#!/usr/bin/perl
use strict;
use warnings;
while (<DATA>){
my ($fruit,$end)=split(/\_ #Match an underscore
(?!.*\_) #Negative lookahead.
#Match only if not followed by characters
#followed by another underscore
/x); #x means allow multi-line regex with comments
print "My fruit = $fruit\n";
print "My end = $end\n";
}
__DATA__
apple_india_20110218091255.txt
apple_india_20110221112444.txt
apple_india_20110301112444.txt
http://www.regular-expressions.info/lookaround.html
d5e5
Practically a Posting Shark
810 posts since Sep 2009
Reputation Points: 159
Solved Threads: 159