in reply to Grabbing file prefixes with Reg Exp

Try using a substitution (s///) instead so that you directly modify what grep returns.

my @auditofiles = grep { s/\A([^.]+)\.ram\z/$1/i } readdir DH;

    --k.


Replies are listed 'Best First'.
Re: Re: Grabbing file prefixes with Reg Exp
by MeowChow (Vicar) on May 13, 2001 at 21:13 UTC
    Any reason for using the \A ... \z assertions instead of the commonplace ^ ... $ metachars? I believe that's the first I've seen those two used. More generally, is there a difference, outside of multiline-matching mode?
       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print
      \z only matches at the end of the string, but $ can match before a newline at the end. Unless you're using multiline mode, \A and ^ are the same.