lundi 30 juillet 2018

Perl return if statment vriable

How can i do something like that: I want return IP server from if statment, where i sign if to variable. It is possible?

#!/usr/bin/env perl
#

use warnings;
use strict;

my $variable1 = "10.12.1.1";
my $variable2 = "10.12.1.2";

my $string = $ARGV[0];

my $serveris=>(if ($string =~ m/^[abcdefghijklm]/) {
            print " $variable1 \n"
} else {
            print " $variable2 \n"
})


print $serveris

Aucun commentaire:

Enregistrer un commentaire