kitty has asked for the wisdom of the Perl Monks concerning the following question:
I need to extract the t.min and t.max values. The code i have written does not print the value but prints t.min and t.max a 1000 times.MML v2.0; import defaultunit; unit conversion on; math top { t.min = 0; t.max = 3600; t.delta = 5; .........
Please help. Thankyou for all the help. I have to parse the whole file and print to a text file, i have gotten stuck in the first step itself, am kind of worried now. Thanks again.#!usr/bin/perl use strict; use warnings; use Getopt::Long; my $file; GetOptions("f|file=s" => \${file}) or die "invalid option\n"; if ($file) { my $fname = $file; open (INFO,"<",$fname) or die " Could not open\n" ; open (OUTFO,">>","text.txt") or die "Could not open\n"; my (@line, $myline); @line=<INFO>; foreach $myline(@line) { if($myline=~ /(t\.min=)(.*)(;)/) {print OUTFO "tmin = $2\n";}; if($myline=~ /(t\.max=)(.*)(;)/) {print OUTFO "tmax = $2\n";}; } close OUTFO; close INFO; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help : Regular expression
by helphand (Pilgrim) on Feb 27, 2006 at 05:23 UTC | |
|
Re: Help : Regular expression
by Praveen (Friar) on Feb 27, 2006 at 05:21 UTC |