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/


Reply via email to