Advertisement
dev017

my ip in perl :P

Jul 29th, 2023 (edited)
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.30 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. my $ifconfig_output = `ifconfig`;
  7.  
  8. if ($ifconfig_output =~ /inet (\d+\.\d+\.\d+\.\d+)/) {
  9.     my $ip_address = $1;  -- Ip address
  10.     print "IP address: $ip_address\n";
  11. } else {
  12.     print "IP address not found\n";
  13. }
  14.  
  15. -- Your system must have ifconfig.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement