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);
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|