in reply to accessing/printing specific rows in a flat file DB

print qq~ $itemName, $nmPrice ~ if $productId =~ "^B00";
Also, perldoc perlre for using regular expressions.

Replies are listed 'Best First'.
Re: Re: accessing/printing specific rows in a flat file DB
by Limbic~Region (Chancellor) on Aug 01, 2003 at 16:25 UTC
    yosefm,
    One minor nit:
    print qq~ $itemName, $nmPrice ~ if $productId =~ m"^B00";

    You have to make the m explicit if you are going to change the default delimiters in a match.

    Cheers - L~R

    Update: Apparently I am wrong and my apologies. It seems that the only time you have to make the m explicit if you are also dropping the binding operator by working on the default $_ as in if /^foo/ can't be done as if |^foo| it needs to be done as if m|^foo|

      That was what I thought when reading, too, but it seems to work.:

      > perl -e '$a="abcd"; print "yes\n" if $a =~ "^abc";' yes > perl -e '$a="abcd"; print "yes\n" if $a =~ "^yyy";' >

      Strange, anyone knows more about this?

      alex pleiner <alex@zeitform.de>
      zeitform Internet Dienste