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)- A3% (1)
- B75% (24)
- C16% (5)
- D6% (2)
Community Discussion
No community discussion yet for this question.