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

Re: Convert backslash to slash using XML parsing

by Taulmarill (Deacon)
on Nov 12, 2004 at 08:47 UTC ( [id://407307]=note: print w/replies, xml ) Need Help??


in reply to Convert backslash to slash using XML parsing

if you only whant to translate '\' to '/', why don't you just use tr!\\!/!;?

Replies are listed 'Best First'.
Re^2: Convert backslash to slash using XML parsing
by Aighearach (Initiate) on Nov 12, 2004 at 09:49 UTC
    THere must be more to it than that, presumably the books contain other, non-url backslashes also.

    --
    Snazzy tagline here
      yea ok, that may be. but why XML?!?
      if i wanted to be clean i would use HTML::Parser.
        I proposed XML parsing because it would solve my problem on one hand and it is a nice way to solve a 'real world problem' on the other hand.
        Indeed using 'tr' would convert *all* '\', but I only want to convert *links*.
        HTML::Parser sounds usable. I'll take a look at it. In the mean time, don't hesitate to reply furthermore since I hope someone will give me a snippet of XML parsing.. :-) This would make a great start for me to get along
Re^2: Convert backslash to slash using XML parsing
by davido (Cardinal) on Nov 12, 2004 at 17:59 UTC

    Why would you assume that it is safe to convert every backslash in the entire Perl CD Bookshelf to a forward slash? This would blindly ruin every example in the suite of CD books! That's a case of throwing out the baby with the bathwater. Could you imagine reading the Camel book where someone has gone through it and changed every single backslash to a forward slash? The first hello world script would look like this:

    #!/usr/bin/perl -w print "Hello world!/n";

    ...and for the record, "/n" is not the same thing as "\n".

    No, the OP realy does probably need a token parser like HTML::TokeParser, and a routine a little smarter than blind transliteration.

    One thing about the OP's post does bother me though. Does this conversion of file:\\\ to http:// mean that he's going to be making available ONLINE the entire Perl CD Bookshelf, in violation of O'Reilly's copyright?


    Dave

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (9)
As of 2024-05-21 13:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found