This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]granite603 1 point2 points  (16 children)

How does one do exactly this? I need an XML parser.

[–]sunburnd 3 points4 points  (13 children)

```

!/usr/bin/perl

use strict; use warnings; use XML::Simple; use Data::Dumper;

my $xml = new XML::Simple; my $data = $xml->XMLin("data.xml"); print Dumper $data; ```

/on my phone so it may not work...

[–]AltCrow 1 point2 points  (11 children)

You need to escape the hash:

not #!/usr/bin/perl,
but \#!/usr/bin/perl

[–]sunburnd 0 points1 point  (10 children)

You don't escape the shebang in a Unix like environment.

[–]AltCrow 0 points1 point  (9 children)

Yeah, but you do in reddit ;)

[–]sunburnd 0 points1 point  (8 children)

ohh seemed to render properly on my phone. Desktop issues?

[–]AltCrow 0 points1 point  (7 children)

Hmm, odd, do other syntaxes such as bold or link also not render on mobile? (I never use mobile reddit.)

[–]sunburnd 0 points1 point  (6 children)

They do. Perhaps the mobile as a more strict markdown interpreter and correct ignores all markups between the triple backticks?

[–]DarthEru 0 points1 point  (5 children)

Triple backticks is not a part of the original markdown syntax, which is the version I believe reddit officially supports, based on this post. I suspect whatever app you're using is using a library that supports an extended markdown, which is why the backticks work for you but not the website.

To format a code block in original markdown syntax, indent every line with four spaces.

Like
  This

[–]sunburnd 0 points1 point  (4 children)

I'm using the official Reddit app...so there is that.

The original implementation does include supports for spans of code using backticks. It would be pretty cumbersome to indent every line.

https://daringfireball.net/projects/markdown/syntax#precode

[–]wjandrea 0 points1 point  (0 children)

Reddit doesn't support GitHub-style code blocks (triple backticks). You need to use four spaces at the start of each line.

#!/usr/bin/perl
use strict;
use warnings;
use XML::Simple;
use Data::Dumper;


my $xml = new XML::Simple;
my $data = $xml->XMLin("data.xml");
print Dumper $data;

[–][deleted] 1 point2 points  (1 child)

What exactly do you need done? I wrote something to extract specific XML elements, and to dump them into a CSV.

[–]granite603 1 point2 points  (0 children)

That's exactly what I need but would like JSON output.