On Thu Jan 21, 2010 at 11:08:39 +0100, Guido G??nther wrote: > Failed to run filter: No such file or directory at /usr/bin/chronicle line > 2000. > # Run the command, reading stdout. > # > - open( FILTER, "$cmd|;utf8" ) or > + open( FILTER, "$cmd|" ) or
This will work, but means that any non-Latin characters will be lost. Can you please try running the sample program attached, and reporting the output? That should be sufficient to tell me which alternative I should adopt. Steve --
#!/usr/bin/perl -w use strict; use warnings; # # 1. Open normally. # print "1. Open a pipe, normally\n"; open( CMD, "/bin/ls /etc/|" ) or die "1. failed: $!"; while( my $line = <CMD> ) { print "\t$line" if ( $line =~ /(motd|group)$/ ); } close( CMD ); # # 2. Open normally, binmode it. # print "2. Open a pipe, set the mode\n"; open( CMD, "/bin/ls /etc/|" ) or die "2. failed: $!"; binmode(CMD, ":utf8"); while( my $line = <CMD> ) { print "\t$line" if ( $line =~ /(motd|group)$/ ); } close( CMD ); # # 3. Use a handle, as God intended. # print "3. Open a handle.\n"; open my $handle, "-|", "/bin/ls /etc" or die "Failed : $!\n"; while( my $line = <$handle> ) { print "\t$line" if ( $line =~ /(motd|group)$/ ); } close( $handle ); # # 4. Open a handle, use binmode # print "4. Open a handle. binmode\n"; open $handle, "-|", "/bin/ls /etc" or die "Failed: $!\n"; binmode( $handle, ":utf8" ); while( my $line = <$handle> ) { print "\t$line" if ( $line =~ /(motd|group)$/ ); } close( $handle ); # # 5. Last ditch # print "5. Last ditch.\n"; open $handle, "-|:utf8", "/bin/ls /etc" or die "Failed: $!\n"; while( my $line = <$handle> ) { print "\t$line" if ( $line =~ /(motd|group)$/ ); } close( $handle );