while(@data) works but why
--0-1635047660-1313175733=:90702
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
..=0A.=0A.=0Awhile( [at] dat =3D $sth->fetchrow) {=0A print " [at] dat\n";=0A.=
=0A.=0A.=0A=0AThis code works yet there is no 'my [at] dat' defined anywhere in=
the code.=0AUsing Perl 5.8.x - 5.14.x=0A=0AQ: Why does the variable [at] dat n=
ot need a 'my' in front?=0A=0ACheers!
--0-1635047660-1313175733=:90702--
Re: while(@data) works but why
On Fri, Aug 12, 2011 at 3:02 PM, Tony Esposito
<tony1234567893 [at] yahoo.co.uk> wrote:
> .
> .
> .
> while( [at] dat =3D $sth->fetchrow) {
> =C2=A0 =C2=A0 =C2=A0 =C2=A0print " [at] dat\n";
> .
> .
> .
>
> This code works yet there is no 'my [at] dat' defined anywhere in the code.
> Using Perl 5.8.x - 5.14.x
>
> Q: Why does the variable [at] dat not need a 'my' in front?
See `perldoc strict'. In particular, the "strict vars" section.
--
Brandon McCaig <http://www.bamccaig.com/> <bamccaig [at] gmail.com>
V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl.
Castopulence Software <http://www.castopulence.org/> <bamccaig [at] castopulence=
..org>
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: while(@data) works but why
On 8/12/11 Fri Aug 12, 2011 12:02 PM, "Tony Esposito"
<tony1234567893 [at] yahoo.co.uk> scribbled:
> .
> .
> .
> while( [at] dat = $sth->fetchrow) {
> print " [at] dat\n";
> .
> .
> .
>
> This code works yet there is no 'my [at] dat' defined anywhere in the code.
> Using Perl 5.8.x - 5.14.x
>
> Q: Why does the variable [at] 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 [at] dat = $sth->fecthrow) {
print "dat: ", join(",", [at] dat), "\n";
}
% perl -c esposito.pl
Global symbol " [at] dat" requires explicit package name at esposito.pl line 9.
Global symbol " [at] dat" requires explicit package name at esposito.pl line 10.
esposito.pl had compilation errors.
perl v5.10.1
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: while(@data) works but why
--0-1759626266-1313176531=:52794
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
got it ... thank you. cheers!=0A=0A=0A=0A=0A______________________________=
__=0AFrom: Brandon McCaig <bamccaig [at] gmail.com>=0ATo: Tony Esposito <tony123=
4567893 [at] yahoo.co.uk>=0ACc: beginners [at] perl.org=0ASent: Fri, 12 August, 2011 =
14:08:52=0ASubject: Re: while( [at] data) works but why=0A=0AOn Fri, Aug 12, 201=
1 at 3:02 PM, Tony Esposito=0A<tony1234567893 [at] yahoo.co.uk> wrote:=0A> .=0A>=
.=0A> .=0A> while( [at] dat =3D $sth->fetchrow) {=0A> print " [at] dat\n";=0A=
> .=0A> .=0A> .=0A>=0A> This code works yet there is no 'my [at] dat' defined a=
nywhere in the code.=0A> Using Perl 5.8.x - 5.14.x=0A>=0A> Q: Why does the =
variable [at] dat not need a 'my' in front?=0A=0ASee `perldoc strict'. In parti=
cular, the "strict vars" section.=0A=0A=0A-- =0ABrandon McCaig <http://www.=
bamccaig.com/> <bamccaig [at] gmail.com>=0AV zrna gur orfg jvgu jung V fnl. Vg q=
brfa'g nyjnlf fbhaq gung jnl.=0ACastopulence Software <http://www.castopule=
nce.org/> <bamccaig [at] castopulence.org>=0A
--0-1759626266-1313176531=:52794--
Re: while(@data) works but why
--0-1623414873-1313176674=:70994
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
It was the absence of the 'use strict;' that permitted the execution.=0ANow=
fails if 'use strict;' is added to code and 'my' is missing.=0AAdded 'use =
strict;' and 'my'.=0A=0ACheers!=0A=0A=0A=0A=0A___________________________ __=
___=0AFrom: Jim Gibson <jimsgibson [at] gmail.com>=0ATo: beginners [at] perl.org=0ASe=
nt: Fri, 12 August, 2011 14:13:26=0ASubject: Re: while( [at] data) works but why=
=0A=0AOn 8/12/11 Fri Aug 12, 2011 12:02 PM, "Tony Esposito"=0A<tony123456=
7893 [at] yahoo.co.uk> scribbled:=0A=0A> .=0A> .=0A> .=0A> while( [at] dat =3D $sth->=
fetchrow) {=0A> print " [at] dat\n";=0A> .=0A> .=0A> .=0A> =0A> This cod=
e works yet there is no 'my [at] dat' defined anywhere in the code.=0A> Using P=
erl 5.8.x - 5.14.x=0A> =0A> Q: Why does the variable [at] dat not need a 'my' i=
n front?=0A=0AIt does on my system:=0A=0A#!/usr/local/bin/perl=0Ause strict=
;=0Ause warnings;=0A=0Ause DBI;=0A=0Amy $sth =3D DBI->connect();=0A=0Awhile=
( my [at] dat =3D $sth->fecthrow) {=0A print "dat: ", join(",", [at] dat), "\n";=0A=
}=0A=0A% perl -c esposito.pl=0AGlobal symbol " [at] dat" requires explicit packa=
ge name at esposito.pl line 9.=0AGlobal symbol " [at] dat" requires explicit pac=
kage name at esposito.pl line 10.=0Aesposito.pl had compilation errors.=0A=
=0Aperl v5.10.1=0A=0A=0A=0A-- =0ATo unsubscribe, e-mail: beginners-unsubscr=
ibe [at] perl.org=0AFor additional commands, e-mail: beginners-help [at] perl.org=0Ah=
ttp://learn.perl.org/
--0-1623414873-1313176674=:70994--