CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Routine to catch exp...

 



jkepler
New User

Jul 25, 2014, 2:29 PM

Post #1 of 2 (476 views)
Routine to catch exp... Can't Post

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:


Code
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


FishMonger
Veteran / Moderator

Jul 25, 2014, 5:34 PM

Post #2 of 2 (468 views)
Re: [jkepler] Routine to catch exp... [In reply to] Can't Post

Cross posted on perlmonks.

http://www.perlmonks.org/?node_id=1095102

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives