in reply to Parsing a .gpx file with Geo::Gpx

Most probably the $gpx object variable was not initialized correctly. Probably the gpx-file was not read correctly. Add an "or die "Error in opening gpx file: $!; to line 6 and run the script again.

Update: deleted a spurious double quote.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

Replies are listed 'Best First'.
Re^2: Parsing a .gpx file with Geo::Gpx
by paulmorrow (Initiate) on Jun 27, 2012 at 22:05 UTC

    Count Zero, thanks for your reply, I inserted your text one space after the last word in line 6:

    "or die "Error is opening gpx file: $!;

    as you had instructed, with no luck, the error is below. I also tried some different combinations of positioning the " quotation marks and leaving them out all together.

    paul@intern-PM:~/Desktop/San Diego$ perl gpxscript2 String found where operator expected at gpxscript2 line 6, near "'sandiegopark.gpx' "or die "" (Missing operator before "or die "?) Bareword found where operator expected at gpxscript2 line 6, near ""or die "Error" (Missing operator before Error?) syntax error at gpxscript2 line 6, near "'sandiegopark.gpx' "or die "" Global symbol "$fh_in" requires explicit package name at gpxscript2 line 8. Execution of gpxscript2 aborted due to compilation errors.

    with no quotes I receive the message: paul@intern-PM:~/Desktop/San Diego$ perl gpxscript2 syntax error at gpxscript2 line 6, near "file:" Global symbol "$fh_in" requires explicit package name at gpxscript2 line 8. Execution of gpxscript2 aborted due to compilation errors.

    Sorry, I'm not sure how to proceed from here. I was also looking at a XML parser, for you can do a save as .xml, do you suggest something like that?

      That line should read:
      open my $fh_in, '<', 'fells_loop.gpx' or die "Error in opening gpx fil +e: $!";
      Try it and see what error you get.

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      My blog: Imperial Deltronics
      I'm not sure what the code looks like when you have it "without quotes", so to remove any confusion, could you revert to the script as it was without out the "or die" stuff and just add use autodie; to the top? What, if any, errors do you get now? Thanks.