$ cat > script.pl print('!', $/); select(STDERR); sub test { print('@', $/); } test(); ^D $ perl script.pl 2>stderr ! $ cat stderr @ $