Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Repeating a substitution in a oneliner (write a program, trt)

by beech (Parson)
on Jan 10, 2018 at 01:41 UTC ( [id://1207025]=note: print w/replies, xml ) Need Help??


in reply to Repeating a substitution

But, what should one do when they want to replace the first 10 separators?

Write a program? So all you have to do is document how to use it, not explain perl syntax

cat > trt

#!/usr/bin/perl -- use strict; use warnings; Main( @ARGV ); exit( 0 ); sub Main { @_ or die Usage(); my( $find, $replace, $ntimes ) = @_; ... } sub Usage { qq{ Usage: trt "," "|" 10 trt ",,,,,,,,,," "||||||||||" Translate n times per line read from standard input, writing to stan +dard output. The usage example replaces the first 10 "," characters with "|". Farts sounds like "trt". }; } ## end sub Usage

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1207025]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-24 13:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found