in reply to Re^2: Print out an XML file to browser
in thread Print out an XML file to browser
Two things:
- If you know you want to output xml, then print header('text/xml'); is a lot simpler.
- Always check to see if your 'open' succeeded. Your error message means that your script didn't open the file.
#!/usr/local/bin/perl use strict; use warnings; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); print header('text/xml'); my $file = "/some/file.xml"; open(XMLFILE, $file) or die "Failed to open $file, $!"; while (<XMLFILE>){ print; }
In Section
Seekers of Perl Wisdom