in reply to Reading and manipulating text files
use strict; use warnings; print "Search for a name: "; my $userinput = <>; chomp $userinput; my %data; my $readfile = 'TextFile.txt'; open(my $fh, '<', $readfile) or die "Could not open file '$readfile'$! +"; while (<$fh>) { chomp; my ($name, $date, $amount) = split /,/; $data{$date} = $_ if $name eq $userinput; } print "$data{$_}\n" for sort keys %data; __END__ mike,2015-07-26,$-93.00 mike,2015-10-16,$69.00 mike,2015-11-08,$28.00 mike,2016-04-02,$95.00
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reading and manipulating text files
by TheRiz (Novice) on Apr 08, 2015 at 19:31 UTC |