Hello,
I'm trying to make a routine to catch some expressions from a file. I'm assuming, wrongly, that can only be one in each line...
I'm capturing and appending the expressions like this:
sub Grab($filename){
open (file1, "<$filename") or goto cont2;
while (<file1>){
my($line) = $_;
my ($exp) =
$line =~ m/
kepler_ # Required
(.+?) # Capture Desired Output
(:?\s\(|\(|\s+) # One required - no capture
/xi;
$expr = "kepler_".$1;
if(@Functions =~ /$expr/gi){goto cont1;}
if($1 =~ ""){goto cont1;}
$n += 1;
print $expr."\n";
$value1 = "Exp_".$n;
$key1 = $expr;
$functions{ $key1 } = $value1; # hash, using variables
cont1:
}
cont2:
close file1;
}
#END GRAB
The problem is that I'm getting duplicated items in the hash.
And, that can be more expressions in one line - but probably not...
Can anyone help me out here?
Kind regards,
Kepler
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.