[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [PATCH] Lib.pm: Add file_architecture command.



On Wed, Jul 29, 2009 at 08:56:19AM -0400, Aron Griffis wrote:
> Richard W.M. Jones wrote:  [Tue Jul 28 2009, 02:03:03PM EDT]
> > +	foreach my $bin (@_initrd_binaries) {
> > +	    if (-f "$dir/bin/$bin") {
> > +		open PIPE, "file $dir/bin/$bin |";
> > +		local $/ = undef;
> > +		$_ = <PIPE>;
> > +		if (/ELF.*executable, (.+?),/) {
> > +		    return _elf_arch_to_canonical ($1);
> > +		}
> > +	    }
> > +	}
> 
> It might be (ever so) slightly better here to use Perl's backtick
> operator to slurp the output rather than declaring $/ local prior
> to calling a function in the same block:
> 
> 	foreach my $bin (@_initrd_binaries) {
> 	    if (-f "$dir/bin/$bin") {
>                 $_ = `file $dir/bin/$bin`;
> 		if (/ELF.*executable, (.+?),/) {
> 		    return _elf_arch_to_canonical ($1);
> 		}
> 	    }
> 	}

Yup, this is better, or even putting local $/ part into its
own block:

{ local $/ = undef; $_ = <PIPE>; }

I'll rustle up a fix.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]