in reply to Is is possible to read in XML file with out use any module?

It's easy enough to read it in. This will slurp it in as a big string:

my $xml_text = do { local(@ARGV, $/) = 'myfile.xml'; <> };

But actually using the content is a different matter. XML is pretty complex to parse, which is why people generally use a pre-written XML module. Parsing a limited subset of XML is generally doable using regular expressions, but I'd still consider this a last resort.

Any particular reason why you're not using modules? See Top Seven (Bad) Reasons Not To Use Modules.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^2: Is is possible to read in XML file with out use any module?
by depthFirst (Initiate) on May 12, 2012 at 22:02 UTC

    hey thanks, I have tried the way you provided to read the .xml file. When I print out the "$xml_text" it seems it is only part of the xml file

    Before I post a question here. I have tried use a while loop

    while(<STDIN>){ print $_; }
    which produce the same output with your method. If I put the xml file to a .txt file. It reads in just fine. the reason I cannot use module is because it is an home work requirement