extract all after last period

retrieve everything after the last period
test3.24.testing.233.txt
I'm in essence trying to retrieve the file extension
NewtonianBAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
mrjoltcolaConnect With a Mentor Commented:
The regex match operator =~ returns a matches in a list context.

my ($v1, $v2, $v3)   is a list
my $v1, $v2, $v3 is not a list, it is 3 scalars.

You can rewrite the whole thing if you want to:




if($s =~ /\.([^.]*)$/) {
   my $ext = $1;
}

Open in new window

0
 
mrjoltcolaCommented:

my $s = "test3.24.testing.233.txt";
my ($ext) = $s =~ /\.([^.]*)$/;
 
print "$ext\n";

Open in new window

0
 
NewtonianBAuthor Commented:
great! what do the parenthesis signify, it doesn't work without them
0
 
NewtonianBAuthor Commented:
the parenthesis around $ext
0
 
NewtonianBAuthor Commented:
thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.