Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; sub rien2rien (@) { my @other = shift; for (my $i = 0; $i < @other; $i++) { my $a = $other[$i]{'first'}; my $b = $other[$i]{'second'}; print "in other sub:\t$a\t$b\n"; } } sub rien () { my $i = 0; my $file ="somefile.html"; my $regexp = "(.*)something(.*)"; open(FH, "<$file"); my @rrayOfHash; (my @data) = split(/<br>/, <FH>); foreach my $tuff (@data) { if ($tuff =~ /$regexp/) { $rrayOfHash[$i]{'first'} = $1; $rrayOfHash[$i]{'second'} =$2; $i++; } } for ($i = 0 ;$i <@data; $i++) { my $a = $rrayOfHash[$i]{'first'}; my $b = $rrayOfHash[$i]{'second'}; print "in sub: \t$a\t$b\n"; } return @rrayOfHash; } my @ut = &rien(); for (my $i = 0; $i < @ut; $i++) { my $a = $ut[$i]{'first'}; my $b = $ut[$i]{'second'}; print "in main:\t$a\t$b\n"; } &rien2rien(@ut);
i imagine it may be a context question but i can't manage how to retrieve the whole array in the "other sub".in sub: bla bleu in sub: bli blo in main: bla bleu in main: bli blo in other sub: bla bleu
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: size of an array of hash
by ikegami (Patriarch) on Oct 04, 2005 at 01:16 UTC | |
|
Re: size of an array of hash
by GrandFather (Saint) on Oct 04, 2005 at 00:08 UTC | |
|
Re: size of an array of hash
by GrandFather (Saint) on Oct 03, 2005 at 23:37 UTC |