Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: reading var from the file

by mwah (Hermit)
on May 17, 2008 at 16:00 UTC ( #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
Node Status?
node history
Node Type: note [id://687104]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2021-04-11 19:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?