Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > <GEN5> ?

Reply
Thread Tools

<GEN5> ?

 
 
cmb99@operamail.com
Guest
Posts: n/a
 
      01-22-2007
I couldn't find the answer to this on the web, but when I get an error
like:

Modification of a read-only value attempted at
C:\dev\perl\script\mail.pl line 55, <GEN5> line 1908. It's a little
confusing. My script is called mail.pl, but I don't have 1900 lines in
it. I'm not really looking for help on the specific error, just what is
meant by output like this.

 
Reply With Quote
 
 
 
 
Mark Clements
Guest
Posts: n/a
 
      01-22-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I couldn't find the answer to this on the web, but when I get an error
> like:
>
> Modification of a read-only value attempted at
> C:\dev\perl\script\mail.pl line 55, <GEN5> line 1908. It's a little
> confusing. My script is called mail.pl, but I don't have 1900 lines in
> it. I'm not really looking for help on the specific error, just what is
> meant by output like this.
>

You have an open filehandle called GEN5. The error has been caused at
line 55 of your script while line 1908 has just been read from GEN5.

(from perldoc perldiag)

Modification of a read-only value attempted
(F) You tried, directly or indirectly, to change the value of a
constant. You didn't, of course, try "2 = 1", because the compiler
catches that. But an easy way to do the same thing is:

sub mod { $_[0] = 1 }
mod(2);

Another way is to assign to a substr() that's off the end of the
string.

Yet another way is to assign to a "foreach" loop *VAR* when *VAR* is
aliased to a constant in the look *LIST*:

$x = 1;
foreach my $n ($x, 2) {
$n *= 2; # modifies the $x, but fails on attempt to modify the 2
}

Mark
 
Reply With Quote
 
 
 
 
cmb99@operamail.com
Guest
Posts: n/a
 
      01-22-2007
Except that there aren't 1900 lines in the (imported) file either. Kind
of throwing my hands up in the air. This script works on exchange (MS)
inboxes but not on a pop3 server on the included component of win2k3
server.

Script attempts to read each e-mail, save attachments, and unzip saved
files:

#!/usr/bin/perl

use Mail:OP3Client;
use Mail::MboxParser::Mail;
use Archive::Extract;

#connect to POP
$pop = new Mail:OP3Client( USER => "username",
PASSWORD => "password",
HOST => "XXX.XXX.XXX.XXX",
PORT => 110,
DEBUG => 0,
AUTH_MODE => "PASS" );

$pop->Connect() || die $pop->Message();
print $pop->Count(), " message(s) in Inbox\n";

for( $i = 1; $i <= $pop->Count(); $i++ ) {
my @header = $pop->Head($i);
my @body = $pop->Body($i);
my $mail = new Mail::MboxParser::Mail (\@header, \@body) ;
my $numAttach = $mail->num_entities;
next if ($numAttach lt 1); # no attachments. body considered
attachment
my $mapping = $mail->get_attachments;
for my $filename (keys %$mapping) { # loop over attachments
next if $filename !~ /.*connectivity.*gzip/; # only interested in
connectivity logs
my $gz_filename = $filename;
$gz_filename =~ s/gzip/gz/;
#line that dies when connecting to MS pop3 vvvv
$mail->store_attachment($mapping->{$filename}, path => "temp") || die
("Died saving ", $filename, "\n", $mail->error()); # save to 'temp'
directory
rename "temp/".$filename, "temp/".$gz_filename; # Archive::Extract
doesn't understand gzip, only gz
$ae = Archive::Extract->new(archive => "temp/".$gz_filename, type=>
"gz");
$ae->extract(to => "temp");

# process xml

# write to database

}
}
}

$pop->Close();

Mark Clements wrote:
> (E-Mail Removed) wrote:
> > I couldn't find the answer to this on the web, but when I get an error
> > like:
> >
> > Modification of a read-only value attempted at
> > C:\dev\perl\script\mail.pl line 55, <GEN5> line 1908. It's a little
> > confusing. My script is called mail.pl, but I don't have 1900 lines in
> > it. I'm not really looking for help on the specific error, just what is
> > meant by output like this.
> >

> You have an open filehandle called GEN5. The error has been caused at
> line 55 of your script while line 1908 has just been read from GEN5.
>
> (from perldoc perldiag)
>
> Modification of a read-only value attempted
> (F) You tried, directly or indirectly, to change the value of a
> constant. You didn't, of course, try "2 = 1", because the compiler
> catches that. But an easy way to do the same thing is:
>
> sub mod { $_[0] = 1 }
> mod(2);
>
> Another way is to assign to a substr() that's off the end of the
> string.
>
> Yet another way is to assign to a "foreach" loop *VAR* when *VAR* is
> aliased to a constant in the look *LIST*:
>
> $x = 1;
> foreach my $n ($x, 2) {
> $n *= 2; # modifies the $x, but fails on attempt to modify the 2
> }
>
> Mark


 
Reply With Quote
 
cmb99@operamail.com
Guest
Posts: n/a
 
      01-22-2007
Nevermind, had slashes in the attachment filenames.

(E-Mail Removed) wrote:
> Except that there aren't 1900 lines in the (imported) file either. Kind
> of throwing my hands up in the air. This script works on exchange (MS)
> inboxes but not on a pop3 server on the included component of win2k3
> server.
>
> Script attempts to read each e-mail, save attachments, and unzip saved
> files:
>
> #!/usr/bin/perl
>
> use Mail:OP3Client;
> use Mail::MboxParser::Mail;
> use Archive::Extract;
>
> #connect to POP
> $pop = new Mail:OP3Client( USER => "username",
> PASSWORD => "password",
> HOST => "XXX.XXX.XXX.XXX",
> PORT => 110,
> DEBUG => 0,
> AUTH_MODE => "PASS" );
>
> $pop->Connect() || die $pop->Message();
> print $pop->Count(), " message(s) in Inbox\n";
>
> for( $i = 1; $i <= $pop->Count(); $i++ ) {
> my @header = $pop->Head($i);
> my @body = $pop->Body($i);
> my $mail = new Mail::MboxParser::Mail (\@header, \@body) ;
> my $numAttach = $mail->num_entities;
> next if ($numAttach lt 1); # no attachments. body considered
> attachment
> my $mapping = $mail->get_attachments;
> for my $filename (keys %$mapping) { # loop over attachments
> next if $filename !~ /.*connectivity.*gzip/; # only interested in
> connectivity logs
> my $gz_filename = $filename;
> $gz_filename =~ s/gzip/gz/;
> #line that dies when connecting to MS pop3 vvvv
> $mail->store_attachment($mapping->{$filename}, path => "temp") || die
> ("Died saving ", $filename, "\n", $mail->error()); # save to 'temp'
> directory
> rename "temp/".$filename, "temp/".$gz_filename; # Archive::Extract
> doesn't understand gzip, only gz
> $ae = Archive::Extract->new(archive => "temp/".$gz_filename, type=>
> "gz");
> $ae->extract(to => "temp");
>
> # process xml
>
> # write to database
>
> }
> }
> }
>
> $pop->Close();
>
> Mark Clements wrote:
> > (E-Mail Removed) wrote:
> > > I couldn't find the answer to this on the web, but when I get an error
> > > like:
> > >
> > > Modification of a read-only value attempted at
> > > C:\dev\perl\script\mail.pl line 55, <GEN5> line 1908. It's a little
> > > confusing. My script is called mail.pl, but I don't have 1900 lines in
> > > it. I'm not really looking for help on the specific error, just what is
> > > meant by output like this.
> > >

> > You have an open filehandle called GEN5. The error has been caused at
> > line 55 of your script while line 1908 has just been read from GEN5.
> >
> > (from perldoc perldiag)
> >
> > Modification of a read-only value attempted
> > (F) You tried, directly or indirectly, to change the value of a
> > constant. You didn't, of course, try "2 = 1", because the compiler
> > catches that. But an easy way to do the same thing is:
> >
> > sub mod { $_[0] = 1 }
> > mod(2);
> >
> > Another way is to assign to a substr() that's off the end of the
> > string.
> >
> > Yet another way is to assign to a "foreach" loop *VAR* when *VAR* is
> > aliased to a constant in the look *LIST*:
> >
> > $x = 1;
> > foreach my $n ($x, 2) {
> > $n *= 2; # modifies the $x, but fails on attempt to modify the 2
> > }
> >
> > Mark


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments