Matching in perl -


i new perl. trying text in between 2 dots of line, program returns entire line.

for example: have text looks sampledata 1,2 perl .version 1_1.

i used following match statement

$x =~ m/(\.)(.*)(\.)/; 

my output $x should version 1_1 getting entire line match.

i appreciate help. thanks.

in code, value of $x not change after match.

when $x matched m/(.)(.*)(.)/, 3 capture groups contain '.', 'version 1_1' , '.' respectively (in order given). $2 give 'version 1_1'.

considering might want part 'version 1_1', need not capture 2 dots. code give same result:

$x =~ m/\.(.*)\./; print $1;  

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -