Gary Stainburn wrote: > > I've got a query about variable initialisation. I want to initialise a list of > variables to an empty string, but I'm having troubles. > > What's the best wat to do this? > > If I use the following I get: > > [EMAIL PROTECTED] gary]$ cat t > #!/usr/bin/perl -w > > use strict; > > my $fred=$ginger=''; > > print "fred=$fred\n"; > print "ginger=$ginger\n"; > [EMAIL PROTECTED] gary]$ ./t > Global symbol "$ginger" requires explicit package name at ./t line 5. > Global symbol "$ginger" requires explicit package name at ./t line 8. > Execution of ./t aborted due to compilation errors. > [EMAIL PROTECTED] gary]$ > > but if I use: > > [EMAIL PROTECTED] gary]$ cat t > #!/usr/bin/perl -w > > use strict; > > my ($fred,$ginger)=''; > > print "fred=$fred\n"; > print "ginger=$ginger\n"; > [EMAIL PROTECTED] gary]$ ./t > fred= > Use of uninitialized value in concatenation (.) or string at ./t line 8. > ginger= > [EMAIL PROTECTED] gary]$
Hi Gary. Just one more offering: $_ = '' foreach my ($fred, $ginger); HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]