Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: extracting data from file

by 2teez (Priest)
on Nov 15, 2012 at 12:24 UTC ( #1004002=note: print w/ replies, xml ) Need Help??


in reply to extracting data from file

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


Comment on Re: extracting data from file
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1004002]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2014-09-20 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (152 votes), past polls