[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

extract all after last period

Posted on 2009-03-31
5
Medium Priority
?
245 Views
Last Modified: 2012-05-06
retrieve everything after the last period
test3.24.testing.233.txt
I'm in essence trying to retrieve the file extension
0
Comment
Question by:NewtonianB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24035830

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

Open in new window

0
 

Author Comment

by:NewtonianB
ID: 24035883
great! what do the parenthesis signify, it doesn't work without them
0
 

Author Comment

by:NewtonianB
ID: 24035885
the parenthesis around $ext
0
 
LVL 40

Accepted Solution

by:
mrjoltcola earned 1000 total points
ID: 24035899
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
 

Author Closing Comment

by:NewtonianB
ID: 31565145
thanks!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question