Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I want a program that acts on a random file that i want to
write in the command line e.g.:

My program takes a file, and adds a .doc suffix to the name.

I want a command line input something like

perl AddSuffix.pl (FileToAddSuffixTo)

Is this possible? how?
I'm grateful for any ideas. Thank you.

Replies are listed 'Best First'.
Re: sending a file to a perl script
by dimmesdale (Friar) on Aug 09, 2002 at 14:34 UTC
    Well just call the program like:

    perl AddSuffix.pl FileToAddSuffixTo

    and the code can simply be:

    ... my $file = $ARGV[0]; ...

    @ARGV is the special perl variable that holds the argument vector.

    If all you're doing is changing the suffix (and not any reformatting, etc.), then might I suggest just renaming the file with the given .doc extension? If you're using windows you can just right click and go to rename (or the rename command in MS-DOS), and under UNIX, the 'mv' command would do it, I believe.