perl subroutine (SEC: UNCLASSIFIED)
Sam Couter
sam at couter.dropbear.id.au
Wed Sep 25 18:18:56 EST 2002
Lisman, FLGOFF Jarrad <Jarrad.Lisman at defence.gov.au> wrote:
> 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);
> }
[ ... ]
> 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
substr() returns the substring. You need something more like:
$line = substr($line, ...)
Otherwise you're just throwing the substring away and are left with what
you had before.
You probably also want $line = &subroutine($line); for the same reason.
--
Sam "Eddie" Couter | mailto:sam at couter.dropbear.id.au
Debian Developer | mailto:eddie at debian.org
| jabber:sam at jabber.topic.com.au
OpenPGP fingerprint: A46B 9BB5 3148 7BEA 1F05 5BD5 8530 03AE DE89 C75C
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.samba.org/archive/linux/attachments/20020925/1d1c0011/attachment.bin
More information about the linux
mailing list