Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Initialize multiple variables in one statement

by mr_ron (Chaplain)
on Nov 23, 2015 at 20:13 UTC ( #1148427=note: print w/replies, xml ) Need Help??


in reply to Re: Initialize multiple variables in one statement
in thread Initialize multiple variables in one statement

I think the solution might be closer to:

use strict; use warnings; my ($name1, $name2, $name3, $name4, $name5, $name6) = ('') x 6; print "\n $name1, $name2, $name3, $name4, $name5, $name6\n\n";

Using '' x 6 in scalar context just concats the empty string six times yielding just an empty string. So:

use strict; use warnings; my @names = '' x 6; print "$names[2]\n"; __END__ Use of uninitialized value $names[2] in concatenation (.) or string at + ...
Ron

Replies are listed 'Best First'.
Re^3: Initialize multiple variables in one statement
by stevieb (Canon) on Nov 23, 2015 at 20:29 UTC

    Nice catch! :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1148427]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2022-12-08 23:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?