[25665] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 7906 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 22 18:05:44 2005

Date: Tue, 22 Mar 2005 15:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 22 Mar 2005     Volume: 10 Number: 7906

Today's topics:
        Error  "Use of uninitialized value " <metri.jain@gmail.com>
        Error  "Use of uninitialized value " <metri.jain@gmail.com>
    Re: Error  "Use of uninitialized value " <postmaster@castleamber.com>
    Re: Error  "Use of uninitialized value " xhoster@gmail.com
    Re: Extracting words using Regular Expressions <nospam@nospam.com>
    Re: Extracting words using Regular Expressions <1usa@llenroc.ude.invalid>
    Re: Extracting words using Regular Expressions <nospam@nospam.com>
    Re: Extracting words using Regular Expressions <postmaster@castleamber.com>
    Re: Extracting words using Regular Expressions <nospam@nospam.com>
    Re: Extracting words using Regular Expressions <postmaster@castleamber.com>
    Re: graph problem <wh@tever.tld>
    Re: LWP: Any Easy Way to Use Relative Links? <postmaster@castleamber.com>
        memory leak in 5.8.2??? <joe.cipale@radisys.com>
        memory leak in 5.8.2??? <joe.cipale@radisys.com>
    Re: memory leak in 5.8.2??? <postmaster@castleamber.com>
    Re: Net::FTP <aolblowz@yahoo.com>
    Re: Net::FTP <noreply@gunnar.cc>
    Re: regular expression Help <tadmc@augustmail.com>
        simple help jaw56856@yahoo.com
    Re: The error "Use of uninitialized value " <tadmc@augustmail.com>
    Re: The error "Use of uninitialized value " <spamtrap@dot-app.org>
        Two-dim array: Strange "can't use string as ARRAY ref" <markus.dehmann@gmail.com>
    Re: Two-dim array: Strange "can't use string as ARRAY r <emschwar@pobox.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 22 Mar 2005 12:17:06 -0800
From: "geek" <metri.jain@gmail.com>
Subject: Error  "Use of uninitialized value "
Message-Id: <1111522626.920093.219130@g14g2000cwa.googlegroups.com>

Hi all,

I am getting the error "Use of uninitialized value" in the line "else {
stat();}"

Any help will be appreciated. Look below for the code .

Thanks,
MJ

#########################################################
sub stat {
  print header(), start_html("The Statistics for Administrator");
 open(fileHandle,"./outputFile") or die "The file cannot be opened";
 my @fileData = <fileHandle>;
 my $count1=0;
 my $count2=0;
 my $count3=0;
 my $count4=0;
 my $count5=0;
 my $count6=0;
 my $count7=0;
 my $count8=0;
 my $count9=0;
 my $countt=0;
# my @array;
 foreach my $word(@fileData){
 print "******$word";
 my @array=split(/ /, $word);

  foreach my $element(@array){
 if($element eq "CS5375"){
 $count1++;
 }
 if($element eq "cd"){
 $count2++;
 }
 if($element eq "cp"){
 $count3++;
 }
 if($element eq "vim"){
 $count4++;
 }
 if($element eq "%ls-l"){
 $count5++;
 }
 if($element eq "man"){
 $count6++;
 }
 if($element eq "perl-v"){
 $count7++;
 }
 if($element eq "all"){
 $count8++;
 }
 if($element eq "finger"){
 $count9++;
 }
 if($element eq "ftp\n"){
 $countt++;
# print "hello";
 }
}
}

   my $noLine=0;
   open( fileHandle,"<./outputFile");
   $noLine++ while <fileHandle>;
   print "Number of lines in the file is $noLine";
   my $noUsers= $noLine/2;
   print br;
   print "Number of users is $noUsers";
   print br;
   my $finalAvg=0;
   open(handGrade,"./gradeFile") or die "gradeFile cannot be opened";
   my @avgarr = <handGrade>;
   my $tmpAvg;
   foreach my $avg(@avgarr){
   $tmpAvg="$finalAvg"+"$avg";
   $finalAvg=$tmpAvg/2;
   }
  print "The average is $finalAvg";
  print br;
  my $percentage1=($count1/$noUsers)*100;
  print " The percentage for first question is $percentage1";
  my $percentage2=($count2/$noUsers)*100;
  print br;
#####################################################################



------------------------------

Date: 22 Mar 2005 12:30:31 -0800
From: "geek" <metri.jain@gmail.com>
Subject: Error  "Use of uninitialized value "
Message-Id: <1111523431.884629.118890@z14g2000cwz.googlegroups.com>

Hi all,

I am getting the error of "Use of uninitialized value" in the line
"else { stat();}"

Any help will be appreciated. Look at the bottom for the code .

#########################################################
sub stat {
  print header(), start_html("The Statistics for Administrator");
 open(fileHandle,"./outputFile") or die "The file cannot be opened";
 my @fileData = <fileHandle>;
 my $count1=0;
 my $count2=0;
 my $count3=0;
 my $count4=0;
 my $count5=0;
 my $count6=0;
 my $count7=0;
 my $count8=0;
 my $count9=0;
 my $countt=0;
# my @array;
 foreach my $word(@fileData){
 print "******$word";
 my @array=split(/ /, $word);

  foreach my $element(@array){
 if($element eq "CS5375"){
 $count1++;
 }
 if($element eq "cd"){
 $count2++;
 }
 if($element eq "cp"){
 $count3++;
 }
 if($element eq "vim"){
 $count4++;
 }
 if($element eq "%ls-l"){
 $count5++;
 }
 if($element eq "man"){
 $count6++;
 }
 if($element eq "perl-v"){
 $count7++;
 }
 if($element eq "all"){
 $count8++;
 }
 if($element eq "finger"){
 $count9++;
 }
 if($element eq "ftp\n"){
 $countt++;
# print "hello";
 }
}
}

   my $noLine=0;
   open( fileHandle,"<./outputFile");
   $noLine++ while <fileHandle>;
   print "Number of lines in the file is $noLine";
   my $noUsers= $noLine/2;
   print br;
   print "Number of users is $noUsers";
   print br;
   my $finalAvg=0;
   open(handGrade,"./gradeFile") or die "gradeFile cannot be opened";
   my @avgarr = <handGrade>;
   my $tmpAvg;
   foreach my $avg(@avgarr){
   $tmpAvg="$finalAvg"+"$avg";
   $finalAvg=$tmpAvg/2;
   }
  print "The average is $finalAvg";
  print br;
  my $percentage1=($count1/$noUsers)*100;
  print " The percentage for first question is $percentage1";
  my $percentage2=($count2/$noUsers)*100;
  print br;
#####################################################################



------------------------------

Date: 22 Mar 2005 20:42:07 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Error  "Use of uninitialized value "
Message-Id: <Xns9621958E37AA7castleamber@130.133.1.4>

geek wrote:

> Hi all,
> 
> I am getting the error of "Use of uninitialized value" in the line
> "else { stat();}"

yes.

I can give you one advice: stop writing (CGI) scripts until you have read 
at least two books on Perl.

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


------------------------------

Date: 22 Mar 2005 20:59:34 GMT
From: xhoster@gmail.com
Subject: Re: Error  "Use of uninitialized value "
Message-Id: <20050322155934.265$qs@newsreader.com>

"geek" <metri.jain@gmail.com> wrote:
> Hi all,
>
> I am getting the error of "Use of uninitialized value" in the line
> "else { stat();}"
>
> Any help will be appreciated. Look at the bottom for the code .

That line does not appear in your code.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: Tue, 22 Mar 2005 14:09:51 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: Extracting words using Regular Expressions
Message-Id: <1111518674.611276@nntp.acecape.com>

"Paul Lalli" <mritty@gmail.com> wrote in message
news:1PZ%d.31803$db6.25283@trndny02...

> > if ( $line =~ /\&ck=[0-9]{4}/ )
>
> '[0-9]' is more compactly written '\d'
>
> > That works great, but am unable to easily figure out then how to extract
> > just that word.
>
> What word?
ck=5458

Which could be buried in the line

www.notarealwebsite.com/cgi/verify.pl?userid=32&ck=0420&date=022005

> > I realize it's a s/// scenario,
>
> It is?

meaning I imagined what I would need to do would be to find the line that
matches /\&ck=[0-9]{4}/
then do a substitution (as a delettion //) for everything that didn't match
that.

> perldoc perlrequick
> perldoc perlretut
> perldoc perlre

thanks, will read them over now

daniel




------------------------------

Date: Tue, 22 Mar 2005 19:28:39 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Extracting words using Regular Expressions
Message-Id: <Xns96219349D519asu1cornelledu@127.0.0.1>

"daniel kaplan" <nospam@nospam.com> wrote in
news:1111518674.611276@nntp.acecape.com: 

> "Paul Lalli" <mritty@gmail.com> wrote in message
> news:1PZ%d.31803$db6.25283@trndny02...
> 
>> > if ( $line =~ /\&ck=[0-9]{4}/ )
>>
>> '[0-9]' is more compactly written '\d'
>>
>> > That works great, but am unable to easily figure out then how to
>> > extract just that word.
>>
>> What word?
> ck=5458
> 
> Which could be buried in the line
> 
> www.notarealwebsite.com/cgi/verify.pl?userid=32&ck=0420&date=022005
> 

Are you writing a CGI script?

If so, use CGI.pm.

Sinan.


------------------------------

Date: Tue, 22 Mar 2005 16:05:03 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: Extracting words using Regular Expressions
Message-Id: <1111525588.320071@nntp.acecape.com>

"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message
news:Xns96219349D519asu1cornelledu@127.0.0.1...
> >
> > www.notarealwebsite.com/cgi/verify.pl?userid=32&ck=0420&date=022005
> >
>
> Are you writing a CGI script?
>
> If so, use CGI.pm.
>

I can see why it looked that way, but no.  Actually I already have the CGI
script written for the above link.  It's for validating a new user.  But I
also wanted a program that reads the email as well, so users could just send
it back, rather than clicking the link, and then I would extract the unique
verification code for that user "ck=XXXX".

But I have it now, I am sure it isn't the most pleasant way, or the most
efficient, but thanks to someone I finaly got it.

Thanks




------------------------------

Date: 22 Mar 2005 21:28:49 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Extracting words using Regular Expressions
Message-Id: <Xns96219D795E048castleamber@130.133.1.4>

daniel kaplan wrote:

> users could just send it back, rather than clicking the link, and then
> I would extract the unique verification code for that user "ck=XXXX".
> 
> But I have it now, I am sure it isn't the most pleasant way, or the
> most efficient, but thanks to someone I finaly got it.

Extract the link, and use URI::QueryParam

Oh, and if you got a solution to a question, post it (unless it already has 
been posted, then you can refer to the message (ID)).

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


------------------------------

Date: Tue, 22 Mar 2005 16:45:07 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: Extracting words using Regular Expressions
Message-Id: <1111527992.860681@nntp.acecape.com>

"John Bokma" <postmaster@castleamber.com> wrote in message
news:Xns96219D795E048castleamber@130.133.1.4...
> daniel kaplan wrote:


> Oh, and if you got a solution to a question, post it (unless it already
has
> been posted, then you can refer to the message (ID)).

My posting ettiquette is far below everyone's standards here, so am trying
to make sure I do right.  If I read you correctly you are saying "when you
find the answer post it so everyone knows" right?

But not sure what you meant by:
>(unless it already has
> been posted, then you can refer to the message (ID)).

Just want to do it reight is all.

Thanks,

Daniel





------------------------------

Date: 22 Mar 2005 22:30:43 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Extracting words using Regular Expressions
Message-Id: <Xns9621A7F849850castleamber@130.133.1.4>

daniel kaplan wrote:

> "John Bokma" <postmaster@castleamber.com> wrote in message
> news:Xns96219D795E048castleamber@130.133.1.4...
>> daniel kaplan wrote:
> 
>> Oh, and if you got a solution to a question, post it (unless it
>> already 
> has
>> been posted, then you can refer to the message (ID)).
> 
> My posting ettiquette is far below everyone's standards here, so am
> trying to make sure I do right.  If I read you correctly you are
> saying "when you find the answer post it so everyone knows" right?

Yup, posts are archived, for example. Imagine you find a "I got it, it 
works" without the solution. I also see it as a kind of respect to the 
people who helped, show them your solution, maybe it's even better than 
what they suggested, or maybe it's a bad solution (and that can be 
discussed)

> But not sure what you meant by:
>>(unless it already has
>> been posted, then you can refer to the message (ID)).
> 
> Just want to do it reight is all.

If you used a solution given by someone, you can write something like:

I used the solution <name, Message-ID: .... > suggested and it works, 
thanks!

Message-ID is sufficient. You can find it if you view the headers of the 
message, for example the ID of your message I reply to is 
<1111527992.860681@nntp.acecape.com>

It can be used to find the message back, for example with Google:

<http://groups-beta.google.com/groups?selm=1111527992.860681%
40nntp.acecape.com&output=gplain>

(the message isn't in Google yet, since I get a no found).

I have configured Firefox in such a way [1] that when I type:

id 1111527992.860681@nntp.acecape.com

it goes to the above URL :-D

[1] http://johnbokma.com/firefox/keymarks-explained.html

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


------------------------------

Date: Tue, 22 Mar 2005 21:53:34 +0000
From: Octo Mancer <wh@tever.tld>
Subject: Re: graph problem
Message-Id: <pan.2005.03.22.21.53.33.818173@tever.tld>

On Tue, 22 Mar 2005 14:43:40 +0000, Sokar wrote:

<SNIP>
> 
>   open(IMG, ">pie1.jpeg") or die $!;
>   binmode IMG;
>   print $image->jpeg;

ITYM

print IMG $image->jpeg;

>   close IMG;
> 
> This bit of code actually creates a jpeg and stores it on the hard drive.
> What I am looking to do is actually create the graph and then e-mail it to
> a person.  I was wondering if anyone knew how I could maybe instead of
> writing the graph into an actual jpeg, write it into a variable and then
> e-mail the variable as a jpeg to an e-mail address, to save me having the
> created jpegs sitting on my hard drive.

Use IO::Scalar (code untested):

my $img;
my $imgScalar = IO::Scalar->new(\$img);
print $imgScalar $image->jpeg;

HTH
Rich


------------------------------

Date: 22 Mar 2005 19:15:14 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: LWP: Any Easy Way to Use Relative Links?
Message-Id: <Xns962186D3A493Ccastleamber@130.133.1.4>

Hal Vaughan wrote:

> Jay Tilton wrote:
> 
>> Hal Vaughan <hal@thresholddigital.com> wrote:
>> 
>> : I'm exploring LWP and trying to write a program that will pull down
>> : some web
>> : pages.  When I read one page, I use regular expressions to find the
>> : links for other pages I want to download.
>> 
>> Regex-parsing HTML?  Yuck.
>> 
>> : Sometimes the links are relative
>> : (like /cgi/link.pl or subdir/newfile.html) instead of including a
>> : domain name.  I don't see anything in the doc files about any
>> : consistency from one connection to another.
>> : 
>> : Is there any module out there for keeping track of domains and
>> : handling relative URLs?
>> 
>> HTML::LinkExtor is your one-stop answer.  It can snatch links from
>> HTML better than your regex can, and it can return all links in a
>> fully-qualified form if given a base URL.
> 
> I had never seen that before.  I'll look into it.  For this project,
> though, I scan each page for specific links with a specific phrase as
> the displayed text part of the link.

Haven't used HTML::LinkExtor, but I have used HTML::TreeBuilder a lot, 
see also HTML::Element for some specific documentation.

I guess look_down( _tag => 'a', ... ) will make several things a bit 
easier, especially if you want only specific links.

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


------------------------------

Date: 22 Mar 2005 13:32:28 -0800
From: "joe.cipale@radisys.com" <joe.cipale@radisys.com>
Subject: memory leak in 5.8.2???
Message-Id: <1111527148.542438.231190@g14g2000cwa.googlegroups.com>

I have an application written in Perl/tk that will write a small file
(~128 bytes) to disk. At random intervals, the application is unable to
write ti the disk. No error message is given, the write file is
executed but the trap 'or die...' is not. The OS is RedHat 7.2.

I have checked the amount of disk space (~85% in use of a 40GB HDD) and
this tells me that it isn't a disk spave issue. If I shutdown and let
the server sit for about 20 minutes, then boot it back up, the system
will allow files to be written to disk once again. A couple of possible
explanations have come up:
1 - The OS is runnung out of file handles.
2 - There is a (possible) memory in perl 5.8.x

Has anyone seen this behaviour before?

TIA,

Joe



------------------------------

Date: 22 Mar 2005 13:32:32 -0800
From: "joe.cipale@radisys.com" <joe.cipale@radisys.com>
Subject: memory leak in 5.8.2???
Message-Id: <1111527152.371338.167950@o13g2000cwo.googlegroups.com>

I have an application written in Perl/tk that will write a small file
(~128 bytes) to disk. At random intervals, the application is unable to
write ti the disk. No error message is given, the write file is
executed but the trap 'or die...' is not. The OS is RedHat 7.2.

I have checked the amount of disk space (~85% in use of a 40GB HDD) and
this tells me that it isn't a disk spave issue. If I shutdown and let
the server sit for about 20 minutes, then boot it back up, the system
will allow files to be written to disk once again. A couple of possible
explanations have come up:
1 - The OS is runnung out of file handles.
2 - There is a (possible) memory in perl 5.8.x

Has anyone seen this behaviour before?

TIA,

Joe



------------------------------

Date: 22 Mar 2005 21:45:29 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: memory leak in 5.8.2???
Message-Id: <Xns9621A04CD77B3castleamber@130.133.1.4>

joe.cipale@radisys.com wrote:

> I have an application written in Perl/tk that will write a small file
> (~128 bytes) to disk. At random intervals, the application is unable
> to write ti the disk. No error message is given, the write file is
> executed but the trap 'or die...' is not. The OS is RedHat 7.2.
> 
> I have checked the amount of disk space (~85% in use of a 40GB HDD)
> and this tells me that it isn't a disk spave issue.

Did you check when the program was running?

> If I shutdown and let
> the server sit for about 20 minutes,

Why? To let it cool down? And a shutdown... that sounds like overkill to
me. 

> then boot it back up, the system
> will allow files to be written to disk once again.

Programs in general or your script? 

How much space does it require?

> A couple of possible
> explanations have come up:
> 1 - The OS is runnung out of file handles.
> 2 - There is a (possible) memory in perl 5.8.x

I think you can remove 2 off that list. If you suspect this, create the
smallest possible script that gives the same problems and post it. But
my best guess is: it's not a memory leaking problem *in* perl. In your
script: maybe, yes. 

You can try to create a file (or files) which use rougly the same amount
of disk space. Does that work? 

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


------------------------------

Date: Tue, 22 Mar 2005 16:59:57 -0500
From: lucas <aolblowz@yahoo.com>
Subject: Re: Net::FTP
Message-Id: <4ZGdneRGHJvBCN3fRVn-pA@rogers.com>

Paul Lalli wrote:

> That script works fine for me with Perl 5.8.0 on Solaris, using Net::FTP
> 2.65.  Have you examined the contents of @_ using Data::Dumper to see
> what's actually in the reference @_ contains?  Try adding these lines:
> 
> use Data::Dumper;
> print Dumper(\@_);
> 
> Also, what versions of Perl and Net::FTP are you using?
> perl -v
> perl -MNet::FTP -e'print $Net::FTP::VERSION;'
> 
> If you're not using at least Perl 5.80 and Net::FTP 2.65, consider
> upgrading.

i am running perl v5.8 and Net::FTP v2.70.  DataDumper did work and printed
out:

$VAR1 = [
          [
            'Games X Copy',
            'index.html',
            'EasyOS.zip',
          ]
        ];

i was hoping to be able to just get a plain file list, but i can make this
work.  thanks for your help
-- 
lucas
-------------------------
Perl Coder since 2001
shift || die;
-------------------------


------------------------------

Date: Tue, 22 Mar 2005 23:15:31 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Net::FTP
Message-Id: <3abjo2F66skmeU1@individual.net>

lucas wrote:
> DataDumper did work and printed out:
> 
> $VAR1 = [
>           [
>             'Games X Copy',
>             'index.html',
>             'EasyOS.zip',
>           ]
>         ];

That means that @_ contains one element ( $_[0] ), which is an array 
reference.

> i was hoping to be able to just get a plain file list,

Just dereference the array reference:

     my @files = @{ $_[0] };

     perldoc perlreftut
     perldoc perlref

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: Tue, 22 Mar 2005 15:27:23 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: regular expression Help
Message-Id: <slrnd413dr.8b5.tadmc@magna.augustmail.com>

jtripo <jtripo@hotmail.com> wrote:
> I have the following text
> 
> blah blah blah blah System Is Working blah blah blah blah
> 
> I need a regular expression that will show true only if System Is
> Working is missing. Is there a way to do this?


   print "missing\n" unless /System Is Working/;

or

   print "missing\n" if $_ !~ /System Is Working/;


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 22 Mar 2005 14:24:06 -0800
From: jaw56856@yahoo.com
Subject: simple help
Message-Id: <1111530246.057023.268670@o13g2000cwo.googlegroups.com>

OK this should be simple, but....
I am parsing an error file greping for a cretin conditions, this part I
have working fine
While(<error_file>)
{
	if (/...what ever it is I am looking for.../)
	print output $_
}
That is working fine.
I then log the last runtime (from the error file line item time stamp),
and this too works fine
So the next time I can pick up where we left off and not revisit the
same errors
$last_runtime = $logfile[$#logfile];

What I would like to do is search the error_file from the $last_runtime
on
But I just can't get the strings to match!
What I was trying is this
$x = 1;
while (<error_file > ){
if ($x)
{
	$comp_string = substr($_, 0, 20);
	if(($last_runtime eq $comp_string) )
	{  	$x = 0;print ("this is where i left off\n")}
print ($comp_string, "\n");
}
else
{
print (" found the starting point\n");
	if (/...what ever it is I am looking for.../)
{
		print $_;
		print ("error found");
	}
}
so what is wrong with the if(($last_runtime eq $comp_string) )
statement???
It never matches??



------------------------------

Date: Tue, 22 Mar 2005 15:38:17 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: The error "Use of uninitialized value "
Message-Id: <slrnd41429.8b5.tadmc@magna.augustmail.com>

Sherm Pendley <spamtrap@dot-app.org> wrote:
> A. Sinan Unur wrote:
> 
>> which error?
> 
> Don't be ridiculous. The error is in the subject. 


There is no error in the subject.


> Complaining because he
> didn't repeat it in the message body is petty.


Complaining because he called a warning an error is not petty,
there is an important difference.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 22 Mar 2005 17:44:10 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: The error "Use of uninitialized value "
Message-Id: <7fSdnR6svMwhAt3fRVn-2w@adelphia.com>

Tad McClellan wrote:

> Sherm Pendley <spamtrap@dot-app.org> wrote:
>> A. Sinan Unur wrote:
>> 
>>> which error?
>> 
>> Don't be ridiculous. The error is in the subject.
> 
>> Complaining because he
>> didn't repeat it in the message body is petty.
> 
> 
> Complaining because he called a warning an error is not petty,

A cryptic two-word question like the one above leaves the OP with a vague
impression that he's done something wrong, but does nothing to tell him
what that was, or help him learn to do better next time.

A. Sinan *could* have chosen to be helpful and point out that the text in
the subject was a warning. He chose not to. Instead, he chose to post a
snide two-word comment.

The regulars here can obviously read between the lines to "get" the joke,
but the OP hasn't a prayer of doing so. The comment wasn't intended to be
helpful or constructive, it was intended to make the OP look foolish, so as
to provide a source of amusement for some of the more childish regulars
here.

I call that petty.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


------------------------------

Date: Tue, 22 Mar 2005 17:31:39 -0500
From: Markus Dehmann <markus.dehmann@gmail.com>
Subject: Two-dim array: Strange "can't use string as ARRAY ref"
Message-Id: <3abkmcF67jipgU1@individual.net>

I am using a two-dim hash with a string as first key, and an array as 2nd
key. But it doesn't work! Can anyone tell me what's wrong?

#!/usr/bin/perl -w
$hash{"test"}{["one", "two"]} = 42;
$hash{"test"}{["three", "four"]} = 23;
my $key = "test";
foreach(keys %{$hash{$key}}){
  print "Value for $_ is $hash{$key}{$_}\n"; # ARRAY(0x804c958)
  # print "@$_\n"; # Can't use string ("ARRAY(0x804c958)") as an ARRAY ref 
}

The output is:
Value for ARRAY(0x804c958) is 23

Why does it print only *one* value? Why can't I dereference 
the array ref $_?

Thanks!



------------------------------

Date: Tue, 22 Mar 2005 15:37:11 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Two-dim array: Strange "can't use string as ARRAY ref"
Message-Id: <etoeke75mug.fsf@wilson.emschwar>

Markus Dehmann <markus.dehmann@gmail.com> writes:
> I am using a two-dim hash with a string as first key, and an array as 2nd
> key. But it doesn't work! Can anyone tell me what's wrong?

You can't use an array as a hash key.  The very first paragraph of
perldata says:

       Hashes are unordered collections of scalar values indexed by
       their associated string key.

So when you try to index a hash with an array like this:

> $hash{"test"}{["one", "two"]} = 42;

what's happening instead is that ["one","two"] is being stringified
into something like ARRAY(0x804c958), and that string is what your
second-level hash is being subscripted by.
> The output is:
> Value for ARRAY(0x804c958) is 23
>
> Why does it print only *one* value? Why can't I dereference 
> the array ref $_?

Because it's not an array ref anymore, it's a string.  Only strings
can be stored as the keys of hashes-- the values can be anything you
like.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 7906
***************************************


home help back first fref pref prev next nref lref last post