perl subroutine (SEC: UNCLASSIFIED)
Lisman, FLGOFF Jarrad
Jarrad.Lisman at defence.gov.au
Wed Sep 25 16:56:44 EST 2002
Hi, I am trying to write a perl script that goes through a log file and does
some changes on various strings. I noticed (dah) that a few of the changes I
am making are repetitious so I decided to make a subroutine so that I can
call it several times over. Unfortunately i can't seem to pass my string
into it as I would like to. Here is an exert from the script as it stands so
far;
open(MYFILE, "filename");
while(<MYFILE>)
{
my($line)=$_;
chomp($line);
substr ($line ...........) #these substr lines work fine when
not in the subroutine
substr
substr
&subroutine($line);
}
sub subroutine
{
substr
substr
return($_)
}
I have put some print lines in to see if I can tell what is happening and it
seems that the script is passing the original main $_ value (ie the one
before all of the substr's) to my subroutine, so effectively the first 3
substr's are being ignored
Can anyone help?
Jarrad
More information about the linux
mailing list