in reply to what is @$varname in perl
You have:
But if you ask me, it'd be tons more clear if you did this:foreach $line (@lines){ chomp $line; $count++; next unless $count; # skip header in csv my $row; @$row = split(/,/, $line ); push @$sheet2 , $row; }
Another example is:my @sheet2 = () # .... foreach $line (@lines){ chomp $line; $count++; next unless $count; # skip header in csv my @row = (); @row = split(/,/, $line ); push @sheet2 , \@row; }
Should be:@$sheet2 = ();
or@sheet2 = ();
It seems to me you're conflating scalars, arrays, and references. Cleaning up the code and being consistent will go a long way in dispelling your confusion.$sheet2 = [];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: what is @$varname in perl
by sandy105 (Scribe) on Jul 03, 2014 at 12:10 UTC | |
by 2teez (Vicar) on Jul 03, 2014 at 15:35 UTC | |
by perlfan (Parson) on Jul 04, 2014 at 03:18 UTC |