shivu126:
I'd suggest reading perldoc perlintro and perldoc perlfunc, especially the sections on string handling and regular expressions--split looks like a reasonable choice for this task.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
| [reply] [Watch: Dir/Any] [d/l] [select] |
| [reply] [Watch: Dir/Any] |
Welcome to Perl monks. You can make your input and output easier to read by using code tags, this is described in How do I post a question effectively?. What have you tried so far, and how did it fail?
| [reply] [Watch: Dir/Any] |
Hi shivu126,
Perl hash to the rescue, something like this:
use warnings;
use strict;
my %data_arrang;
while (<DATA>) {
my @data = split /, / => $_, 2;
push @{ $data_arrang{ shift(@data) } }, @data;
}
print "Enter your date: ";
chomp( my $date = <STDIN> );
if ( exists $data_arrang{$date} ) {
print "goods,quality : ", @{ $data_arrang{$date} };
}
else { print "Date entered didn't exist\n" }
__DATA__
12-11-2006, books, 100
10-11-2006, bag, 10
10-12-2006, pen, 15
UPDATE:
You may want know more about Hash in Perl, split, perldsc
If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me
| [reply] [Watch: Dir/Any] [d/l] |