[Libguestfs] [PATCH] Lib.pm: Add file_architecture command.
Richard W.M. Jones
rjones at redhat.com
Wed Jul 29 14:18:38 UTC 2009
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
More information about the Libguestfs
mailing list