in reply to Re^10: Sorting names using Regular Expressions and placing them in different Files.
in thread Sorting names using Regular Expressions and placing them in different Files.

This node falls below the community's minimum standard of quality and will not be displayed.
  • Comment on Re^11: Sorting names using Regular Expressions and placing them in different Files.
  • Download Code

Replies are listed 'Best First'.
Re^12: Sorting names using Regular Expressions and placing them in different Files.
by talexb (Chancellor) on Jan 09, 2007 at 13:31 UTC

    What have you tried? Can you make a guess?

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re^12: Sorting names using Regular Expressions and placing them in different Files.
by talexb (Chancellor) on Jan 09, 2007 at 14:23 UTC

    Kiran,

    Here's what you want ..

    #!/usr/bin/perl -w use strict; # Filter specific strings from an input file into specific # files. { # Open input and output files. open ( INPUT, '<', 'html_LogFiles' ) or die "Unable to open input file: $!"; open ( BSC, '>', 'BSC' ) or die "Unable to open BSC: $!"; open ( SBSCSubsystem, '>', 'BSC' ) or die "Unable to open SBSCSubsystem: $!"; open ( MCBTSSubsystem, '>', 'BSC' ) or die "Unable to open MCBTSSubsystem: $!"; # Process input lines into output files. Note that # an input line may match more than one pattern and # therefore may appear in more than one output # file. while(<INPUT>) { # This breaks the incoming line into the part before # the pattern, the pattern itself, and after the # pattern. We then output the last two parts, # followed by the last part. This effectively # truncates the first part. if ( /^(.+)(BSC-)(.+)$/ ) { print BSC "$2$3 $3\n"; } if ( /^(.+)(SBSCSubsystem-)(.+)$/ ) { print SBSCSubsystem "$2$3 $3\n"; } if ( /^(.+)(MCBTSSubsystem-)(.+)$/ ) { print MCBTSSubsystem "$2$3 $3\n"; } } # Close input and output files. close ( INPUT ); close ( BSC ); close ( SBSCSubsystem ); close ( MCBTSSubsystem ); }

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds