Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: getting numeric data from a file into an array

by NetWallah (Abbot)
on Nov 02, 2011 at 03:05 UTC ( #935276=note: print w/replies, xml ) Need Help??

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

Here is a more "perlish" Warning-free way: (Deliberately avoiding regular expressions)
use strict; use warnings; my @values; my $special_string_found = 0; my $special_string = 'time values:'; while (defined( my $line= <DATA>)) { if (not $special_string_found ){ next unless $special_string eq substr($line,0,length($special_s +tring)); $special_string_found = 1; $line = substr($line,length($special_string)+1); } push @values, split(' ' ,$line); } print qq|$_\n| for @values; __DATA__ TIME number of steps: 13 time values: 2.83506E+03 2.83697E+03 2.83911E+03 2.84117E+03 2.84331E+03 2.84544E+03 2.84750E+03 2.84958E+03 2.85172E+03 2.85383E+03 2.85588E+03 2.85804E+03 2.86012E+03

            "XML is like violence: if it doesn't solve your problem, use more."

Replies are listed 'Best First'.
Re^2: getting numeric data from a file into an array
by jmccaslin (Initiate) on Nov 02, 2011 at 04:10 UTC

    I appreciate seeing the warning-free solution, and I must admit it's a little comforting to see it done without reg exp.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://935276]
[Corion]: choroba: I'm still using spod5 as my pod-to-ooxml- converter didn't really get off the ground so far
[choroba]: Slidy is basically HTML, so I'm not sure I really fly high :)
choroba should make his presentation scaffolding public
[Corion]: choroba: spod5 converts pod to S5 HTML, so it's also still basic. I find the lack of animations (in the sense of "highlight this", "highlight that" in code) somewhat tedious as I do it with rendered PNGs
[Corion]: I haven't found a good way to include/use the source SVGs I use for creating the PNGs directly as animations
[ambrus]: Presentations come in many different shapes, and so slides do as well.
[Corion]: Doing that in Powerpoint or Ooxml would be nice(r) but I'm much quicker doing the outline of a presentation and the code as Pod

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (13)
As of 2017-09-26 10:01 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (293 votes). Check out past polls.