http://qs321.pair.com?node_id=11101386


in reply to Re: Sort alphabetically from file
in thread Sort alphabetically from file

Original contents:

thanks I tried the below and no errors but nothing happens, sure it's me though.
if ($ARGV[0] eq "-a") { open (INFILE, "$ARGV[1]") or die "$ARGV[1] cannot be openned : $!"; my %hash; while ($source_file =~ /(\d)\s+(\d)\s+(\d)\s+(\w+)/) { push @{$hash{$4}}, $1, $2, $3; } print "@{$hash{$_}}[0..2] $_\n" for sort keys %hash; }
BTW I should've mentioned I must call my program as follows: myprogram.pl($ARGV[0]) option($ARGV[1]) mytextfile.txt($ARGV[-1]) I'm using this for assigning the text file to a variable $source_file = "$ARGV[-1] hence using $source_file to call the text file but now working. am I missing something?
Thanks - will try this out. :)

2019-06-17 Athanasius restored original contents and added code tags around the program call