in reply to Getting Error in character class - Regex

it's the array access that's causing the problems.. this works around it:
my $s = $imlre{$_}->[1]; $input =~ s/<$s[^>]*>//g ;

Replies are listed 'Best First'.
Re^2: Getting Error in character class - Regex
by ikegami (Patriarch) on Apr 03, 2006 at 15:40 UTC

    Curlies can be used for disambiguation:

    $input =~ s/<${imlre{$_}->[1]}[^>]*>//g ;

    When dealing with HoA, HoH, AoA and AoH, the arrays are optional between the indexes.
    $imlre{$_}->[1]
    is the same thing as
    $imlre{$_}[1]

    When Perl sees
    $imlre{$_}->[1][^>]
    it thinks you mean
    $imlre{$_}->[1]->[^>]
    rather than a HoA followed by a regexp. Between the square brackets, an index is expected. Since ^> is not a valid perl expression, you get an error.

    Update: Rearranged explanation for clarity.