in reply to Re^2: More efficient way to truncate long strings of the same character
in thread More efficient way to truncate long strings of the same character

It's not necessary.

>perl -e"$_='a'; print qr/$_{3}/" (?-xism:a{3})

And beyond being unnecessary, it will never help either. If you were to do ${_}{...} to prevent $_{...} from beint treated as a hash element, it still wouldn't do what you want. See Re: Of scalars, hashes, quantifiers, and regexen.

Replies are listed 'Best First'.
Re^4: More efficient way to truncate long strings of the same character
by GrandFather (Saint) on Oct 31, 2008 at 00:00 UTC

    So when I run:

    use strict; use warnings; my ($ikegamiRe1) = map qr/$_/, join '|', map "(?<=$_{3})$_+", map quot +emeta, 1 .. 9;

    I should ignore:

    Use of uninitialized value in concatenation (.) or string at noname.pl + line 4. Use of uninitialized value in concatenation (.) or string at noname.pl + line 4. Use of uninitialized value in concatenation (.) or string at noname.pl + line 4. Use of uninitialized value in concatenation (.) or string at noname.pl + line 4. Use of uninitialized value in concatenation (.) or string at noname.pl + line 4. Use of uninitialized value in concatenation (.) or string at noname.pl + line 4. Use of uninitialized value in concatenation (.) or string at noname.pl + line 4. Use of uninitialized value in concatenation (.) or string at noname.pl + line 4. Use of uninitialized value in concatenation (.) or string at noname.pl + line 4.

    Update: Oh, and here's an interesting result:

    use strict; #use warnings; my $str = join '|', map "(?<=${_}{3})$_+", 1 .. 2; print $str, "\n"; $str = join '|', map "(?<=$_{3})$_+", 1 .. 2; print $str;

    Prints:

    (?<=1{3})1+|(?<=2{3})2+ (?<=)1+|(?<=)2+

    Perl reduces RSI - it saves typing
      Oh shoot, that's a string literal and not a regexp literal! Fixed.