Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: getting numeric data from a file into an array

by runrig (Abbot)
on Nov 01, 2011 at 17:40 UTC ( #935169=note: print w/ replies, xml ) Need Help??


in reply to getting numeric data from a file into an array

...I'm not sure how to do it

What have you tried so far? Just so you know, we're usually happy to help, but this is not a code writing service or a place to get homework answers.

And welcome to PerlMonks!


Comment on Re: getting numeric data from a file into an array
Re^2: getting numeric data from a file into an array
by jmccaslin (Initiate) on Nov 02, 2011 at 04:09 UTC

    I should have been more specific. I was suspicious that matching reg exp would do the trick. Here is what I have so far:

    # read in times open MYFILE, "<$dir/structs/times"; my @temptimes = <MYFILE>; close(MYFILE); print "$#temptimes\n"; my @strtimes; for (my $i = 2;$i <= $#temptimes;$i++){ if ($temptimes[$i] =~ m/(\d+.\d+)/){ print "$1\n"; } }
    I'm having trouble reading the other two values and storing them in an array. I figured I could just multiply by 10^3 to account for the "E+03", as I didn't know how to deal with the "+" sign. Sorry if it seemed like I'm looking for homework solutions - in fact this is not homework. I can do this in other languages, I just want to learn Perl.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2014-09-21 01:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (165 votes), past polls