in reply to shell problem
Also for problems like this it can be very nice to open on pipes and hook them up within Perl.