in reply to Re: Extract a small part of a long sentence using regular expressions
in thread Extract a small part of a long sentence using regular expressions

Thanks Karl! Might be a dumb question(with Perl i am always in the figuring out stage!!) but what does  &{ sub { blah } do exactly??
  • Comment on Re^2: Extract a small part of a long sentence using regular expressions
  • Download Code

Replies are listed 'Best First'.
Re^3: Extract a small part of a long sentence using regular expressions
by choroba (Cardinal) on Dec 02, 2014 at 16:02 UTC
    It's a dereference, I'd rather (if ever) write it as
    my %hash = map { $key++ => $_ } grep { $_ != 0 } sub { $line =~ /action\(([^)]+)\)/; split /,/, $1; }->();
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      "It's a dereference..."

      Thank you for answering this question for me.

      But i'm Karl and you are Choroba, isn't it?

      "...(if ever)..write it"

      May be - if you make so. But there is nothing wrong with the syntax i used to dereference a anonymous sub.

      Regards, Karl

      «The Crux of the Biscuit is the Apostrophe»

        No offence. I use anonymous subs sometimes, too. I just don't feel it's needed here:
        my %hash = map { $key++ => $_ } grep { $_ != 0 } map { split /,/ } $line =~ /action \( ( [^)]+ ) \) /gx;
        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Got it!! Cheers!
Re^3: Extract a small part of a long sentence using regular expressions
by karlgoethebier (Abbot) on Dec 02, 2014 at 17:28 UTC
    "Might be a dumb question..."

    Sorry - my fault. I should have mentioned this. Please see perlsub as well as anonymous functions.

    Regards, Karl

    P.S.: There are no dumb questions. Just dumb answers ;-)

    «The Crux of the Biscuit is the Apostrophe»