FAQ
I was a little quick on the h2ph as possible solution as I ran it and was
still able to generate the error. However, the following does not generate
the error;

use Sys::Hostname;
$host = hostname;
print "$host\n";
system("/bin/date");

and produces the output as expected.

use Sys::Hostname ();
BEGIN { $hn = Sys::Hostname::hostname(); }
BEGIN { $^W=1; } # or perl -w
print "$hn\n";
system("/bin/date");

is the original example.

Now, if I change the original snippet to

#!/usr/local/bin/perl -w

use Sys::Hostname ();
$hn = Sys::Hostname::hostname();
print "$hn\n";
system("/bin/date");

it works without the warning.

as does

#!/usr/local/bin/perl -w

use Sys::Hostname();
BEGIN { $hn = Sys::Hostname::hostname();
print "$hn\n";
system("/bin/date");
}

This strikes me as odd, but I imagine I'm missing something here.

e.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 6 | next ›
Discussion Overview
groupperl5-porters @
categoriesperl
postedOct 6, '99 at 12:49a
activeOct 7, '99 at 3:38p
posts6
users4
websiteperl.org

People

Translate

site design / logo © 2021 Grokbase