2

i want to read an xml from stdin.

For parsing the xml I would use $data = $xml->XMLin(<STDIN>), anyway which is the most efficient way for evaluating all the data passed from stdin without rewriting it into a file?

If I use $data = $xml->XMLin(<STDIN>) it does not work.

Any suggestion?

Main goal is to use the data passed from the stdin in the most efficient way.

2 Answers 2

5
 $data = $xml->XMLin('-');

Note, the filename '-' can be used to parse from STDIN.

Sign up to request clarification or add additional context in comments.

3 Comments

what's the meaning of "-" is?
It's just a special symbol which XML::Simple understand as STDIN. This is XML::Simple feature described in docs.
It's quite common for Unix utilities and Perl functions that expect a filename to recognise '-' as meaning read from STDIN.
4

Passing a reference to the builtin filehandle also works using typeglob notation.

my $data = XMLin(\*STDIN);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.