On Tue, Jul 08, 2003 at 02:09:38PM -0600, Lance Murray wrote:

> Hello:
>  
> I'm very excited when I discovered the map function, however, I cannot
> seem to get it to do what I want in this instance:
>  
>   chomp (my @strings = `strings *`);
>   my $var;
>   my @ptrRecords = map ((/.*\s+PTR\s+.*/), @strings );   #  <- LINE IN QUESTION
>   foreach (@ptrRecords) { print "$_\n" };
> 
> What I am trying to do is get all PTR records in a DNS BIND directory
> into @ptrRecords, e.g., 
> 
>   What I'm gettingin @ptrRecords (1 = scalar match):
>   1
>   1
>   [...]
>  
>   What I want in @ptrRecords (actual match string):
>   12   PTR ldsslcs_cab4_12.infra.chq.slc.ut.usa.wh.lds.
>   13   PTR ldsslcs_cab4_13.infra.chq.slc.ut.usa.wh.lds.
>   [...]

In this case you actually want grep rather than map.  Look up their
descriptions in perlfunc:

  perldoc -f map
  perldoc -f grep

And you can probably do without the .* at the beginning and end of your
RE.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to