Using Scalar::Util::Numeric
#!/usr/bin/env perl use strict; use warnings; use Scalar::Util::Numeric qw(isfloat); use Data::Dumper; my @data; push @data, grep { isfloat($_) } split /\s+/ while <DATA>; print Dumper @data; __DATA__ 360.000 -0.000100033 -1.76122e-05 -9.89111e-05 -1.9003e-05 640.000 -4.54467e-05 9.13758e-05 -4.50576e-05 9.04804e-05 123 V.1234
dubs@server:~$ perl t1.pl $VAR1 = '360.000'; $VAR2 = '-0.000100033'; $VAR3 = '-1.76122e-05'; $VAR4 = '-9.89111e-05'; $VAR5 = '-1.9003e-05'; $VAR6 = '640.000'; $VAR7 = '-4.54467e-05'; $VAR8 = '9.13758e-05'; $VAR9 = '-4.50576e-05'; $VAR10 = '9.04804e-05';

In reply to Re: How to read string with numbers by trippledubs
in thread How to read string with numbers by luxs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.