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

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



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


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