Hello all, I want to make a function to list all jobs name from a printer. The format of the jobs name is like d00001-001, d00002-001. To list all the jobs and get the correct job name, i use the lpstat command, that returns me lines like this one: _DATA_ HP4100V-4 rodza 2597888 Seg 21 Jun 2004 12:56:56 BRT _DATA_
in the first camp i got the printer name (HP4100V) followed by the job numer (separated by -), the owner of the job, the job length in bytes and the started job data. What i mean here is to use a hash with 2 camps: 'name' and 'jobs'. In the 'name' i put the printer name. In the 'jobs' i put a hash reference that got the job name like his key associated with the owner job name. well, i write this code that are not working:: _BEGIN_ #!/usr/bin/perl use warnings; use strict; sub lst_job{ # this sub list all the jobs name from a printer my ($printer) = @_; my @lpstat = `lpstat -P $printer`; my %jobs; #here i assembly the job name (like d00001-01) for(my $i=0; $i < @lpstat; $i++){ $lpstat[$i] =~ /\w+\-(\d+)\s+(\w+)\s+/; $jobs{sprintf("d%05d-001",$1)} = $2; } my %printer = ( name => $printer, jobs => \%jobs, ); return %printer; } my %printers = lst_job("HP4100V"); print "The printers: ".$printers{name}." got this job(s):\n"; foreach my $keys (keys $printers{jobs}){ print $printers{jobs}->{$key}."\n"; }; _END_ this is the error i got: _ERROR_ Type of arg 1 to keys must be hash (not hash element) at printer.pm line 61, near "})" _ERROR_ Can someone help me? Thanks __________________________________ Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. http://promotions.yahoo.com/new_mail -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>