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

Aron Griffis aron.griffis at hp.com
Wed Jul 29 12:56:19 UTC 2009


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);
		}
	    }
	}

Having read through the rest of the code, that's the only thing
I could find to comment on... :-)

Regards,
Aron




More information about the Libguestfs mailing list