Ask a Question related to PERL Miscellaneous, Design and Development.
-
Paul #1
Perl Arguements
I am having difficulty in getting the Perl Interpretor to recognize
arguements submitted with a perl script. For example,I have a simple
perl script like this called temp.pl
print "ARGV0 : $ARGV[0]\n";
print "ARGV1 : $ARGV[1]\n";
print "ARGV2 : $ARGV[2]\n";
If I run the script as 'temp.pl A B C',I get the following output:
ARGV0 :
ARGV1 :
ARGV2 :
If I run the script as 'perl temp.pl A B C', the arguements are then
recognized and I get the following output:
ARGV0 : A
ARGV1 : B
ARGV2 : C
I do not understand why the difference, the perl scripts is running in
both cases, but in the first case no arguements seem to be recognized.
Thanks for any help, Paul
Paul Guest
-
Off Topic: Active Perl Native Windows / cygwin perl
I have both activestate windows native perl installed and the default cygwin perl. How can I have the cygwin shell use the windows perl rather... -
Control a non-perl image viewer from perl script
Below is a (non-finished) script that trys to run a linux viewer called eog (eye of gnome) in a script that will eventually allow me to power thru... -
Re : Installing CPAN Perl Modules with Activestate Perl 5. v5.8
Hi, In the process of trying to get perl modules installed, I downloaded over 300 Activestate specific perl modules and they work fine (of the ones... -
Effeciency question - perl scripts v's perl exe's
Max Adams wrote: The only existing Perl compiler is part of perl. Anything else is just a packager that puts a perl, required modules, and the... -
How Can I Install PERL Modules w/o Upgrading PERL?
Shalom! I absolutely hate it when I install a required module for one piece of software or another, and suddenly it begins installing the... -
Tina Mueller #2
Re: Perl Arguements
Paul wrote:
> I am having difficulty in getting the Perl Interpretor to recognize
> arguements submitted with a perl script. For example,I have a simple
> perl script like this called temp.pl> print "ARGV0 : $ARGV[0]\n";
> print "ARGV1 : $ARGV[1]\n";
> print "ARGV2 : $ARGV[2]\n";which operating sytem, which perl version?> If I run the script as 'temp.pl A B C',I get the following output:
> ARGV0 :
> ARGV1 :
> ARGV2 :
> If I run the script as 'perl temp.pl A B C', the arguements are then
> recognized and I get the following output:
> ARGV0 : A
> ARGV1 : B
> ARGV2 : Ci don't understand the difference, either. for me it works, if> I do not understand why the difference, the perl scripts is running in
> both cases, but in the first case no arguements seem to be recognized.
i call the script with ./temp.pl (if the rights are set correctly):
$ cat temp.pl
#!/usr/bin/perl -w
use strict;
print "ARGV0 : $ARGV[0]\n";
print "ARGV1 : $ARGV[1]\n";
print "ARGV2 : $ARGV[2]\n";
$ ls -l temp.pl
-rwxr--r-- 1 tina users 115 Sep 8 23:27 temp.pl
$ temp.pl A B C
bash: temp.pl: command not found
$ ./temp.pl A B C
ARGV0 : A
ARGV1 : B
ARGV2 : C
hth, tina
--
[url]http://www.tinita.de/[/url] \ enter__| |__the___ _ _ ___
[url]http://Movies.tinita.de/[/url] \ / _` / _ \/ _ \ '_(_-< of
[url]http://www.perlquotes.de/[/url] \ \ _,_\ __/\ __/_| /__/ perception
- the above mail address expires end of december 2003 -
Tina Mueller Guest
-
Michael P. Broida #3
Re: Perl Arguements
Paul wrote:
Do you have the "shebang" line at the beginning?>
> I am having difficulty in getting the Perl Interpretor to recognize
> arguements submitted with a perl script. For example,I have a simple
> perl script like this called temp.pl
>
> print "ARGV0 : $ARGV[0]\n";
> print "ARGV1 : $ARGV[1]\n";
> print "ARGV2 : $ARGV[2]\n";
>
> If I run the script as 'temp.pl A B C',I get the following output:
> ARGV0 :
> ARGV1 :
> ARGV2 :
>
> If I run the script as 'perl temp.pl A B C', the arguements are then
> recognized and I get the following output:
> ARGV0 : A
> ARGV1 : B
> ARGV2 : C
>
> I do not understand why the difference, the perl scripts is running in
> both cases, but in the first case no arguements seem to be recognized.
#!/usr/bin/perl
I'm thinking that if you DON'T have that line and you
run it without specifying "perl", then it's running
as commands to a shell (not executing "perl") which
-might- output what you see.
(Or maybe not; it's just a thought. I'm on Win32, so
can't test this theory.)
Mike
Michael P. Broida Guest
-
John Bokma #4
Re: Perl Arguements
Tina Mueller wrote:
I suspected Windows but Win2K + cmd.exe:> Paul wrote:
>>>>I am having difficulty in getting the Perl Interpretor to recognize
>>arguements submitted with a perl script. For example,I have a simple
>>perl script like this called temp.pl
>>>>print "ARGV0 : $ARGV[0]\n";
>>print "ARGV1 : $ARGV[1]\n";
>>print "ARGV2 : $ARGV[2]\n";
>>>>If I run the script as 'temp.pl A B C',I get the following output:
>>ARGV0 :
>>ARGV1 :
>>ARGV2 :
>
> which operating sytem, which perl version?
D:\Snippets>perl arg.pl foo bar
foo
bar
D:\Snippets>arg.pl foo bar
foo
bar
D:\Snippets>type arg.pl
print join("\n", @ARGV), "\n";
D:\Snippets>perl -v
This is perl, v5.8.0 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
[snip]
--
Kind regards, feel free to mail: mail(at)johnbokma.com (or reply)
virtual home: [url]http://johnbokma.com/[/url] ICQ: 218175426
John web site hints: [url]http://johnbokma.com/websitedesign/[/url]
John Bokma Guest
-
Keith Keller #5
Re: Perl Arguements
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 2003-09-08, Michael P. Broida <michael.p.broida@boeing.com> wrote:My shell, bash, says "print: command not found" or some such.>
> Do you have the "shebang" line at the beginning?
> #!/usr/bin/perl
>
> I'm thinking that if you DON'T have that line and you
> run it without specifying "perl", then it's running
> as commands to a shell (not executing "perl") which
> -might- output what you see.
Why not? Doesn't Win32 have a command shell?> (Or maybe not; it's just a thought. I'm on Win32, so
> can't test this theory.)
- --keith
- --
[email]kkeller-mmmspam@wombat.san-francisco.ca.us[/email]
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see [url]http://www.gnupg.org[/url]
iEYEARECAAYFAj9dOQIACgkQhVcNCxZ5ID+m3ACfVtGQzjZ6IH J5splaDuHNyKG4
lg0AnA0gf0WXJOFYzQ5LAid07XQYfSZL
=qpKN
-----END PGP SIGNATURE-----
Keith Keller Guest
-
Sam Holden #6
Re: Perl Arguements
On Mon, 8 Sep 2003 19:20:51 -0700,
Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us> wrote:Korn shell has a print command, and it is a reasonably popular shell.>
> On 2003-09-08, Michael P. Broida <michael.p.broida@boeing.com> wrote:>>>
>> Do you have the "shebang" line at the beginning?
>> #!/usr/bin/perl
>>
>> I'm thinking that if you DON'T have that line and you
>> run it without specifying "perl", then it's running
>> as commands to a shell (not executing "perl") which
>> -might- output what you see.
> My shell, bash, says "print: command not found" or some such.
It does say "-might-" after all.
Not one that will execute files with arbitrary names. And clearly testing>>>> (Or maybe not; it's just a thought. I'm on Win32, so
>> can't test this theory.)
> Why not? Doesn't Win32 have a command shell?
such a thing would be pointless since the OP isn't using the a windows
command shell (since it won't produce the behaviour described).
--
Sam Holden
Sam Holden Guest
-
John Bokma #7
Re: Perl Arguements
Keith Keller wrote:
[snip]> On 2003-09-08, Michael P. Broida <michael.p.broida@boeing.com> wrote:
It has, but .pl is associated with perl so even without the she bang a>>> (Or maybe not; it's just a thought. I'm on Win32, so
>> can't test this theory.)
>
> Why not? Doesn't Win32 have a command shell?
..pl script is executed as perl.
without an extension:
(1)
D:\Snippets>arg hello world
'arg' is not recognized as an internal or external command,
operable program or batch file.
and with .bat (silly)
(2)
D:\Snippets>arg hello world
D:\Snippets>print join("\n", @ARGV), "\n";
Can't find file join(\n,
Can't find file @ARGV),
Can't find file \n;
With a proper she-bang and without an extension associated with perl.exe
I expect (1).
And for those who really want the same experience on Windows:
[url]http://www.cygwin.com/[/url]
^ please use the appropriate sig separator which is -- followed by one> - --keith
>
> - --
space. This means that most news readers automatically can remove the 12
(not counting the sig sep) lines which includes the PGP signature. Thanks.
--
Kind regards, feel free to mail: mail(at)johnbokma.com (or reply)
virtual home: [url]http://johnbokma.com/[/url] ICQ: 218175426
John web site hints: [url]http://johnbokma.com/websitedesign/[/url]
John Bokma Guest
-
Keith Keller #8
Re: Perl Arguements
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 2003-09-09, John Bokma <postmaster@castleamber.com> wrote:[snip]>
> It has, but .pl is associated with perl so even without the she bang a
> .pl script is executed as perl.
>
> without an extension:
>
> (1)
>
> D:\Snippets>arg hello world
> 'arg' is not recognized as an internal or external command,
> operable program or batch file.
Both you and Sam make good points--though I think Sam's
is slightly more valid, since neither your nor my error
messages look like the OPs. I don't have ksh available,
so I can't test whether that would produce the aberrant
behaviour the OP had.
Well, I have made a conscious decision to not use the switch> ^ please use the appropriate sig separator which is -- followed by one
> space. This means that most news readers automatically can remove the 12
> (not counting the sig sep) lines which includes the PGP signature. Thanks.
to gpg that preserves the "-- " delimiter; according to the
man page it causes some problems with spaces. I apologize
for this nonstandard behaviour. Some newsreaders (like slrn)
can strip this nonstandard sig delimiter.
- --
[email]kkeller-mmmspam@wombat.san-francisco.ca.us[/email]
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see [url]http://www.gnupg.org[/url]
iEYEARECAAYFAj9dVkQACgkQhVcNCxZ5ID8ZMACcD4S40O4Luo yMXfaWa94bkwAd
OSgAn0HCVu2VRv1WeUZ//lhhMAQyesWa
=zpGZ
-----END PGP SIGNATURE-----
Keith Keller Guest
-
Paul #9
Re: Perl Arguements
Tina Mueller <usenet@expires12.2003.tinita.de> wrote in message news:<bjis87$ivcqu$1@ID-24002.news.uni-berlin.de>...
Tina,> Paul wrote:>> > I am having difficulty in getting the Perl Interpretor to recognize
> > arguements submitted with a perl script. For example,I have a simple
> > perl script like this called temp.pl>> > print "ARGV0 : $ARGV[0]\n";
> > print "ARGV1 : $ARGV[1]\n";
> > print "ARGV2 : $ARGV[2]\n";>> > If I run the script as 'temp.pl A B C',I get the following output:
> > ARGV0 :
> > ARGV1 :
> > ARGV2 :
> which operating sytem, which perl version?
>>> > If I run the script as 'perl temp.pl A B C', the arguements are then
> > recognized and I get the following output:
> > ARGV0 : A
> > ARGV1 : B
> > ARGV2 : C>> > I do not understand why the difference, the perl scripts is running in
> > both cases, but in the first case no arguements seem to be recognized.
> i don't understand the difference, either. for me it works, if
> i call the script with ./temp.pl (if the rights are set correctly):
>
> $ cat temp.pl
> #!/usr/bin/perl -w
> use strict;
> print "ARGV0 : $ARGV[0]\n";
> print "ARGV1 : $ARGV[1]\n";
> print "ARGV2 : $ARGV[2]\n";
> $ ls -l temp.pl
> -rwxr--r-- 1 tina users 115 Sep 8 23:27 temp.pl
> $ temp.pl A B C
> bash: temp.pl: command not found
> $ ./temp.pl A B C
> ARGV0 : A
> ARGV1 : B
> ARGV2 : C
>
> hth, tina
I am running this on Win 2k, the Perl is Active State 5.2.2.0.
Thks,
Paul
Paul Guest
-
Michael P. Broida #10
Re: Perl Arguements
Keith Keller wrote:
Not one that could pay attention to the "shebang" line>
> On 2003-09-08, Michael P. Broida <michael.p.broida@boeing.com> wrote:>> >
> > Do you have the "shebang" line at the beginning?
> > #!/usr/bin/perl
> >
> > I'm thinking that if you DON'T have that line and you
> > run it without specifying "perl", then it's running
> > as commands to a shell (not executing "perl") which
> > -might- output what you see.
> My shell, bash, says "print: command not found" or some such.
>>> > (Or maybe not; it's just a thought. I'm on Win32, so
> > can't test this theory.)
> Why not? Doesn't Win32 have a command shell?
INSIDE the file.
Here on Win2K, there is a "print" command; I could have
tested that, BUT our network printer queue management
system doesn't work well from the DOS (CommandPrompt)
side.
Mike
Michael P. Broida Guest
-
Michael P. Broida #11
Re: Perl Arguements
John Bokma wrote:
I am interested in Cygwin, but we need to keep all of>
> And for those who really want the same experience on Windows:
> [url]http://www.cygwin.com/[/url]
our systems here in pretty nearly the same configuration
so we don't introduce problems from dependencies on a
particular tool.
We had problems on an older project under Solaris when
one person decided to use "tcsh" instead of our "standard"
csh. Some of his scripts didn't work correctly for the
rest of us or for our customers. :) So we enforce a
standard set of tools.
Mike
Michael P. Broida Guest
-
Keith Keller #12
Re: Perl Arguements
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message
On 2003-09-09, Paul <pecymanski@yahoo.com> wrote:Might adding a>
> I am running this on Win 2k, the Perl is Active State 5.2.2.0.
use warnings;
statement be helpful?
--keith
--
[email]kkeller-mmmspam@wombat.san-francisco.ca.us[/email]
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see [url]http://www.gnupg.org[/url]
iEYEARECAAYFAj9eMDgACgkQhVcNCxZ5ID+TiQCggO79bh0IHT oJzqK+hVeGEJqh
xTYAnR1aRHuErPZ3lYTdy2an9KNqxlPA
=1eLw
-----END PGP SIGNATURE-----
Keith Keller Guest
-
Bart Lateur #13
Re: Perl Arguements
Michael P. Broida wrote:
That's what the shebang line is for.> We had problems on an older project under Solaris when
> one person decided to use "tcsh" instead of our "standard"
> csh. Some of his scripts didn't work correctly for the
> rest of us or for our customers. :)
--
Bart.
Bart Lateur Guest
-
John Bokma #14
Re: Perl Arguements
Michael P. Broida wrote:
So why can you use tool Perl but not tool Cygwin?> John Bokma wrote:
>>>>And for those who really want the same experience on Windows:
>>[url]http://www.cygwin.com/[/url]
>
> I am interested in Cygwin, but we need to keep all of
> our systems here in pretty nearly the same configuration
> so we don't introduce problems from dependencies on a
> particular tool.
--
Kind regards, feel free to mail: mail(at)johnbokma.com (or reply)
virtual home: [url]http://johnbokma.com/[/url] ICQ: 218175426
John web site hints: [url]http://johnbokma.com/websitedesign/[/url]
John Bokma Guest
-
Michael P. Broida #15
Re: Perl Arguements
John Bokma wrote:
Perl has been approved. Cygwin has not.>
> Michael P. Broida wrote:
>>> > John Bokma wrote:
> >> >> >>And for those who really want the same experience on Windows:
> >>[url]http://www.cygwin.com/[/url]
> >
> > I am interested in Cygwin, but we need to keep all of
> > our systems here in pretty nearly the same configuration
> > so we don't introduce problems from dependencies on a
> > particular tool.
> So why can you use tool Perl but not tool Cygwin?
I don't do the approving, so I don't know their reasons.
Mike
Michael P. Broida Guest
-
Michael P. Broida #16
Re: Perl Arguements
Bart Lateur wrote:
Yeah, but... (It's been 7+ years, so my recall is a bit>
> Michael P. Broida wrote:
>>> > We had problems on an older project under Solaris when
> > one person decided to use "tcsh" instead of our "standard"
> > csh. Some of his scripts didn't work correctly for the
> > rest of us or for our customers. :)
> That's what the shebang line is for.
spotty...)
The problem surfaced when the user's DEFAULT shell was tcsh.
We tracked it down to some builtin function that behaved VERY
slightly differently in tcsh than in csh. I don't recall now
which function it was, but that TINY difference screwed up one
of:
- the setup commands we required in the .login/.cshrc files
- the actual startup scripts for the project app
I don't recall which.
The simple fix was to require csh for all testing/running of
that app. NONE of our customers were "techie" enough to find
or use tcsh themselves; it was only ONE of our developers that
liked using it. :) He was able to use tcsh for his general
work as long as he set his default shell to csh and opened a
fresh csh for testing/running.
Mike
Michael P. Broida Guest



Reply With Quote

