nerdexam
IBM

C9010-022 · Question #30

Within a Perl script, how can the output of the hostname command be assigned to a variable called myHostname?

The correct answer is B. chomp(myHostname=`hostname -s 2>/dev/null`). See the full explanation below for the reasoning.

Question

Within a Perl script, how can the output of the hostname command be assigned to a variable called myHostname?

Options

  • AchopfmyHostname="hostname -s 2>/dev/null")
  • Bchomp(myHostname=hostname -s 2>/dev/null);
  • C$myHostname=/usr/bin/hostname
  • Dchomp(@myHostname=hostname -s 2>/dev/null');

How the community answered

(32 responses)
  • A
    3% (1)
  • B
    75% (24)
  • C
    16% (5)
  • D
    6% (2)

Community Discussion

No community discussion yet for this question.

Full C9010-022 Practice