And the clouds parted, and Rob Dixon said...
>
> Gary Stainburn wrote:
> >
>
> Hi Gary.
>
> Just one more offering:
>
>$_ = '' foreach my ($fred, $ginger);
>
> HTH,
>
> Rob
...and in the spirit of TMTOWTDI...
map {$_=""} my ($fred, $ginger);
:)
/~
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 st
From: Gary Stainburn <[EMAIL PROTECTED]>
> 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/bi
in @_, and
@_ contains aliases to the variables that were passed. So modifying $_
modified $x and $y directly without having to return a value.
Rob
-Original Message-
From: Gary Stainburn [mailto:[EMAIL PROTECTED]
Sent: Friday, October 03, 2003 11:27 AM
To: James Edward Gray II
Cc: [EMAIL PROTE
On Friday 03 Oct 2003 4:05 pm, James Edward Gray II wrote:
> On Friday, October 3, 2003, at 09:55 AM, Gary Stainburn wrote:
> > Hi folks
>
> Howdy.
>
> > 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.
>
> my $fred=$ginger='';
Should be:
my $fred = my $ginger = '';
> my ($fred,$ginger)='';
Should be:
my ($fred,$ginger) = ('','');
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
On Friday, October 3, 2003, at 09:55 AM, Gary Stainburn wrote:
Hi folks
Howdy.
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?
How about:
my($fred, $ginger) = ('') x 2;
James
> 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=
Hi folks
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='';
pr