Need help with a question.
- From: Trev <trevor.dodds@xxxxxxxxx>
- Date: Sat, 28 Jun 2008 09:33:18 -0700 (PDT)
I'm having a problem with my Perl script, what I would like the script
to achieve is to read a file, search it for certain words, put the
results into an Array so I can then call each result with $var[1] etc
and print output to a file. I tried doing it without Sub routines but
wasn't able to split the results. When I rapped the code into a Sub I
get these errors:
syntax error at test.pl line 7, near "@cpqlog_data"
syntax error at test.pl line 24, near "}"
How come these errors only appear when I use Sub { } ?
test.pl
use English;
use Warnings;
Sub LoadFile
{
open (DAT, "<output.txt") || die("Could not open file!");
@cpqlog_data=<DAT>;
foreach $cpqlog (@cpqlog_data)
{
{
chomp($cpqlog);
if ($cpqlog =~ /MAC/)
{
$cpqlog =~ s/ <FIELD NAME="Subject" VALUE="//i;
$cpqlog =~ s/ <FIELD NAME="MAC" VALUE="//i;
$cpqlog =~ s/"\/>//i;
}
}
}
close DAT;
}
Sub CreateLOG
{
open (BOO, "<blah2.txt");
@lines=<TMP>;
print $lines[1];
close BOO;
}
LoadFile;
CreateLOG;
.
- Follow-Ups:
- [OT] Read the Posting Guidelines (was: Need help with a question.)
- From: Dr.Ruud
- Re: Need help with a question.
- From: Ben Morrow
- Re: Need help with a question.
- From: Dan Mercer
- Re: Need help with a question.
- From: Gunnar Hjalmarsson
- Re: Need help with a question.
- From: Erwin van Koppen
- [OT] Read the Posting Guidelines (was: Need help with a question.)
- Prev by Date: Re: Simplest way (or module) to tweak query in CGI server-side validation
- Next by Date: Re: Need help with a question.
- Previous by thread: FAQ 9.7 How do I make an HTML pop-up menu with Perl?
- Next by thread: Re: Need help with a question.
- Index(es):
Relevant Pages
|