in reply to Re^4: pulling more data from an array
in thread pulling more data from an array
I copied your Data::Dumper output and filtering loop in to the following code:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $VAR1 = [ 'snmp-server host 10.234.171.38 abcd snmp-server host 10.234.171.39 abcd snmp-server host 10.234.171.40 abcd !snmp-server host 10.10.10.1 xyz !' ]; my $result_1; for (split /(?<=\n)/, $VAR1->[0]) { next unless /^\Qsnmp-server host\E/; $result_1 .= $_; } print "---Result 1---\n$result_1\n\n";
which gives me the result
---Result 1--- snmp-server host 10.234.171.38 abcd snmp-server host 10.234.171.39 abcd snmp-server host 10.234.171.40 abcd
Does this match your expectation?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: pulling more data from an array
by zonevbkr (Initiate) on Aug 05, 2010 at 22:33 UTC | |
by kennethk (Abbot) on Aug 05, 2010 at 22:39 UTC |