#!/usr/bin/perl
$command="lscpu | grep -i Architecture";
#$arch = system($command);
@SplitArch = split(/:/, system($command));
print @SplitArch[1];
The result I get is:
Architecture: x86_64
I was hoping that the only thing that would display is:
x86_64
This doesn’t do what you think it does. The
systemfunction runs the command and returns its exit status; so in your case, this:prints
Architecture: x86_64, so this:prints
Architecture: x86_64and sets@SplitArchto(0).print @SplitArch[1]then prints nothing, because@SplitArchhas only one element. (By the way, you probably meant to write$SplitArch[1]rather than@SplitArch[1], but that’s neither here nor there.)Since you apparently intend to capture the output of
$command, use`...`orqx/.../instead: