UPDATED MY POST. how do I access it from sub two?
#!/usr/bin/perl -w use strict; system('clear'); my $test = first(); two($test); sub first{ my @data; my %objREF; $data[2] = 'hi there'; $objREF{poker} = \$data[2]; } sub two{ my $objREF = shift; #print "$objREF{'poker'}"; #print "$$objREF{'poker'}"; #print "$objREF->{'poker'}"; #print "$$objREF->{'poker'}"; #print "$$$objREF{'poker'}"; #print "$$$$objREF{'poker'}"; #print "${$objREF{'poker'}}\n"; print "$${$objREF->{'poker'}}\n"; }
### original post ###
I have read that linked lists in perl are slow but I can't quite find an example of one. Is this a linked list? If so how can I change it without losing any of the functionality?
#!/usr/bin/perl -w use strict; system('clear'); my @data; $data[2] = 'hi there'; my %objREF; $objREF{poker} = \$data[2]; print "struct example\n"; print "======================================\n"; print "original value:\n"; print_me(); print "change by array value:\n"; $data[2] = 'joker'; print_me(); print "change value by ref:\n"; ${$objREF{poker}} = 'batman'; print_me(); print "change the array\n"; $data[2] = 'robin'; print_me(); sub print_me{ print "array is: $data[2]\n"; print "Ref is: ${$objREF{poker}}\n\n"; }

Edit by castaway - restored original content


In reply to code sample: possible improvements by arcnon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.