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:
Why isn't this working?

 



data345
Novice

Dec 4, 2009, 11:58 AM

Post #1 of 2 (727 views)
Why isn't this working? Can't Post

This is driving me nuts. It worked at one time.

It's not making it inside the "if ( $ary[1] eq $srchstr ) "

Here's some sample data:

lookup:
CIU.RCMs.1TH-VIB1B-RST.OUT
CIU.RCMs.1TI-SY100.OUT
CIU.RMSCs.1AB-_ASH.OUT
CIU.RMSCs.1AB-CST_HAUL.OUT
CIU.RMSCs.1BA-FC110A-B.OUT
CIU.RMSCs.1BA-FC110B-B.OUT
CIU.RMSCs.1FC-CST_TON.OUT

And the sample opc_tags1 is uploaded as an attachment (it's text, of course).



Code
#!/usr/bin/perl 

open (INFILE, "<opc_tags1");

#open (OUTFILE, ">out1");

while (<INFILE>) {
chomp;
@ary = split /\t/;
if ( ! $ary[26]) {
open (LOOKUP, "<lookup_table");
while (<LOOKUP>) {
$srchstr = $fullstr = $_;
$srchstr =~ s/.+\.(.+)\..+/$1/;
print "Before if: $ary[1]\t$srchstr\n";
if ( $ary[1] eq $srchstr ) {
print "in loop $ary[1]\t$srchstr\n";
$ary[26] = $fullstr;
goto LINE;
}
}
LINE: close LOOKUP;
print "$ary[1]\t$ary[26]\n";
}
}

Attachments: opc_tags1 (0.97 KB)


data345
Novice

Dec 4, 2009, 12:49 PM

Post #2 of 2 (722 views)
Re: [data345] Why isn't this working? [In reply to] Can't Post

I found the error. I needed to add another

Code
chomp;

under

Code
while (<LOOKUP>)


=== Al

 
 


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

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