Hi folks.

I need to select a single file name from a list of filenames and assign it
to a variable.


I currently do this in a few shell scripts using: $last_file=`ls -1r
somedata_file.dat.*.orig | head -1`

The "*" represents a timestamp in the filename. This allows me to select the
most recent file, in this case.


as an example, this would return a value such as :
somedata_file.dat.20011203130101.orig which would be stored in $last_file




When I do this in Perl thusly:

$oldfile = `system "ls -1r $oldfile.\*.orig | head -1"`;

Where $oldfile contains the first part of a filename passed in via
Getopt::Long .

$oldfile is empty. I think it contains the return value from the call to the
system, so I am not properly assigning the output value, (the single
filename), to it.

I verify that $oldfile does contain a value with a print statement
immediately prior to the statement with 'system' in it.


Am I somehow stepping on $oldfile by using it to re-assign a new value to
itself?

Am I screwing up on the various tic's?

How can I do this? 

Should I use File::Find? If so, how? I have not been able to find how to do
this with File::Find in any of the O'Reilly books or on the web.




Thanks,
Tom Wright



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to