The following updated Code extracts all the
filenames with the data <FileName>-**************
(Filename being âBSCâ,âSBSCSubsystemâ,
âMCBTSSubsystemâ),in the given list of Filenames
in the Input File âbsm1_LogFilesâand place
corresponding appropriate Filenames in the Output
Files created viz. âBSCâ, âSBSCSubsystemâ and
âMCBTSâ, respectively. The below updated Script
gives the appropriate Output when the command
âperl âw Test.plâ is executed from the Root :-
#!/usr/bin/perl -w
use strict;
## Open I/P File "bsm1_LogFiles" for reading.
open(INPUT,'<','bsm1_LogFiles') or die $!;
## Read from the Input File.
my $line = <INPUT>;
## Open the O/P File "BSC" for writing.
open(BSC,'>','BSC') or die $!;
## Open the O/P File "SBSCSubsystem" for writing.
open(SBSCSubsystem,'>','SBSCSubsystem') or die $!;
## Open the O/P File "MCBTSSubsystem" for writing.
open(MCBTSSubsystem,'>','MCBTSSubsystem')or die $!;
## Search each Line in the Input File.
for my $searchline(<INPUT>) {
## Search for parameter 'BSC-'.
if( $searchline =~ /BSC-/) {
## Write to the Output File 'BSC'.
my $line = 'BSC';
print BSC $searchline;
}
## Search for parameter 'SBSCSubsystem-'.
elsif( $searchline =~ /SBSCSubsystem-/) {
## Write to Output File 'SBSCSubsystem'.
my $line = 'SBSCSubsystem';
print SBSCSubsystem $searchline;
}
## Search for parameter 'MCBTSSubsystem-'.
if( $searchline =~ /MCBTSSubsystem-/) {
## Write to Output File 'MCBTSSubsystem'
my $line = 'MCBTSSussystem';
print MCBTSSubsystem $searchline;
}
}
## Close the O/P File "BSC";
close (BSC) or die $!;
## Close the O/P File "SBSCSubsystem";
close (SBSCSubsystem) or die $!;
## Close the O/P File "MCBTSSubsystem";
close (MCBTSSubsystem) or die $!;