in reply to understanding scope and () and {}

The OP with formatting:

#!/usr/local/bin/perl -w use Email::Sender::Simple qw(sendmail); use Email::Simple; use Email::Simple::Creator; open (IN, 'top.log'); $input=<IN>; print $input; $lngth=length($input); print $lngth; $load = substr($input,16,4); print $load; $value=.1 if ($load > $value) { # print "$load greater than $value"; my $email = Email::Simple->create( header => [ To => '"Hardy Cherry" <hcherry@youngliving.com>', From => '"Hardy Cherry" <hcherry@youngliving.com>', Subject => "Load g", ], body => "$load greater than $value.\n", ); sendmail($email); }
"my" variable $email masks earlier declaration in same scope at hcshor +t.pl line 26. syntax error at hcshort.pl line 15, near ") {" syntax error at hcshort.pl line 28, near "}" Execution of hcshort.pl aborted due to compilation errors.

I intend to use sendmail more than once but I'm a newbie in perl so I don't understand why I'm getting a syntax error and why the ()and {} seem to be ignored.

The problems stem from the missing semicolon after "$value=.1". Perl is seeing the following (which is perfectly legitimate):

$value=.1 if ($load > $value)

That can't be followed by an opening brace, so Perl gives a syntax error 'near ") {"'. Been there, done that.