Welcome,
2008/6/24 jet speed <[EMAIL PROTECTED]>: > Hi, > > I am beginner to perl, > > I have a file name cxout and i want to capture just the LUN 415, LUN 815 > into arrray & then print from the array. my idea is to capture different > element form this file and the print form the array. Any help would be much > appericated. my sample script looks as below. > > > $filename = "cxout" ; > open (FILE, "< $filename" ) or die "Could not open $filename: $!"; > > while (<FILE>) { > if ( $line = (/\^LUN \d+/) ) { > print $line ; > }; > }; > > ------------------------------------------------------------------------------------- ...snip This appears to do the job. There may be better ways to do it. In particualar I think a hash might be better here but this should get you going. #!/bin/perl use strict; use warnings; my @luns; while (<DATA>) { chomp; next unless $_ =~ /LUN/; $_ =~ /\[(LUN\s+\d+)\]/; print $1,"\n"; push(@luns,$1); } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/