[Chicago-talk] A CLUE @ARGV while(<>)

Richard Reina richard at rushlogistics.com
Tue Jan 8 16:03:29 PST 2008


Ted,

Thank you for your reply.  I will work on adding some debugging.

Thanks again,

Richard
Ted Zlatanov <@lifelogs.com> wrote: On Tue, 8 Jan 2008 06:55:49 -0800 (PST) Richard Reina  wrote: 

RR> Progress, maybe.  I believe this script is hanging at the line push(@lines, $_) unless (/espf\[/); 
RR> I believe this because in cases when it hangs, if I do a Cntl-C I get:

RR> Not a subroutine reference at ./file_delimiter.pl line 24, <> line3.

RR> This is turning out to be a disruptive problem here.  Any help would be greatly appreciated.

RR> #!/usr/bin/perl5 -w 

RR> use warnings;
RR> use strict;

RR> sub delimit {

RR> my ($tos, $ccs, $rp, $sb, $body, $in_file) = @_;

RR> if (defined $in_file) { # file submited 

RR> @ARGV = $in_file;

RR> $body = "";  

RR> while(<>) {

RR> push(@lines, $_) unless (/espf\[/);  # hangs here sometimes

RR> } # end of while

RR> } # end of if    

RR> } # end of sub

It's unlikely this is your script, since line 24 is at the end and
@lines is not declared, which wouldn't work under `use strict'.  Can you
please post your actual code that hangs?  Also try some debugging output
(or the Perl debugger with a watch).

FWIW, I'd write delimit() like this (untested):

sub delimit {
 my ($tos, $ccs, $rp, $sb, $body, $in_file) = @_;

 return unless defined $in_file;
 open IN, '<', $in_file or warn "Could not open $in_file: $!";
 my @lines;

 while (my $line = )
 {
  next if $line =~ m/espf\[/;
  push(@lines, $line);
 } 
}

Note how the open() will tell you if it couldn't open the input file,
which could be one of your problems.  Anyhow, don't post broken code, no
one can help you fix it.

Ted
_______________________________________________
Chicago-talk mailing list
Chicago-talk at pm.org
http://mail.pm.org/mailman/listinfo/chicago-talk



Your beliefs become your thoughts.  Your thoughts become your words.  Your words become your actions.  Your actions become your habits.  Your habits become your values.  Your values become your destiny.  -- Mahatma Gandhi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/chicago-talk/attachments/20080108/03db25c6/attachment.html 


More information about the Chicago-talk mailing list