Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: (FoxUni) Re(3): XML parsing

by PrakashK (Pilgrim)
on Mar 20, 2002 at 03:48 UTC ( #152908=note: print w/ replies, xml ) Need Help??


in reply to Re: (FoxUni) Re(3): XML parsing
in thread XML parsing

You have my sympathy. Since you are counting (or hoping) on the file format to not change, and not treating the data as XML (as suggested by your code above), you could improve it a little bit.

Assuming that you just want the number between the FILE_SIZE tags, you can do something like:

open my $fh, "<$ack_filename" or die "open error: $!"; my $file_size; while (<$fh>) { chomp; if (m|<file_size>([^<]*)</file_size>|i) { $file_size = $1; last; } } $fh->close; print $file_size;
This avoids running an external command and does not require the value to start at on offset of 13 in the second line from last. Even though it is more flexible, it would not be the right approach to parse XML data, but in your difficult situation I guess you can't do much better.

Then again, if the people you work with are so stupid and stubborn, maybe they deserve such code or worse.

Good luck getting out of there.

/prakash


Comment on Re: Re: (FoxUni) Re(3): XML parsing
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://152908]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (14)
As of 2014-08-01 17:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (33 votes), past polls