This is a small perl script I wrote to check mirror lists (files filled with one URL per line). It prints "[FAIL] hxxp://..." when an URL can't be retrieved and just prints the url when everything goes fine. The code is pretty straightforward and it works well until I am trying to redirect its output.
There is one thing I can't figure out. As far as I know the program called 'less
' prints its input on the screen providing a nice interface for examining the contents of another program's output.
less works fine in situations like:
perl -e 'print "test"' | less
ls | less
cat /etc/passwd | less
The problem is that using my script 'less
' only gets the lines sent to STDERR.
# Usage: ./linkchk.pl filename_containing_urls
# or cat file | ./linkchk.pl
# create and urllist file
# try ./linkchk.pl urllist | less
print STDOUT "Why can't ./linkchk.pl urllist|less see this?\n";
print STDOUT "$line\n";
print STDERR "[FAIL] $line\n";
(Fedora9, perl 5.10.0)