SPUG:-s option doesn't always work!
Tim Maher
tim at consultix-inc.com
Tue Jun 3 22:53:08 CDT 2003
SPUGsters,
I don't use the -s invocation option very often, but for certain
categories of students, I think it works well. So imagine my surprise
when I learned today that -s on the shebang line seems to be ignored
when the script is invoked as an argument to the perl command!
None of the other invocation options I can think of works like that,
except -T, and there are good reasons for that -- but not for this,
AFAIK.
I don't find any warning about this goofy behavior in the documentation.
Can anybody shed some light on this?
-Tim
NOTE on session transcript: The edited output appears in the
original file, where you can't see it.
$ ./change_file5 -old=e -new=E motd
Arguments are: motd
(That's what I want)
$ perl ./change_file5 -old=E -new=e motd
Arguments are: -old=E -new=e motd
(That's undesirable!)
Usage: ./change_file5 -old='old' -new='new' f1 [f2...]
BEGIN failed--compilation aborted at ./change_file5 line 13.
$ perl -s ./change_file5 -old=e -new=E motd
Arguments are: motd
(That's what I want, but not how I want to get it)
$ perl -v
This is perl, v5.8.0 built for i586-linux-thread-multi
$ cat change_file5
#! /usr/bin/perl -wlps -i.bak
BEGIN {
$USE="Usage: $0 -old='old' -new='new' f1 [f2...]";
warn "Arguments are: @ARGV\n"; # to debug -s handling problem
# Really need more stringent test, but students not ready yet
defined $old and defined $new or die "$USE\n"; # must have strings
@ARGV > 0 or die "$USE\n"; # mut have at least one filename
}
s/$old/$new/g;
----- End forwarded message -----
--
-Tim
*------------------------------------------------------------*
| Tim Maher (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX |
| CEO, JAWCAR ("Just Another White Camel Award Recipient") |
| tim(AT)Consultix-Inc.Com TeachMeUnix.Com TeachMePerl.Com |
*+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-*
| Watch for my Book: "Minimal Perl for Shell Programmers" |
*------------------------------------------------------------*
More information about the spug-list
mailing list