perl remove data from array with field separator -
i have following perl script.
#!/usr/bin/perl -w use strict; use warnings; (@failhost); %currblocked; %addblocked; $action; open (myinputfile, "/var/log/asterisk/messages") or die "\n", $!, "does log file file exist\?\n\n"; while (<myinputfile>) { ($line) = $_; chomp($line); if ($line =~ m/\' failed \'(.*?)\' - no matching peer found/) { push(@failhost,$1); } if ($line =~ m/\' failed \'(.*?)\' . wrong password/) { push(@failhost,$1); print $1 . "\n"; } } exit 0;
this produces following results.
212.83.134.244:5065 212.83.134.244:5063 212.83.134.244:5092 212.83.134.244:5109 212.83.134.244:5080 212.83.134.244:5110 212.83.134.244:5096 212.83.134.244:5093 212.83.134.244:5089 212.83.134.244:5073 212.83.134.244:5101 212.83.134.244:5072 212.83.134.244:5092 212.83.134.244:5094 212.83.134.244:5076 212.83.134.244:5080 212.83.134.244:5081 212.83.134.244:5094 212.83.134.244:5077 212.83.134.244:5096 212.83.134.244:5069 212.83.134.244:5097 212.83.134.244:5101
i want remove ports numbers including ":", want retain ip address.
desired result
212.83.134.244 212.83.134.244 212.83.134.244 212.83.134.244 212.83.134.244 212.83.134.244 212.83.134.244 212.83.134.244 212.83.134.244 212.83.134.244 212.83.134.244
i appreciate if 1 can guide me, or show me how this?
thanks in advance.
modify second if this
if ($line =~ m/\' failed \'([^:]*):\d+\' . wrong password/) {
Comments
Post a Comment