tom poe wrote: > Hi: I really appreciate the input on separating $header and $body from those > on the list so far. The suggested modules all seem too complicated to me, so > I continue to read Chapter One, over and over. In the meantime, I think I > have something close to what I want to accomplish, but it still prints out > the entire email, both $header and $body. > > My file that I'm using has the first five lines as $header, followed by 2 > blank lines. The rest of the lines are the email message. When I run the > script: > #! /usr/local/bin/perl -w > > # Simple program to prepare an email message for entry into a database > # This program simply discards header information, and collects message > # body into an array. Once in the array it should print out just the > # message body. > use strict; > my $file = '../perlStuff/email.txt'; > my @body; > open (IN, "<$file") or die "Can't open $file: !$\n"; > while (<IN>) { > # Skip lines unless we have a blank line > next unless /^\s*?/;
This line is not doing what you expect of it. '*' matches 0 or more, this example should clear it my $var = "abcd"; print "matches\n" if ($var =~ m/^\s*?/); This prints "matches", the 0 spaces at the start matches '\s*', you need m/^\s+ to match 1 or more. > > > # Put the data line in an array. > push @body, $_; > > my $string = join "", @body; > > print @body; > } > close IN; > ---------------- > it prints out all 20 lines. I had hoped it would ignore the first five > lines, and start entering the next 15 lines, beginning with the two blank > lines. So, any help appreciated. > Thanks, > Tom > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]