Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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

by geekoid (Initiate)
on Mar 19, 2002 at 22:32 UTC ( #152871=note: print w/ replies, xml ) Need Help??


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

They do not have XML::Parser. There not planning on putting it on there at this time, however, they want me to manipulate these incoming XML files. The incoming XML file only have 2 pieces of information in it, and they could just send a normal file, but noooo, they want to use XML so they can say they use XML. Bah. Thanks for your advice everybody, I appreciate it. If I had know ahead of time they weren't going to give me the tools I need to do the job they mandated correctly, I wouldn't have bothered you. so I get to do this instead:

@ar = `tail -2 "$ack_filename"`; print $ar[0]; $file_size = substr($ar[0],13,-13); print $file_size;
hope there file format doesn't change. oh, and I can't put it in my space because we all use the same logon and password. yes you read correctly. I've been trying to get them to change that for almost a year, but they have more important things to do. Like work on there golf game. fortuanatly, my year here will be up at the end of july, and I can flee.


Comment on Re: (FoxUni) Re(3): XML parsing
Download Code
Re: Re: (FoxUni) Re(3): XML parsing
by PrakashK (Pilgrim) on Mar 20, 2002 at 03:48 UTC
    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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2014-10-02 00:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (41 votes), past polls