Dear me, you can see what those lines do if you let the script run! And if you want to know more, you have to look up the description for example with Shuck, that is the MacPerl built in help function (put the cursor on some function word and press Command+H).
Some description: while (<D_E>) { = reads one line after the other from D_E and delivers them as $_ m' '; = perform a search on $_ .. = find any character (except \n) ..{2} = find 2 of them (.{2}) = read the frist two characters and remember them in $1 (.{7}) = read the next 7 characters an remember them in $2, and so on [^,] = find any character that is not a comma [^,]* = find any number of any character that is not a comma ... ([^,]*),? = ... and remember them as $7; if a comma follows, read and forget it; if not, do not matter (.*) = find the rest of the line and remember it as $8 - - - - - - - - - - Is it that difficult? RTFM means: Read The Fine Manual! You can put the print lines like this: print "$1\t$2\t$3\t$4\t$5\t$6\t$7\t$8\n"; print D_O "$1\t$2\t$3\t$4\t$5\t$6\t$7\t$8\n"; If you want to know how "printf" does function, put the cursor on it and press Command H; AND: PLAY AROUND, and you will find what everything is good for. Good luck, gutes Gelingen! Detlef "Mohanty, Debi (MED, TCS)" wrote: > Hi Detlef, > What does the below two lines does ....... Please help me. > > m'(.{2})(.{7})(.{9})(.{10})([^ ]*)([^,]*),?(?:([^,]*),?)?(.*)'g; > printf "%-3s %-8s %-11s %-11s %-11s %-12s %-12s %-12s %-12s \n", > $1, $2, $3, $4, $5, $6, $7, $8; > > Thanks&Regards > Debi > > > -----Original Message----- > From: Detlef Lindenthal [mailto:detlef@;lindenthal.com] > Sent: Tuesday, October 29, 2002 11:26 AM > To: Mohanty, Debi (MED, TCS) > Subject: Re: [MacPerl-WebCGI] Help in perl formatting a text file > > ### Did you dream of something like this? > > open (D_I, "Input.dat") or die "Not found" ; > open (D_O, ">Output.dat") or die "Cannot write"; > while(<D_I>) { > chomp; > m'(.{2})(.{7})(.{9})(.{10})([^ ]*)([^,]*),?(?:([^,]*),?)?(.*)'g; > printf "%-3s %-8s %-11s %-11s %-11s %-12s %-12s %-12s %-12s \n", > $1, $2, $3, $4, $5, $6, $7, $8; > printf D_O "%-3s %-8s %-11s %-11s %-11s %-12s %-12s %-12s %-12s \n", > $1, $2, $3, $4, $5, $6, $7, $8; > } > > ## What is captured within those (....) in the m' ... ' -line > ## is given back as $1, $2, ... . > ## Adjust those numbers {..} according to your needs. > ## To have the result really tab seperated change the printf line: > ## fill in \t instead of blanks in the " ..... " -part. > ## > ## HTH, Detlef