in reply to optimise perl code

You could use File::Basename to split the path in its components.
Alternatively, you could use a RE to change the filename:
(my $newValue = $tempValue) =~ s|([^/]*)$|".$temp1.$temp2.$1"|e
(updated: different seperator for s//)

Paul

Replies are listed 'Best First'.
Re^2: optimise perl code
by dirac (Beadle) on Jul 07, 2005 at 13:30 UTC
    I remove some thing ...
    (my $newValue = $tempValue) =~ s|([^/]*)$|$temp1.$temp2.$1|;
    
    and now works well
    #!/usr/bin/perl -w
    use strict;
    
    my $tempValue = "/home/madam/scripts/madam.tcl";
    my $temp1 = "temp1";
    my $temp2 = "temp2";
    (my $newValue = $tempValue) =~ s|([^/]*)$|$temp1.$temp2.$1|;
    print $newValue;