in reply to Re: what is @$varname in perl
in thread what is @$varname in perl
"i had to write a csv sorting code for which i used the following code :"
i wrote this multithreaded program to sort files in parallel ,this was actually the subroutine part (sort of).initial code which i tried would append sorted line to previous line, so 2 lines would be clubbed in 1 line ; hence i found THIS code on net
initial code below
foreach(@csvfiles) { $csvfile=$_; open(hanr,"D:\\stock\\".$csvfile) or die"error read $!\n"; open(hanw,">D:\\stock\\sorted".$csvfile) or die"error write $!\n"; @lines = (); @lines = <hanr>; shift(@lines);#remove header csv @sorted = sort multisort @lines; sub multisort { ($field1a, $field2a, $field3a)=split(/\,/, $a); ($field1b, $field2b, $field3b)=split(/\,/, $b); $field1a cmp $field1b or $field2a cmp $field2b; } print hanw @sorted; close(hanw); close(hanr); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: what is @$varname in perl
by andal (Hermit) on Jul 03, 2014 at 10:58 UTC | |
by Laurent_R (Canon) on Jul 03, 2014 at 20:38 UTC | |
by andal (Hermit) on Jul 04, 2014 at 07:55 UTC | |
by sandy105 (Scribe) on Jul 03, 2014 at 11:03 UTC | |
by andal (Hermit) on Jul 04, 2014 at 08:06 UTC |
In Section
Seekers of Perl Wisdom