CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [dani8586] extracting data between string: Edit Log



g4143
Novice

Jun 18, 2013, 6:02 AM


Views: 533
Re: [dani8586] extracting data between string

You really don't give us enough information about your datafile example but you could start here:


Code
#!/usr/bin/perl 

use warnings;
use strict;
use autodie qw/open close/;

print "Enter filename->";
chomp(my $ifilename = <STDIN>);

open(my $IFILE, "<", $ifilename);

while ( <$IFILE> )
{
chomp;
#found regexp here http://stackoverflow.com/questions/2293780/how-to-detect-a-floating-point-number-using-a-regular-expression
if (/DECAY 6100006 ((([1-9][0-9]*\.?[0-9]*)|(\.[0-9]+))([Ee][+-]?[0-9]+)?)/)
{
print $1 , "\n";
}
}

close($IFILE);

__END__



(This post was edited by g4143 on Jun 18, 2013, 6:08 AM)


Edit Log:
Post edited by g4143 (Novice) on Jun 18, 2013, 6:02 AM
Post edited by g4143 (Novice) on Jun 18, 2013, 6:03 AM
Post edited by g4143 (Novice) on Jun 18, 2013, 6:08 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives