Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: reading var from the file

by mwah (Hermit)
on May 17, 2008 at 16:00 UTC ( [id://687104]=note: print w/replies, xml ) Need Help??


in reply to reading var from the file

if cdarke's method doesn't work (if the end of the record /\n is not always consistent), you may parse the whole file the "hard way":

use strict; use warnings; my $regexp = qr{ Temp: # hit => the temp: keyword (.+?) # capture what follows (?: # until (?=[\s-]+Temp) # another temp: shows up | # or \s*\z # the end of the data is here ) }msx; open my $fh, '<', 'tmpvar.dat' or die "wtf, $!"; { local $/; # slurp the entire file in +to my $content = <$fh>; # a buffer while($content =~ /$regexp/g) { # and extract each temp: r +ecord (my $var_temp = $1) =~ tr/\r\n//d; # delete new line (if any) print "var_temp=$var_temp\n" # and print } } close $fh;

Regards

mwa

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-16 05:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found