Hi All,

#!/usr/bin/perl -w use strict; use warnings; ## 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 $!; ## Process input lines into output files. while(<INPUT>) { ## For parameter 'BSC-'. if ( /BSC-/ ) { ## Read a line, copy it, and delete 'BSC-' in the copy. chomp $line; my $copy = $_; $copy =~ s/BSC-//; ## Print the original line and the copy. print BSC "$_ $copy\n"; } ## For parameter 'SBSCSubsystem-'. if ( /SBSCSubsystem-/ ) { ## Read a line, copy it, and delete 'SBSCSubsystem-' in the cop +y. chomp $line; my $copy = $_; $copy =~ s/SBSCSubsystem-//; ## Print the original line and the copy. print SBSCSubsystem "$_ $copy\n"; } ## For parameter 'MCBTSSubsystem-'. if ( /MCBTSSubsystem-/ ) { ## Read a line, copy it, and delete 'MCBTSSubsystem-' in the co +py. chomp $line; my $copy = $_; $copy =~ s/MCBTSSubsystem-//; ## Print the original line and the copy. print MCBTSSubsystem "$_ $copy\n"; } } ## Close the I/P File "bsm1_LogFiles"; close (INPUT) or die $!; ## 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 $!;

1) The above code gives the one of the Output to the File BSC as :-

-rw-rw-rw- 1 bsmbin bsmbin 303 Dec 3 02:06 BSC-20041202143000

-rw-rw-rw- 1 bsmbin bsmbin 303 Dec 3 02:06 20041202143000

-rw-rw-rw- 1 bsmbin bsmbin 303 Dec 3 02:06 BSC-20041202140000

-rw-rw-rw- 1 bsmbin bsmbin 303 Dec 3 02:06 20041202140000

2) What if, I need to get the output to the File BSC as just:-

BSC-20041202143000 20041202143000

BSC-20041202140000 20041202140000

Similar Output for other 2 Files SBSCSubsystem and MCBTSSubsystem. Please let me know.


In reply to Re^11: Sorting names using Regular Expressions and placing them in different Files. by Kiran Kumar K V N
in thread Sorting names using Regular Expressions and placing them in different Files. by Kiran Kumar K V N

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.