in reply to Need Help in Array
outputs (with your data)#! /usr/bin/perl open(FILE,"<file.txt"); my @lines=<FILE>; close(FILE); my $module; my $id; foreach my $line(@lines) { chomp($line); if($line=~ /Module.*/) { $line=~ /:\s*/;$module=$'; } if($line=~ /ID.*/) { $line=~ /:\s*/;$id=$'; } if($line=~ /Customer : yes/i) { print "$module and $id\n"; } }
1 and 001 3 and 003
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Need Help in Array
by GrandFather (Saint) on Jan 03, 2012 at 23:36 UTC |