I'm not too sure if this is a perl question.....

Discussion in 'Perl Misc' started by grocery_stocker, Jan 3, 2007.

  1. I have a question on the Firefox mork script found at:

    http://www.jwz.org/hacks/mork.pl

    ##########################################################################
    # Read in the file.

    ##########################################################################
    open (IN, "<$file") || error ("$file: $!");
    print STDERR "$progname: reading $file...\n" if ($verbose);

    my $body = <IN>;
    close IN;

    $body =~ s/\r\n/\n/gs; # Windows Mozilla uses \r\n
    $body =~ s/\r/\n/gs; # Presumably Mac Mozilla is similarly dumb

    $body =~ s/\\\\/\$5C/gs; # Sometimes backslash is quoted with a
    # backslash; convert to hex.
    $body =~ s/\\\)/\$29/gs; # close-paren is quoted with a backslash;
    # convert to hex.
    $body =~ s/\\\n//gs; # backslash at end of line is continuation.

    I have a clear understanding of this part
    $body =~ s/\r\n/\n/gs; # Windows Mozilla uses \r\n
    $body =~ s/\r/\n/gs; # Presumably Mac Mozilla is similarly dumb

    However, I don't understand this part.
    $body =~ s/\\\\/\$5C/gs; # Sometimes backslash is quoted with a
    # backslash; convert to hex.
    $body =~ s/\\\)/\$29/gs; # close-paren is quoted with a backslash;
    # convert to hex.
    $body =~ s/\\\n//gs; # backslash at end of line is continuation.

    Let's see if I can break this down.
    1)I really don't see when a backslash can be quoted as a backslash
    (presum. in URL)
    2)I see even less when there can be a close-paren with backslash.

    Maybe if I understood this, I could maybe understand why it has to be
    converted to hex.

    Chad
     
    grocery_stocker, Jan 3, 2007
    #1
    1. Advertisements

  2. grocery_stocker

    John Bokma Guest

    If you read the rest of jwz's comments you should have learned fast enough
    that MORK is the biggest POS file format you'll probably every encounter
    in your life.

    Let's hope it will be dropped with Firefox 3.0 (If it hasn't been already)
     
    John Bokma, Jan 3, 2007
    #2
    1. Advertisements

  3. For whatever reasons, I thought I was somehow missing some strange and
    funky CS concept. After following and reading the URLs in the source
    code, I realized that those lines were meant to deal with MORK itself.

    Chad
     
    grocery_stocker, Jan 3, 2007
    #3
  4. grocery_stocker

    John Bokma Guest

    Yup, kudos to jwz for his script. I once tried to decode the format
    myself, and while looking for a specification I found the script.
     
    John Bokma, Jan 3, 2007
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.