My agenda actually is two pronged. I have read Beginning Perl and a bit of
Intermediate Perl, though was able to solve individual problems, but I was not
sure,if I can code myself out of a wet paperbag.
So I thought, lets chuck theory. Its better to get hands dirty with some real
life code. Actually, the stuff which I am working on is my own problem. Its
related to what I do, and I was adviced to do the same thing in Excel, as its
much easier. But yes, I got to learn Perl and got to solve my issue ;)
So that might explain the reason behind why I dont have much idea on what I
happen to be thinking.I am not really sure how to proceed.
To put my problem more succinctly
a. I have a CSV file
b. I am reading and parsing it through Tie::Handle::CSV module
c. There is a date column in that csv file
d I want to process a hashlist such that each date is mapped to a sequential
number. {where I am stuck at, currently}
e. I want to use this hash as a way to further process another csv such that I
can segregate the contents of the second csv populating/processing two
two-dimensional array.
f.. etc etc
Soham
Would be interested in getting a bit of help.
I am attaching a snippet.
use warnings;
use Tie::Handle::CSV;
#Read Market Data
my $file= shift @ARGV;
my $trade_fh=Tie::Handle::CSV->new($file,header=>1);
#Find the number of market days
#I want to read the entire column called date, present in the file, and map it
to a sequence of numbers
Soham
----- Original Message ----
From: Shawn H Corey <[email protected]>
To: Uri Guttman <[email protected]>
Cc: Soham Das <[email protected]>; [email protected]
Sent: Monday, 28 September, 2009 10:45:33 PM
Subject: Re: Arrays, Dates, Indexing and Initialisation
Uri Guttman wrote:
> only for ++/-- and +=/-= will that work with no warnings. if he uses an
> undef value in another arithmetic expression it will warn.
Also, undef values work in if/unless and while/until conditions.
Usually when you see indexes used with arrays, it is because the programmer
does know of all the tools available for manipulating lists. 99.97% of the
time, indexes are not needed. But if you must insist on initializing the
array, it's better to use the ||= assignment to indicated that zero is the
default value, even if the array hasn't been used before.
$a[$_] ||= 0 for 0 .. 125;
One of the common patterns in Perl is using || for defaults.
$var ||= $default;
or
$var = expr || $default;
You should use common patterns where possible so that your code will be easier
to understand.
-- Just my 0.00000002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
I like Perl; it's the only language where you can bless your
thingy.
-- To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn..perl.org/
Now, send attachments up to 25MB with Yahoo! India Mail. Learn how.
http://in.overview.mail.yahoo.com/photos
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/