P
pui ming Wong
My script which worked under 5.6.1 failed after I upgraded
to 5.8
The loop codes that failed is as below:
The print count line statement never gets printed at all; why?
------------------------------------------------
# read each message in turn
while( $msg = &read_message ) {
$count++;
print "count line is $count";
}
---------------------------------------------------
and its routine is:
-------------------------------------------------------
sub read_message
{
local( $msg ) = ""; # message to send back
local( $prev_blank ) = 1; # assume previous line blank
local( $seen_from ) = 0; # seen a from line
local( $line ) = ""; # current line
# reset some globals
$msg_status = "";
$msg_subject = "";
$msg_date = "";
while( $line = &get_line ) {
if( $line =~ /^From\s+([^\s]+)\s+(.*)$/ ) {
# if previous line was blank, then legal from line
if( $prev_blank ) {
# if already seen a legal from line, then this is next message
if( $seen_from ) {
# pushback this from line
$line_buffer = $line;
return $msg;
}
$seen_from++;
# From line found, extract information
( $msg_from, $msg_date ) = ( $1, $2 );
$msg_stamp = &rctime( $msg_date );
$msg_age = &days_old( $msg_stamp );
}
} elsif( $line =~ /^[Ss]tatus: ([A-Za-z]+)/ ) { ( $msg_status ) = ( $1 );
} elsif( $line =~ /^[Ss]ubject: (.*)$/ ) { ( $msg_subject ) = ( $1 );
}
# set previous line
if( $line =~ /^$/ ) {
$prev_blank = 1;
} else { $prev_blank = 0;
}
$msg .= $line;
}
return $msg;
}
-------------------------------------
BTW ,The perl routines required are:
require "getopts.pl"; # option handling
require "timelocal.pl"; # time conversion
require "ctime.pl"; # ctime for pseudo-mailing
require "stat.pl"; # file status
Any change to these after upgrade to 5.8 ?
that could be responsible for the failure of my old script?
to 5.8
The loop codes that failed is as below:
The print count line statement never gets printed at all; why?
------------------------------------------------
# read each message in turn
while( $msg = &read_message ) {
$count++;
print "count line is $count";
}
---------------------------------------------------
and its routine is:
-------------------------------------------------------
sub read_message
{
local( $msg ) = ""; # message to send back
local( $prev_blank ) = 1; # assume previous line blank
local( $seen_from ) = 0; # seen a from line
local( $line ) = ""; # current line
# reset some globals
$msg_status = "";
$msg_subject = "";
$msg_date = "";
while( $line = &get_line ) {
if( $line =~ /^From\s+([^\s]+)\s+(.*)$/ ) {
# if previous line was blank, then legal from line
if( $prev_blank ) {
# if already seen a legal from line, then this is next message
if( $seen_from ) {
# pushback this from line
$line_buffer = $line;
return $msg;
}
$seen_from++;
# From line found, extract information
( $msg_from, $msg_date ) = ( $1, $2 );
$msg_stamp = &rctime( $msg_date );
$msg_age = &days_old( $msg_stamp );
}
} elsif( $line =~ /^[Ss]tatus: ([A-Za-z]+)/ ) { ( $msg_status ) = ( $1 );
} elsif( $line =~ /^[Ss]ubject: (.*)$/ ) { ( $msg_subject ) = ( $1 );
}
# set previous line
if( $line =~ /^$/ ) {
$prev_blank = 1;
} else { $prev_blank = 0;
}
$msg .= $line;
}
return $msg;
}
-------------------------------------
BTW ,The perl routines required are:
require "getopts.pl"; # option handling
require "timelocal.pl"; # time conversion
require "ctime.pl"; # ctime for pseudo-mailing
require "stat.pl"; # file status
Any change to these after upgrade to 5.8 ?
that could be responsible for the failure of my old script?