I am extracting the MAC address like so
my @tmp = split / /, "domain (123.123.123.123) at 00:11:22:33:44:55 [ether] on eth0";
my $vip = $tmp[3];
but can it be done without using a temporary variable?
Writing a one-line if-else statement in Python is possible by using the ternary operator, also known as the conditional expression. This works just fine. But you can get the job done by writing the if-else statement as a neat one-liner expression.
Python If Statement In One Line In Python, we can write “if” statements, “if-else” statements and “elif” statements in one line without worrying about the indentation. In Python, it is permissible to write the above block in one line, which is similar to the above block.
Yes it can:
my $vip = (split / /, "domain (123.123.123.123) at 00:11:22:33:44:55 [ether] on eth0")[3];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With