I want to write a Perl script to sort a file containing multiple comma separated values (and output the results back to standard output)
scriptname -f n in_file
Switch Description
-f select field to sort by
where n = the nth value (in the csv) to sort by.
For example, here is what a in_file might look like...
1, abc, asldfjajfal
15, djsk, 1sljfal
24, aldfj, jfaldjfa
If I issue a 'scriptname -f 1 in_file, the output should be:
1, abc, asldfjajfal
15, djsk, 1sljfal
24, aldfj, jfaldjfa
If I issue a 'scriptname -f 3 in_file, the output should be:
1, abc, asldfjajfal
24, aldfj, jfaldjfa
15, djsk, 1sljfal
Anyone has any ideas? I am a complete Perl newbie stuck on a prctice example I created for myself.
Help!
In reply to sorting comma separated value file by taopunk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |