Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: What is wrong here (Replacing Strin pieces)

by AnomalousMonk (Chancellor)
on Jul 16, 2013 at 16:23 UTC ( #1044631=note: print w/replies, xml ) Need Help??


in reply to Re: What is wrong here (Replacing Strin pieces)
in thread What is wrong here (Replacing Strin pieces)

$string =~ s/\A(-+)|(-+)$/("?" x length $1).("?" x length $2)/eg;

That does the substitutions, but will also produce warnings if run with warnings:

>perl -wMstrict -le "my $s = '---------xxxxxxxxxxxxxxx------yyyyyyyyyyyyyy--------'; print qq{'$s'}; ;; $s =~ s{ \A (-+) | (-+) \z } { ('?' x length $1) . ('?' x length $2) }xmsge; print qq{'$s'}; " '---------xxxxxxxxxxxxxxx------yyyyyyyyyyyyyy--------' Use of uninitialized value $2 in repeat (x) at -e line 1. Use of uninitialized value $1 in repeat (x) at -e line 1. '?????????xxxxxxxxxxxxxxx------yyyyyyyyyyyyyy????????'

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1044631]
help
Chatterbox?
[choroba]: The older one will even perform twice, once at a retirement home, and then at the music school. It's a day off, but will be pretty busy...
[Eily]: hello perlmonks :)
[Corion]: choroba: I think it's great that your kids (have to) perform in public - that makes you appreciate any kind of show much better IMO

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2017-12-12 09:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (327 votes). Check out past polls.

    Notices?