Re: Need help with a question.
- From: Jim Gibson <jimsgibson@xxxxxxxxx>
- Date: Mon, 30 Jun 2008 08:27:11 -0700
In article <48666e7f$0$14348$e4fe514c@xxxxxxxxxxxxxx>, Erwin van Koppen
<invalid@xxxxxxxxxxxxxxx> wrote:
"Trev" wrote:
Thanks, I've made the changes and so far so good.
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;
}
}
}
You do understand that the above code does not actually change anything in
the file, right? The substitutions in $cpqlog are just discarded at the end
of the loop.
Not quite. In Perl, the loop variable $cpqlog is an "alias" to the
array elements, so the changes to $cpqlog are applied to the members of
the array. Of course, whether or not the file is modified depends upon
what is done after the loop. (Just trying to clear up any
misunderstanding about what "discarded at the end of the loop" means.)
--
Jim Gibson
.
- References:
- Need help with a question.
- From: Trev
- Re: Need help with a question.
- From: Erwin van Koppen
- Re: Need help with a question.
- From: Trev
- Re: Need help with a question.
- From: Erwin van Koppen
- Need help with a question.
- Prev by Date: Re: Thread or threads.
- Next by Date: Re: I hate CGI.pm
- Previous by thread: Re: Need help with a question.
- Next by thread: Re: Need help with a question.
- Index(es):
Relevant Pages
|