Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^2: Reading/Parsing an XML file using Perl

by manu_06 (Novice)
on Sep 17, 2010 at 00:45 UTC ( #860420=note: print w/replies, xml ) Need Help??

in reply to Re: Reading/Parsing an XML file using Perl
in thread Reading/Parsing an XML file using Perl


Thank you for the help. I was trying your suggestion but it is showing up syntax error near the end of the script "}"

#!/usr/local/bin/perl-w use strict; use warnings; use XML::Simple; my $path = 'C:\Documents and Settings\user\Desktop\output2\FITS\ IMD02 +5350802'; # add your path here for my $xfile (glob "$path/*.xml") { print "xfile=$xfile\n"; my $xml = XML::Simple->new(); my $file = $xml->XMLin($xfile) or die $!; if (($file->{identification}{'identity'}{'format'} eq 'JPEG File I +nterchange Format') && ($file->{filestatus}{'well-formed'}{'content'} eq 'true') && ($file->{ +filestatus}{'valid'}{'content'} eq 'true')) }

Error: syntax error at line 14, near ") }"

Replies are listed 'Best First'.
Re^3: Reading/Parsing an XML file using Perl
by rowdog (Curate) on Sep 18, 2010 at 09:11 UTC

    You're missing at least an opening brace. You have

    ($file->{filestatus}{'well-formed'}{'content'} eq 'true') && ($file->{ +filestatus}{'valid'}{'content'} eq 'true')) }

    but you need something like

    ($file->{filestatus}{'well-formed'}{'content'} eq 'true') && ($file->{ +filestatus}{'valid'}{'content'} eq 'true')) { # do something useful }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://860420]
[moritz]: you need to read the file in one go to do a multiline regex match
[erix]: ha ha, I like the Vigilante
[Lady_Aleena]: Forget it. I'm getting angry with it.
[Lady_Aleena]: I'll just have to search for the files using the subs and open them up.
[Discipulus]: nice Perl dreams, folks.. shower->Dumas->bed
[erix]: pere ou fils?
[Lady_Aleena]: Discipulus, good night.
[Discipulus]: pere, le vicomte de bragelonne.. wonderfull

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2017-05-23 19:55 GMT
Find Nodes?
    Voting Booth?