Thanks Shawn, yes hashes I guess will be the way to go forward.

Soham



----- Original Message ----
From: Shawn H Corey <shawnhco...@gmail.com>
To: Soham Das <soham...@yahoo.co.in>
Cc: beginners@perl.org
Sent: Monday, 28 September, 2009 9:50:18 PM
Subject: Re: Arrays, Dates, Indexing and Initialisation

Soham Das wrote:
> a.. How do I initialise an array of a definite size with zero. Say the C 
> equivalent of such a statement will be:
>                          int a[125];
>                    for(i=0;i<125;i++)                    a[i]=0;

Not needed.  Perl assume zero if a non-existing element is used in an 
arithmetic expression.

perl -e '$a[$_] += int(rand(10)) for 0..10;print"@a\n"'

> 
> b. Is it possible, to have dates as index? I am trying to parse and process
> data corresponding to a list of "trades" I have made(financial trades) and
> want to see, how my portfolio varies with time. So is it possible to do in
> such a way?
> 
> 

Perl has no date type.  All dates are either strings or numbers.  You can use 
any string as the keys to a hash.  Numbers would be convert to strings if they 
are used as keys.


-- 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..



      Try the new Yahoo! India Homepage. Click here. http://in..yahoo.com/trynew


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to