Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

pme

by pme (Pilgrim)
on Aug 13, 2001 at 20:01 UTC ( #104470=user: print w/ replies, xml ) Need Help??


use strict;
use Data::Dumper;

my $scalar = 13;
my @array = (1, 2, 3);
my %hash  = (1, 2, 3, 4, 5, 6);

print 'scalar: ' . Dumper( \$scalar ) . "\n";
print 'array : ' . Dumper( \@array  ) . "\n";
print 'hash  : ' . Dumper( \%hash   ) . "\n";

my $scalarref = \$scalar;
$$scalarref = 14;
print "scalar is 14 now: $scalar\n";

my $arrayref = \@array;
$arrayref->[1] = 8;
print "array 1th is 8 now: $array[1]\n";
$$arrayref[1] = 5;
print "array 1th is 5 now: $array[1]\n";

my $hashref = \%hash;
$hashref->{3} = 15;
print "hash 3 is 15 now: $hash{3}\n";
${%$hashref}{3} = 16;
print "hash 3 is 16 now: $hash{3}\n";

# Array -> LoL - List of lists
my @lol = (
    [ 1, 2, 3 ],
    [ 4, 5, 6 ],
    [ 7, 8, 9 ],
);

my $lolref = \@lol;

print 'lol: ' . Dumper( $lolref ) . "\n";
print "lol    1, 1, must be 5: $lol[1][1]\n";
print "lolref 1, 1, must be 5: $lolref->[1][1]\n";
print "lolref 1, 1, must be 5: $$lolref[1][1]\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2014-09-20 10:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (158 votes), past polls