Perl wildcard un-expansion

A

alexxx.magni

I am usually very happy to access any args I gave to my prog as:
myprog.pl *.pgm
using @ARGV

In this particular occasion instead, I find that I would like to
access the literal argument written by the user, i.e.
myprog.pl img0*.pgm
to be able to access "img0*.pgm", not its expansion

is it possible?

thanks!

Alessandro Magni
 
J

Jürgen Exner

I am usually very happy to access any args I gave to my prog as:
using @ARGV

In this particular occasion instead, I find that I would like to
access the literal argument written by the user, i.e.
to be able to access "img0*.pgm", not its expansion

is it possible?

That expansion is performed by the shell and there is nothing perl can do
about it because when it recieves the arguments the shell expansion has
happened already.

If you want to include a literal * in a command line argument then you need
to use the proper shell escape character or whatever means your shell
provides to prevent the shell from expanding that *.

jue
 
P

Peter Makholm

In this particular occasion instead, I find that I would like to
access the literal argument written by the user, i.e.
to be able to access "img0*.pgm", not its expansion

Not as such. The expansion happens in the shell and perl has no way of
knowing if the arguments is a result of an expansion or not.

But you can call you program like:

$ myprog.pl 'img0*.pgm'

and then perl will se the argument untouched. (This isn't really a perl
question but a question about the environment you're using perl in. So
teh correct answer may differ acording to platform.)

//Makholm
 
S

sheinrich

to be able to access "img0*.pgm", not its expansion

On a side note to the former answers, some shells put the commandline
into the environment.
Take a look at the content of %ENV. Maybe you're lucky.

Cheers,
Steffen
 
A

alexxx.magni

On a side note to the former answers, some shells put the commandline
into the environment.
Take a look at the content of %ENV. Maybe you're lucky.

Cheers,
Steffen


not on BASH, it seems...

Alessandro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top