in reply to vanishing system call

The first thing I would add, and leave in place is

system(" cat $file | sort -t\\| +1 -2 > $file.out ") or warn "sort fai +led $!\n";

Also, you said that "I tried -w". Is there some reason that you don't leave -w on all the time?

The second thing I notice, though my memory of *nix is sketchy is that you are starting 2 processes and using a pipe when 1 process, no pipe would be fine.

system("sort -t\\| +1 -2 <$file > $file.out ") or warn "sort failed $! +\n";

Actually I am fairly sure that you don't even need the '<' infront of the filename but my memory ain't what it once was.

Some other possibilities

What happens if you issue the sort command as you have it immediately after the program has run? If it works as expected then, that will eliminate several possiblities.


Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!

Replies are listed 'Best First'.
Re: Re: vanishing system call
by sauoq (Abbot) on Sep 20, 2002 at 20:19 UTC

    It seems this is a meme that just won't roll over and die...

    The construct, system(...) or die_warn_etc() is almost never what you want. The return value of system() is the exit value of the command executed. Usually, this will be 0 on success. Some alternatives:

    system(...) and die; # Ugly. if ( system(...) != 0 ) { die } # C-ish if ( system(...) ) { die } # C-ish and ugly. unless ( system(...) == 0 ) { die } # Nicer

    I think it is better to explicitly compare to 0. It serves as a reminder that system() is a bit different than most functions in this respect.

    -sauoq
    "My two cents aren't worth a dime.";
    
      Or you can simply system(@LIST) == 0 or die; :-)

      Makeshifts last the longest.