#!/usr/bin/perl -w use strict; #this gets chars until first digit... my $search = "some_string200912.txt"; my $alpha1 = ($search =~ m/(.*?)\d+.txt/)[0]; #this gets chars until first digit... my $to_modify = "some_value200912.txt"; my $alpha2 = ($to_modify =~ m/(.*?)\d+.txt/)[0]; #this modifies (assigns new value to $to_modify) $to_modify = "$alpha2"."_"."$alpha1"; print "$to_modify\n"; __END__ prints: some_value_some_string #### #!/usr/bin/perl -w use strict; #this gets chars until first digit... my $search = "some_string200912.txt"; (my $alpha1) = $search =~ m/(.*?)\d+.txt/; #this gets chars until first digit... my $to_modify = "some_value200912.txt"; (my $alpha2) = $to_modify =~ m/(.*?)\d+.txt/; #this modifies (assigns new value to $to_modify) $to_modify = "$alpha2"."_"."$alpha1"; print "$to_modify\n"; __END__ prints: some_value_some_string