Hi monks, I seem to be having a problem with scalar. "Not enough arguments for scalar at a18.pl line 25, near "scalar;" Execution of a18.pl aborted due to compilation errors."
#!/usr/bin/perl use Modern::Perl; use strict; system 'clear'; my@array; my $counter=0; my $total=0; open FILE,'testFile.txt'; while (<FILE>) { chomp; $array[$counter]=$_; $total +=$_; $counter++ } close (FILE); foreach my $scalar(@array) { $total+=scalar; } printf("\nThe total of the numbers in testfile.txt is %d.\n\n",$total) +; my($add,$sub,$div,$mul,$mod)=0; $add=$array[0] +$array[1]; $sub=$array[0] -$array[3]; $div=$array[5]/$array[1]; $mul=$array[0]*$array[1]*$array[2]*$array[3]*$array[5]*$array[4]; $mod=$array[4]%$array[2]; print "ADD:$add\n"; print "SUB:$sub\n"; print "DIV:$div\n"; print "MUL:$mul\n"; print "MOD:$mod\n"; print ("The answer to 3%5+\(12/4\)-10/5*-3 is".(($array[0] %$array[1]) + +($array[2]/$array[4])-$array[5]/$array[1]*($array[3]))."\n"); open FILE2,'output.txt'; print FILE2 "ADD:$add\n"; print FILE2 "SUB:$sub\n"; print FILE2 "DIV:$div\n"; print FILE2 "MUL:$mul\n"; print FILE2 "MOD:$mod\n"; print FILE2 ("The answer to 3%5+\(12/4\)-10/5*-3 is".(($array[0]%$arra +y[1]) + ($array[2]/$array[4])-$array[5]/$array[1]*($array[3]))."\n"); close (FILE2); print"\nThe Program has terminated. data has been saved to output.txt\ +n\n"; ~

In reply to Update: problem with scalar by sargg55

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.