[26156] in Perl-Users-Digest
Perl-Users Digest, Issue: 8347 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 22 18:05:23 2005
Date: Mon, 22 Aug 2005 15:05:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 22 Aug 2005 Volume: 10 Number: 8347
Today's topics:
Dereferencing array/hash element with @{ } instead of $ (Hue-Bond)
Re: Use of uninitialized value Error <tadmc@augustmail.com>
Re: Use of uninitialized value Error <nospam@nospam.com>
Re: Use of uninitialized value Error <nospam@nospam.com>
Use of uninitialized value in substitution (s///) <hlawson@triad.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 22 Aug 2005 21:07:47 +0000 (UTC)
From: "David Serrano (Hue-Bond)" <responder_solo_en_el_grupo@yahoo.es>
Subject: Dereferencing array/hash element with @{ } instead of ${ }
Message-Id: <slrndgkfl3.1qi.responder_solo_en_el_grupo@genus.hue-bond.info>
I'm learning to use references and complex data structures. No problem at
all until I discovered a typo in a program that was working perfectly. I've
investigated that (reading perlref, perldsc, perldata and perlobj) but found
nothing similar except pseudo-hashes, but I think this is not the case since
I'm under strict and I'm not setting up a special first field.
This is the (conveniently shortened) code:
use strict;
use warnings;
my $lines = [
{
stations => [
{
name => "baz"
}
]
}
];
# same as $lines->[0]{stations}[0]{name}
print ${ ${ ${ $lines->[0] }{stations} }[0] }{name},"\n";
print ${ ${ $lines->[0] }{stations} }[0] ,"\n";
print @{ ${ $lines->[0] }{stations} }[0] ,"\n";
print ${ $lines->[0] }{stations} ,"\n";
print @{ $lines->[0] }{stations} ,"\n";
And the output:
baz
HASH(0x8071fbc)
HASH(0x8071fbc)
ARRAY(0x8071fec)
ARRAY(0x8071fec)
I expect to see some error instead of the second HASH(0x8071fbc) and the
second ARRAY(0x8071fec). Why not?
[ ... ] Could it be a slice of just one element?
use strict;
use warnings;
my $a=[4,6,8];
print $$a[1], "\n"; ## normal usage, prints 6 without warnings
print @$a[1], "\n"; ## what I'm doing, also prints 6 without warnings
Using an array instead of a reference yields "Scalar value @a[1] better
written as $a[1] at - line 4.", why doesn't that happen with references?
Maybe Perl doesn't know what @$a[1] is?
--
David Serrano
------------------------------
Date: Mon, 22 Aug 2005 15:52:02 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Use of uninitialized value Error
Message-Id: <slrndgkeni.m06.tadmc@magna.augustmail.com>
A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:
> "daniel kaplan" <nospam@nospam.com> wrote in
> news:1124660477.785784@nntp.acecape.com:
>
>> The error is: uninittest.pl: Use of uninitialized value in
>> concatenation (.) or string at uninittest.pl line 45.
> To fix your code, you need to make sure all variables hold valid values
> when you use them in operations.
Your answer is not in keeping with "one of the rudest people i have
ever encountered on a newsgroup".
You're going to blow your reputation! :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 22 Aug 2005 17:04:36 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: Use of uninitialized value Error
Message-Id: <1124744604.232839@nntp.acecape.com>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrndgkeni.m06.tadmc@magna.augustmail.com...
> Your answer is not in keeping with "one of the rudest people i have
> ever encountered on a newsgroup".
>
> You're going to blow your reputation! :-)
oy...here we go again ;-)
------------------------------
Date: Mon, 22 Aug 2005 17:07:18 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: Use of uninitialized value Error
Message-Id: <1124744766.460026@nntp.acecape.com>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrndgkeni.m06.tadmc@magna.augustmail.com...
> Your answer is not in keeping with "one of the rudest people i have
> ever encountered on a newsgroup".
>
> You're going to blow your reputation! :-)
ah but don't worry, i fought back a little ...
in reply to:
>> my $came_from = 'I must learn proper CGI programming first';
i responded with:
But even after changing: my $came_from = xxxxxxxxx
to: my $came_from = 'You need to learn to be nicer to others';
so if you want, we can do this dance....but am so tired, we don't have to,
do we? ;-)
daniel
------------------------------
Date: Mon, 22 Aug 2005 21:51:37 GMT
From: Hugh Lawson <hlawson@triad.rr.com>
Subject: Use of uninitialized value in substitution (s///)
Message-Id: <87y86tk5cm.fsf@desktop.xx.yy>
This error occurs in this program. What is uninitialized in the substitution?
I've spent quite a while searching for clues.
#! /usr/bin/perl
use strict;
use warnings;
use diagnostics;
use GDBM_File;
my $db_file;
my %fred;
my $word;
my $defn;
my $db;
$db_file="frenchwords";
$db = tie %fred, 'GDBM_File', $db_file, &GDBM_WRCREAT, 0640;
# Install DBM Filters.
######Error comes on next line******************
$db->filter_fetch_key ( sub { s/\0$// } ) ;
$db->filter_store_key ( sub { $_ .= "\0" } ) ;
$db->filter_fetch_value( sub { s/\0$// } ) ;
$db->filter_store_value( sub { $_ .= "\0" } ) ;
while (($word, $defn) = each (%fred)) { print ("$word: $defn\n"); }
undef $db;
untie %fred;
#end of program.
--
Hugh Lawson
hlawson@triad.rr.com
------------------------------
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 8347
***************************************