Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Sending Email to a list of people using Mail::Sender

by mlebel (Hermit)
on Aug 14, 2011 at 00:26 UTC ( [id://920192]=note: print w/replies, xml ) Need Help??


in reply to Sending Email to a list of people using Mail::Sender

Thanks pvaldes and GrandFather, I have tried both of your methods. Both methods lead me to the same error:

syntax error at ./scriptfile line 55, near "if !~"

I should also have mentioned that the $TestFile also contains other options used in the script, which is initially the reason for why i used a foreach loop. here is the code if it helps any:

foreach $Line (<TESTFILE>) { next if ($Line =~ m/^#/); if ($Line =~ m/option1\s*=\s*(.*)/) { $option1 = $1; print "option1 = <$option1>\n"; } if ($Line =~ m/option2\s*=\s*(.*)/) { $option2 = $1; print "option2 = <$option2>\n"; } if ($Line =~ m/option3\s*=\s*(.*)/) { $option3 = $1; print "option3 = <$option3>\n"; } if ($Line =~ m/option4\s*=\s*(.*)/) { $option4 = $1; print "option4 = <$option4>\n"; } # if ($Line =~ m/To\s*=\s*(.*)/) { # $To = $1; # print "To = <$To>\n"; # } if ($Line =~ m/option6\s*=\s*(.*)/) { $option6 = $1; print "option6 = <$option6>\n"; } if ($Line =~ m/option7\s*=\s*(.*)/) { $option7 = $1; print "option7 = <$option7>\n"; } if ($Line =~ m/option8\s*=\s*(.*)/) { $option8 = $1; print "option8 = <$option8>\n"; } } close(TESTFILE);

Replies are listed 'Best First'.
Re^2: Sending Email to a list of people using Mail::Sender
by GrandFather (Saint) on Aug 14, 2011 at 01:49 UTC

    That could be written more succinctly as:

    while (defined (my $Line = <TESTFILE>)) { next if ($Line =~ m/^#/); next if $Line !~ /(option(?:1|2|3|4|6|7))\s*=\s*(.*)/; print "$1 = <$2>\n"; } close (TESTFILE);

    although I doubt very much that the code you have shown so far is your actual code. Maybe if you showed us some real code that you have actually run and that demonstrates the problem you describe.

    True laziness is hard work

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://920192]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-20 16:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found