help with qx?

Andy Armstrong andy at hexten.net
Wed Feb 6 01:06:15 GMT 2008


On 6 Feb 2008, at 00:39, Iain Barnett wrote:

> Hello all,
>
> Sorry for not mailing to kick the crap out of Perl5/6/MVC/Catalyst/ 
> Maypole/Jifty/Mornington Crescent/other mongers..., but I have a  
> small technical question to ask and a room full of perl sceptics  
> (a.k.a C# developers) waiting for a script to cure their build  
> process!
>
> The script has a system call (to the svn command-line client), and  
> it could possibly return a lot of lines back so I don't want to  
> store it in an array, but process it as it's coming through. Is  
> there a way to force qx or `` into list context, or something  
> equally helpful?
>
> e.g
>
> while( list qx($command) ) {
> 	do stuff...
> }
>
>
> Any help is much appreciated!


my @cmd = ( 'svn', 'up', '-r', $rev );
open my $ch, '-|', @cmd or die "Oops";
while ( defined ( my $line = <$ch> ) ) {
     chomp $line; # or whatever
}
close $ch or die "Another oops";

The check on whether close succeeeded is important. Any error may not  
be detected until then.

-- 
Andy Armstrong, Hexten






More information about the london.pm mailing list