It was the absence of the 'use strict;' that permitted the execution. Now fails if 'use strict;' is added to code and 'my' is missing. Added 'use strict;' and 'my'.
Cheers! ________________________________ From: Jim Gibson <jimsgib...@gmail.com> To: beginners@perl.org Sent: Fri, 12 August, 2011 14:13:26 Subject: Re: while(@data) works but why On 8/12/11 Fri Aug 12, 2011 12:02 PM, "Tony Esposito" <tony1234567...@yahoo.co.uk> scribbled: > . > . > . > while(@dat = $sth->fetchrow) { > print "@dat\n"; > . > . > . > > This code works yet there is no 'my @dat' defined anywhere in the code. > Using Perl 5.8.x - 5.14.x > > Q: Why does the variable @dat not need a 'my' in front? It does on my system: #!/usr/local/bin/perl use strict; use warnings; use DBI; my $sth = DBI->connect(); while( my @dat = $sth->fecthrow) { print "dat: ", join(",",@dat), "\n"; } % perl -c esposito.pl Global symbol "@dat" requires explicit package name at esposito.pl line 9. Global symbol "@dat" requires explicit package name at esposito.pl line 10. esposito.pl had compilation errors. perl v5.10.1 -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/