in reply to Help for generating multiple file from singl e file and parsing it.

update:
#!usr/bin/perl -w use strict; use Data::Dump qw(pp); my %data; foreach (<DATA>) { next if (/^\s*$/); #skip blank lines my ($str, $date) = m/^#RD(.+)?#OE.+?(\d+)/; push @{$data{"$str"."txt"}},"OE#$date"; } print pp \%data; =Prints { "#,3004,,,,,N,MANS.20111011.2,txt" => ["OE#284110217106"], "#,3023,,,,,N,MANS.20111011.2,txt" => ["OE#284110161544", "OE#284110 +161544"], } =cut __DATA__ #RD#,3023,,,,,N,MANS.20111011.2,#OE#,CR,N,284110161544,,Y,MANS,2011101 +1064839000,20111011~1M9LQV49HM #RD#,3023,,,,,N,MANS.20111011.2,#OE#,CR,N,284110161544,,Y,MANS,2011101 +1064839000,20111011~1M9LQV49HM,20111011064925000,20111011~1M9LQV49Ho, +,,20111011064925000 #RD#,3004,,,,,N,MANS.20111011.2,#OE#,RT,N,284110217106,,Y,MANS,2011101 +1065244000,20111011~1J6Q7ETYXH,,20111011~1J6Q7ETYXH,NVMI,201110110652 +44000,2324,E
  • Comment on Re: Help for generating multiple file from singl e file and parsing it.
  • Download Code

Replies are listed 'Best First'.
Re^2: Help for generating multiple file from singl e file and parsing it.
by sarf13 (Beadle) on Oct 16, 2011 at 04:47 UTC
    thank you very for you reply.
    while ia m running this code it is giving me some error which is
    Use of uninitialized value $str in string at test2.pl line 13, <DATA> line 8968. Use of uninitialized value $date in concatenation (.) or string at test2.pl line 13, <DATA> line 8968. Use of uninitialized value $str in string at test2.pl line 13, <DATA> line 8968. Use of uninitialized value $date in concatenation (.) or string at test2.pl line
    i am not able to understand.
      what you describe would be a symptom of say a blank line at the end of the DATA section although I'm not sure how you get to line 8968! The code should skip blank lines and this shouldn't matter.

      I just ran the code here again. Download and run it verbatim.

        Hi Marshall thank you very much for help me out. now it working perfectly.
        i have one more issue can you please guide me for writing a reguler expression for substitution.
        i have this pattern :- 3023NMANS.20111011.2 as a value of hash where starting no (3023) and last no (.20111011.2) will be change and NMANS wil be constant.i need to write reguler expression for substituting this pattern with nothing.
        i really appreciate for your help.