Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Perl - pattern matching

by hazylife (Monk)
on Mar 31, 2014 at 11:36 UTC ( [id://1080388]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1080388]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-20 00:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found