in reply to Re: sytem command perl
in thread sytem command perl

better yet, quote each string argument:
system 'perl', '-pi', '-e', 's/>//g', $filename;
See? I didn't quote $filename because the variable is already the argument I want to pass to 'perl'.
But you can even do better: instead of calling another instance of perl, do the job right here:
CHANGE_FILE: { my $backup = "${filename}~"; rename $filename, $backup; open my $b, '<', $backup; open my $f, '>', $filename; select $filename; s/>//g, print while <$backup> }
[]s, HTH, Massa (κς,πμ,πλ)

Replies are listed 'Best First'.
Re^3: sytem command perl
by FunkyMonk (Bishop) on Aug 25, 2008 at 10:33 UTC
    • You should check that open, close & rename succeeded
    • If you're going to use select (and I wouldn't) make sure to restore STDOUT to what it should be when you're finished with it
    • You've confused the use of $filename, $f, $backup and $b in your last two statements.