Dermot schreef:

> #!/bin/perl
> 
> use strict;
> use warnings;
> 
> my @luns;
> while (<DATA>) {
>     chomp;

Why chomp?


>     next unless $_ =~ /LUN/;
>     $_ =~ /\[(LUN\s+\d+)\]/;

There is no need to mention $_ in  those lines. 
(I don't think it is bad that you do, but I wouldn't.) 

$1 can remain undefined. Rob already showed how to combine them. 


>     print $1,"\n";
>     push(@luns,$1);

I think such code looks clearer like this:

     print $1, "\n";
     push @luns, $1;

(a bit more whitespace, no () with builtins) 

> }


Some extremish alternatives:

#!/usr/bin/perl -l
  use strict;
  use warnings;

  print for map m/\[(LUN\s+[0-9]+)\]/ ? $1 : (), <>;


#!/usr/bin/perl -wn
  print "$1\n" if m/\[(LUN\s+[0-9]+)\]/;


#!/usr/bin/perl -wnl
  print $1 if m/\[(LUN\s+[0-9]+)\]/;

(the last one does chomp)

-- 
Affijn, Ruud

"Gewoon is een tijger."

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to