Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a ~1.5MB data file which is simply dumped to screen using the following code:
#!/usr/bin/perl -w use strict; use warnings; eval { die 'insufficient arguments' unless @ARGV; open(IN, $ARGV[0]) or die "unable to open '$ARGV[0]'"; while (<IN>) { printf "%4d:\t%s", $., $_; } close IN; }; if ($@) { print "error:\t$@"; }
If I run this in an xterm specifying the data's filename as an argument, the script runs & terminates the xterm. When I run this script at the console it runs to completion as expected; my debugger knowledge is weak, but it appears to run fine there too. What should I be looking for in the debugger in order to determine the root cause? Thanks for any insight which can be shared.

Replies are listed 'Best First'.
Re: debugging possible memory crash?
by varian (Chaplain) on Jun 11, 2007 at 06:40 UTC
    Indead not really a Perl issue. This is documented xterm behavior, it is supposed to exit as soon as the program it has started has completed. So instead of:
    xterm -e 'perl xx.pl'
    specify an extra xterm option to keep the window open after the Perl program has finished:
    xterm -hold -e 'perl xx.pl'
      I'm running a shell within the xterm. Executing the Perl script takes down both the shell & xterm. This is expected behaviour? I would think I should be returning to the shell...
        once perl exits, xterm does what xterm want
Re: debugging possible memory crash?
by cdarke (Prior) on Jun 11, 2007 at 08:30 UTC
    There might be some binary data in the file which is confusing your xterm, is it pure text?

      I would agree with cdarke. Possibly some non-ASCII characters (UTF-8?) are being output and your xterm cannot handle it -- but I haven't seen that in quite some time. What system are you running and what version of xterm do you have?

      -derby
        Actually, I'm running aterm 0.4.2p1 on OpenBSD 4.1. Do you know how I would check to see if characters are UTF-8?
Re: debugging possible memory crash?
by TOD (Friar) on Jun 11, 2007 at 05:53 UTC
    that must not be a perl problem, nor one of the system memory. i assume it's the xterm configuration.

    --------------------------------
    masses are the opiate for religion.