Honored monks
The following script quick and dirty though it may be was working for months until the CGI.pm module(s) got upgraded. It now throws this error
"ebcdic2ascii" is not exported by the CGI::Util module
"ascii2ebcdic" is not exported by the CGI::Util module
Can't continue after import errors at pressUpload.pl line 8
BEGIN failed--compilation aborted at pressUpload.pl line 8.
I added an explicit import line in a blind attempt to get this back up and running (see use CGI::Util line in script below). but this did not change the error which is being thrown by the line use CGI; or use CGI qw/:all /;. Which one I use has made no difference. If, for fun, I comment out use CGI; then the same error is thrown by the use CGI::Util line. I have Googled the error and found this but haven't been able to figure out what is happening.
Any help will be greatly appreciated.
TIA
jg
#!/usr/local/bin/perl -w
use strict;
use CGI::Carp qw/fatalsToBrowser /;
use lib ('/home/xxxxx/public_html/mods');
use CGI qw/:all /;
# this line added to try to deal with error
use CGI::Util qw(rearrange make_attributes unescape escape expires ebc
+dic2ascii ascii2ebcdic);
my $q = CGI->new();
use CGI::Upload;
my $upload = CGI::Upload->new;
use DBI;
my $user_pass = $q->param('pass');
my $name = $q->param('name');
my $corrected_filename = $name;
$corrected_filename =~ s/ /_/g;
$corrected_filename =~ s/[^a-zA-Z0-9_-]//g;
my $file_extension = $upload->file_type('temp_filename');
$corrected_filename .= ".$file_extension";
my $target_directory = "/home/ehrhardt/public_html/releases/";
if ($user_pass eq 'xxxxx') {
file_up();
} else {
print $q->header, start_html, h2('Bad Password=', $user_pass);
exit;
}
sub file_up {
local $| = 1;
my ($bytesread,$buffer,$file);
my $fh = $upload->file_handle('temp_filename');
open(OUTF, '>' . $target_directory . $corrected_filename);
while ($bytesread = read($fh, $buffer, 1024)) {
print(OUTF $buffer);
}
close(OUTF);
if (!$file && $q->cgi_error) {
print($q->header(-status=>$q->cgi_error));
exit 0;
}
update_db();
my $redir = "http://www.xxxxx.com/admin/done.htm";
print $q->redirect("$redir");
}
sub update_db {
my $dbh = DBI->connect("DBI:mysql:PressReleases:localhost","xxxx",
+"xxxxx",{'RaiseError' => 1});
my $sth = $dbh->prepare("INSERT INTO Releases (Row, Name, FileURL,
+ Description, Uploaded, Archived) VALUES (?, ?, ?, ?, ?, ?)");
my $fileURL = "http://65.57.xxx.x/~xxxx/xxxxx/$corrected_filename"
+;
my $description = $q->param('description');
$description =~ s/\'/\\\'/g;
$sth->execute('', $name, $fileURL, $description, undef, '');
}
_____________________________________________________
"The man who grasps principles can successfully
select his own methods.
The man who tries methods,
ignoring principles, is sure to have trouble.
~ Ralph Waldo Emerson
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.