Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^4: Symbolic references

by Anonymous Monk
on Apr 15, 2013 at 06:57 UTC ( #1028687=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Symbolic references
in thread Symbolic references

I used the wrong word 'reference' it should have been variable. I've tried to impliment your code below, but I'm still lost...

foreach $argnum (0..$#ARGV){ print "$ARGV[$argnum]\n"; my $path=$ARGV[$argnum]; @path=split /\//,$path; $node=node->{$_} for @path; print $node; } print "\n"; }


Comment on Re^4: Symbolic references
Download Code
Replies are listed 'Best First'.
Re^5: Symbolic references
by Anonymous Monk on Apr 15, 2013 at 07:05 UTC
    got it! phew!
    foreach $argnum (0..$#ARGV){ $node=$ret; print "$ARGV[$argnum]\n"; @path=split /\//,$ARGV[$argnum]; print Dumper @path; #debugging helps! $node=$node->{$_} for @path; print $node; } print "\n"; }
    Thanks!
      Just a minor note: your way to iterate thru different arguments by index is rather cumbersome

      just do

      ~$ perl -E 'foreach $arg (@ARGV) { say split /\//,$arg }' 1/2 a/b/c 12 abc

      And plz consider using strict and warnings!

      Cheers Rolf

      ( addicted to the Perl Programming Language)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2015-07-30 23:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls