jkepler
Novice
Jul 25, 2014, 2:29 PM
Views: 2253

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
