Author Topic: exmaples/qbjobs.pl - syntax errors  (Read 4655 times)

Achilles

  • Sr. Member
  • ****
  • Posts: 25
exmaples/qbjobs.pl - syntax errors
« on: May 07, 2010, 07:12:06 AM »
Code: [Select]
#       All jobs which are owned by user "yuna" or "tidus"
#
#       my $filter = {};
#       my $filter->{"user"} = ["yuna","tidus"];
#

the second "my $filter" will reinitialize $filter.


there is a var $fileds initialized. but never used.

Code: [Select]
my $fields = ["subjobs"];

- Thomas

jburk

  • Administrator
  • *****
  • Posts: 493
Re: exmaples/qbjobs.pl - syntax errors
« Reply #1 on: May 07, 2010, 02:12:30 PM »
Actually, you need to define the hash before you can assign a value to a specific key.

Achilles

  • Sr. Member
  • ****
  • Posts: 25
Re: exmaples/qbjobs.pl - syntax errors
« Reply #2 on: May 07, 2010, 02:16:18 PM »
Code: [Select]
use strict;
my $filter = {};
my $filter->{"user"} = ["yuna","tidus"];

is giving me:

Code: [Select]
# perl test.pl
Can't use an undefined value as a HASH reference at test.pl line 4.

Perl 5.8.8 (Centos 5.4)

jburk

  • Administrator
  • *****
  • Posts: 493
Re: exmaples/qbjobs.pl - syntax errors
« Reply #3 on: May 10, 2010, 01:52:12 PM »
lose the 'my' declaration on the hash assignment line:

Code: [Select]
use strict;
my $filter = {};
$filter->{"user"} = ["yuna","tidus"];

Achilles

  • Sr. Member
  • ****
  • Posts: 25
Re: exmaples/qbjobs.pl - syntax errors
« Reply #4 on: May 10, 2010, 05:34:34 PM »
my intention was to say:

if you provide examples - provide working examples.

 - Thomas