Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7890527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:22:38+00:00 2026-06-03T06:22:38+00:00

I have my $x = whatever 123; $x =~ s/ //g; $x =~ s/\d/9/g;

  • 0

I have

my $x = "whatever 123";
$x =~ s/ //g;
$x =~ s/\d/9/g;
frobnicate($x);

although in real life it’s far messier and bigger. What I would like to do is perform the substitions in functional form, like this:

my $x = "whatever 123";
frobnicate(   regex_substitutions($x, s/ //g, s/\d/9/g) );

That may look like a step backward in readability, but in real life something like this would actually help. The goal it to avoid having the regex substitutions in separate statements, but incorporated into an expression. I’m guessing there’s a slick and readable way to do this that long-time perl experts would know.

(Not only is there “more than one way to do it” but there’s more than one way to ask about any particular thing. Forgive me if this question is redundant with existing ones.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:22:40+00:00Added an answer on June 3, 2026 at 6:22 am

    5.14 introduced /r(eturn):

    frobnicate( $x =~ s/ //gr =~ s/\d/9/gr );
    

    Any version:

    frobnicate apply { s/ //g; s/\d/9/g; } $x;
    

    apply comes from List::MoreUtils.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Specifically, say I have a string like ABC-123-NNN. I would like the paragraph to
I have the following variables: $something = 'whatever'; $hello = array(); $test = 123;
I have a table row, and within that, I have a td (whatever it
I have following code: def whatever(url, data=None): req = urllib2.Request(url) res = urllib2.urlopen(req, data)
I have some PHP code which stores whatever is typed in a textbox in
I have this code here printf '$request1 = select * from whatever where this
i have two mysql tables tableA colA1 colA2 1 whatever 2 whatever 3 whatever
I have a .js file to deal with a dialog box whatever when I
In the past I have used MAPISendMail to launch Outlook (or whatever the desired
I have made Iphone applicatio. In my application whatever data i have recorded; all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.