in reply to Is there an array for $1,$2,$3... or some alternative ?

eval($temp4ev) is just going to report success or not (0,1)

Can you give one clear example of how you want this to work?

I would suggest writing some text explanation of what you think should happen.

Replies are listed 'Best First'.
Re^2: Is there an array for $1,$2,$3... or some alternative ?
by palkia (Monk) on Mar 14, 2012 at 04:17 UTC
    The user choses both the value of $fromUserNumber and of $pat
    when $fromUserNumber in a positive integer !
    I wanted that when $fromUserNumber == 1 the line will be
    @simMatches = map{$_ =~ s/$pat/$1/} @simMatches;
    when $fromUserNumber == 2 the line will be
    @simMatches = map{$_ =~ s/$pat/$2/} @simMatches; and so on.
      When you think of a subset of an array, think grep.
      Use map only when you think of transforming one thing into another.
      Perl variables can be interpolated into a regex expression.
      my $pat = "somepattern"; @simMatches = grep{/$pat$num/} @simMatches; # subset of @simMatches
      Show a couple of lines of actual data and this can all become clear.
      $1 or $2 are regex capture variables that don't seem to play a role here.