in reply to Re: Passing Regex Pattern in Subroutine
in thread Passing Regex Pattern in Subroutine

Yes, this is what I am looking for. But I don't understand why you had to use 'map' to pass the regular expression.

Is it because when you run get_data( map { "^$_" @ids } ), it is like doing get_data( "^john" ) and that is being passed to the subroutine?

  • Comment on Re^2: Passing Regex Pattern in Subroutine

Replies are listed 'Best First'.
Re^3: Passing Regex Pattern in Subroutine
by toolic (Bishop) on Aug 16, 2011 at 23:18 UTC
    I don't understand why you had to use 'map' to pass the regular expression
    You could use map inside your sub, if you prefer.
    Is it because when you run get_data( map { "^$_" @ids } ), it is like doing get_data( "^john" ) and that is being passed to the subroutine?
    Not exactly. The map is like doing:
    get_data( '^john' , '^james' );