Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Fix whitespace around symbols

by corfuitl (Sexton)
on Mar 20, 2015 at 14:49 UTC ( [id://1120750]=note: print w/replies, xml ) Need Help??


in reply to Re: Fix whitespace around symbols
in thread Fix whitespace around symbols

Hi,

Thanks for your reply. I haven't written any code because I don't know how to start. I would like to do it in perl but other script languages are welcome.

I have tried your code and it works when the sentence contains one symbol. In case of more symbols, they are omitted from the second sentence.

Thanks

Replies are listed 'Best First'.
Re^3: Fix whitespace around symbols
by Corion (Patriarch) on Mar 20, 2015 at 15:00 UTC

    I can't replicate the problem. When I run the program with the two sentences:

    $_= "This is a perl script/program- code."; my $target= "C'est un perl script / programme - codele";

    I get as the result in $target:

    C'est un perl script/programme- codele

    ... which is what I expect. If you tell us the exact input data and the exact output data you get, maybe we can work on finding the cause.

      Hi,

      I don't have a standard text, but the problem appears when I have two same symbols in the same sentence. For instance,

      <p>Is this a perl script/program or a java script/program?</p> <p>C'est un perl script / programme ou un script / programme?</p>

      Best

        Aaah, now I understand. There was the /g flag missing when initializing the %symbols hash. As soon as you add it to the three m// operators, the program works. See perlop and perlre for more information on the /g flag.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-19 19:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found