I am sure that the solution to this problem will be simple but it clearly eludes me at the moment. I'm writing out to two files, #1 = volcano and #2 = label.txt. I added the label routine so I could check on the whether the data was fresh or stale.

I'm getting an error,

"my" variable $outfile masks earlier declaration in same scope at ./vo +lcano/volcano_parsing_2 line 14.</p> <p> syntax error at ./volcano/volcano_parsing_2 line 14, near "open "
and it's not clear to me what Perl is really complaining about. I'm not declaring things twice.

Here's the full script:

#!/usr/bin/perl -w use strict; use warnings; use XML::FeedPP; use HTML::TreeBuilder::XPath; # input my $source = 'http://www.volcano.si.edu/news/WeeklyVolcanoRSS.xml'; # output my $markers_dir = "/Users/coblem/xplanet/markers"; my $outfile = "$markers_dir/volcano"; my $labelfile = "$markers_dir/label.txt" open my $fh,">",$outfile or die "$!"; open my $label, ">", $labelfile or die "$!"; # initialize report_header(); my $volcano_color = "Chocolate"; label_header($markers_dir); close $label; # process my $feed = XML::FeedPP->new( $source ); foreach my $volcano( $feed->get_item() ) { my $title = $volcano->get('title'); my $name = substr($title, 0, index($title, '(', 0)-1); my $locn = $volcano->get('georss:point'); print $fh <<EOF \# Title : $title \# Name : $name \# Location : $locn $locn "" color=Yellow symbolsize=4 $locn "" color=Orange symbolsize=8 $locn "$name" color=$volcano_color align=Below EOF } close $fh; sub report_header { my $cur_time = localtime; print $fh <<EOF # This Volcano file created by script "volcano_parsing_1" # Matt Coblentz; Perl version v5.12.4 # For more information, see the website $source # Last Updated: $cur_time EOF } sub label_header { my $update_time = localtime; print $label <<EOF -65 -1 "Volcano Infomation Last Updated $update_time" color=Green i +mage=none position=pixel; EOF }
I will probably be embarrassed again about the error but I'm stumped!

In reply to Opening filehandles by mcoblentz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.