On Tue, Mar 2, 2010 at 5:45 PM, Durairaj Muthusamy <tech.du...@gmail.com>wrote:

> Hi,
>
>  I am a newbie and need your help. The following script doesn't
> display the first print statement like the second one.
>  Why?
>
> @str = qw(NEW food foosball newstr foobasefoot);
>
> $\ = "\n";
>
> foreach(@str)
> {
>        print "First: $&" if ?(foo.*)?;
>        print "Second: $&" if /(foo.*)/;
> }
>
> Output:
>
> First: food
> Second: food
> Second: foosball
> Second: foobasefoot
>
>
> Regards,
> Durai
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
> Hi,

I didn't understand your question! Are you asking that why first print only
shows one match "food" unlike second one which shows all matches
matched by"foo.*"

If that is the question then the m?? unlike m// only matches once.
Those ?? are special delimiters specially created for this purpose i.e
single match only.

Reply via email to