in reply to Building Paths without Regex

This problem just cries out for regex in Perl.
This is not a sub-string problem.
sub string is the wrong tool for the job.
#!/usr/bin/perl -w use strict; my ($var1) = 'stuff_to_cut_out_with_substr_FOO'; my ($var2) = 'stuff_to_cut_out_with_substr_BAR'; my ($var3) = 'stuff_to_cut_out_with_substr_LOST'; my @paths; foreach my $line ($var1, $var2, $var3) { push @paths, $line =~ /_([A-Za-z]+)$/; #stuff after last _ } print join("/",@paths),"\n"; __END__ prints "FOO/BAR/LOST"