in reply to Perl - pattern matching

if i try to run the script on Windows one it fails
And the fqdn of that Windows host is just one single word, right? Try chomping it like this:
chomp(my $fqdn = `hostname`); # OR, much better: my ($hostname) = `hostname` =~ /([-a-zA-Z0-9]+)/; $hostname=~ tr/A-Z/a-z/;
update: no, ([^.]+) won't do

Replies are listed 'Best First'.
Re^2: Perl - pattern matching
by McA (Priest) on Mar 31, 2014 at 14:08 UTC

    Hi,

    may I suggest to use the following CORE module (even no addon installation necessary):

    use Sys::Hostname; my $hostname = hostname;

    No subprocess is spawned and hopefully all OS dependent aspects considered. IMHO a much better approach.

    best regards
    McA

Re^2: Perl - pattern matching
by fabrizio_start_perl (Novice) on Mar 31, 2014 at 11:48 UTC
    Great now it works ! Thanks a lot ! Fabrizio