[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] tweak



On Tue, Apr 25, 2006 at 02:54:09PM -0500, Jay Hannah (jhannah@omnihotels.com) wrote:
> My after:
> 
>   my $pageid;
>   foreach ($q->param) {
>     s/^view__Record__// || next;
>     $pageid = $_;
>     last;
>   }

You can use that s/// in a boolean context

    foreach ($q->param) {
        if (s/^view__Record__//) {
            $pageid = $_;
            last;
        }
    }

If you don't want to do a replacement for some reason:

    foreach ($q->param) {
        if (/^view__Record__(.+)/) {
            $pageid = $1;
            last;
        }
    }

This last one I think is the clearest, because what you're saying is
"match view__Record__ followed by something else, and I want to keep the
something else".

xoa

-- 
Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance