deelinux has asked for the wisdom of the Perl Monks concerning the following question:
Hi I'm try in to check a number of ports against the etc/services file.
I have created an array of various ports
@myports qw( 21 22 23) open SERVICES_FILE, "<", "/etc/services" or die $!; foreach my $port (@myports) { print $port; } while (my @lines = <SERVICES_FILE>) { for my $line (@lines){ if ( my $port =~ m/$line/ ) { print "Match Found: $line"; } } } }
But Im getting errors
Use of uninitialized value $port in pattern match (m//) at ./get_services.pl line 48, <SERVICES_FILE> line 10774. Unknown verb pattern '' in regex; marked by <-- HERE in m/exp1 1021/tcp # RFC3692-style Experiment 1 (*) <-- HERE RFC4727 / at ./get_services.pl line 48, <SERVICES_FILE> line 10774.
any pointers for a newbie
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Port check - Services File
by stevieb (Canon) on Dec 02, 2015 at 16:39 UTC | |
|
Re: Port check - Services File
by hippo (Archbishop) on Dec 02, 2015 at 15:37 UTC | |
by deelinux (Novice) on Dec 02, 2015 at 15:59 UTC | |
|
Re: Port check - Services File
by 1nickt (Canon) on Dec 02, 2015 at 15:28 UTC | |
by deelinux (Novice) on Dec 02, 2015 at 15:58 UTC |