in reply to Perl pattern matching question

Read perlrequick, perlre,perlrecharclass

1.Read how to match a string.
2.Read How to group a matched string
Ex,
my $str="a apple"; $str =~(s/a(\s+[aeiou].+)/an\1/g); print $str

All is well. I learn by answering your questions...

Replies are listed 'Best First'.
Re^2: Perl pattern matching question
by Anonymous Monk on May 06, 2015 at 09:10 UTC

    sure vinoth, an alteration of single characters should be a character class :)

    and we're on our way with the help from Basic debugging checklist

    use Data::Dump qw/ dd /; my $string = 'and a one and a two and a panda is a animal'; $string =~ (s/a (a|e|i|o|u)/an /g); dd( $string ); __END__ "and an ne and a two and a pandan s an nimal"