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

What is the easiest way to insert an extension to a file? I have a varialbe $extension with the current that I want to add to a filename. Basically, change file to file.123456 Thanks in advance.

Replies are listed 'Best First'.
Re: Insert extension to filename
by broquaint (Abbot) on Jul 22, 2002 at 18:59 UTC
    How about
    use File::Copy qw(move); my $extension = "12345"; move("file", "file.$extension");
    There's also the handy rename() function, but is known to have various platform issues. See the File::Copy docs for more info.
    HTH

    _________
    broquaint

Re: Insert extension to filename
by blaze (Friar) on Jul 22, 2002 at 18:58 UTC
    my $file = 'file';
    my $extension = '.123456';
    my $file .= $extension;

    Update: sorry about that, I misunderstood the question...broquaint's suggestion is the way to go..use File::Copy