Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: difference between @, $

by si_lence (Deacon)
on Dec 07, 2011 at 17:01 UTC ( #942286=note: print w/ replies, xml ) Need Help??


in reply to difference between @, $

Just to add to the answers already given:
I find it really helpful to visualize data structures with Data::Dumper. It helps me to see the difference. So

use Data::Dumper; my @a = ['1','2','3','4']; my $a = ['1','2','3','4']; print Dumper(\@a); print Dumper($a);
gives
$VAR1 = [ [ '1', '2', '3', '4' ] ]; $VAR1 = [ '1', '2', '3', '4' ];
illustrating the difference quite nicely.


Comment on Re: difference between @, $
Select or Download Code
Re^2: difference between @, $
by johngg (Abbot) on Dec 07, 2011 at 18:12 UTC

    It can also be useful to name the variables using Dump() or Dumpxs() (see Data::Dumper) to avoid confusion.

    knoppix@Microknoppix:~$ perl -MData::Dumper -E ' > @arr1 = ( 1 .. 4 ); > @arr2 = [ 1 .. 4 ]; > $arr3 = [ 1 .. 4 ]; > print Data::Dumper->Dumpxs( > [ \ @arr1, \ @arr2, $arr3 ], > [ qw{ *arr1 *arr2 arr3 } ], > );' @arr1 = ( 1, 2, 3, 4 ); @arr2 = ( [ 1, 2, 3, 4 ] ); $arr3 = [ 1, 2, 3, 4 ]; knoppix@Microknoppix:~$

    I hope this is of interest.

    Cheers,

    JohnGG

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2014-09-22 08:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (185 votes), past polls