http://www.perlmonks.org?node_id=614118


in reply to String matching problem

I hope you mean the very last digit of a line, not the last digit of '-' pattern.
#! /usr/bin/perl use warnings ; use strict; open(FH,"infile") or die "File cant be opened\n"; while (<FH>) { if (m/\d-(\d)"$/) { print "$1\n"; } }
Infile
"1-2, 3-4, 5-6" or "1%5, 3-4" or "1-2" A6 12