mcoblentz has asked for the wisdom of the Perl Monks concerning the following question:
I'm getting an error,
and it's not clear to me what Perl is really complaining about. I'm not declaring things twice."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 "
Here's the full script:
I will probably be embarrassed again about the error but I'm stumped!#!/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 }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Opening filehandles
by Anonymous Monk on Jun 21, 2013 at 18:49 UTC | |
by mcoblentz (Scribe) on Jun 21, 2013 at 22:36 UTC |