Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Replacing a special character

by BrowserUk (Pope)
on Jun 14, 2013 at 00:57 UTC ( #1038870=note: print w/ replies, xml ) Need Help??


in reply to Re: Replacing a special character
in thread Replacing a special character

Because: Quantifier follows nothing in regex; marked by <-- HERE in m/* <-- HERE / at ...


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re^2: Replacing a special character
Download Code
Re^3: Replacing a special character
by pvaldes (Chaplain) on Jun 16, 2013 at 22:06 UTC

    okey, okey, it was about the idea not about the execution. The idea is that you could wish (or not) to make the replacement before populating your array. It depends on your specific case or goals

    Replacing a special character by something, full version

    while (<DATA>){ s/\*/* /g; print }; __DATA__ ******************* ********************

    Returning to the question

    I have an array with some special character like '*' and i want to print " " (space ) every where I find this '*'
    if($dlog2[$co] eq '*') { print $fh " ,"; }

    By "print everywhere" I'm understanding (maybe incorrectly) "everywhere in my array". You are not printing to your array. You are printing to a filehandle that contains and points to... well... who knows. Scalar. Not an array.

    If you want to modify your array, the idea could be: if some element of my array eq to '*' reasign again this element to ' '

    if($dlog2[$co] eq '*'){ $dlog2[$co] = ' '}

    Or maybe, to clean your problematic characters before, with a global replacement, and forget about the '*' in your file.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2014-10-02 09:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (52 votes), past polls