I'm using cat to get content of the file, and then I use regex to get what I want. When I change order of if's in example i put PASSWORD as a second one, IP will be empty.
#!/usr/bin/perl
my $param = $ARGV[0];
my $IP;
my $PASSWORD;
my $MODEM;
my @cat = `cat file`;
foreach my $line (@cat){
if ($line =~ /$param/){
if ($line =~ /MODEM:(\w+)/g){ $MODEM = $1; }
if ($line =~ /IP:((\d{1,3}\.){3}\d{1,3})/g){ $IP = $1; }
if ($line …
Run Code Online (Sandbox Code Playgroud)