HTTP-404 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Guys just installed ActivePerl 5.6.1.630, and when i tried to execute any of my scripts i was getting errors, so decided to make a simple test script:
echo "test";
And i keep getting this error:
String found where operator expected at C:\Dev\test.pl line 1, near "e +cho "test" " (Do you need to predeclare echo?) syntax error at C:\Dev\test.pl line 1, near "echo "test"" Execution of C:\Dev\test.pl aborted due to compilation errors.
Thank You very much

Replies are listed 'Best First'.
Re: ActivePerl 5.6.1.630 - echo problem
by broquaint (Abbot) on Nov 09, 2001 at 20:53 UTC
    I think you may have been brainwashed by PHP as echo isn't in Perl, you'll be wanting print.

    The error is caused by perl guessing that echo is a function, and since it's behaviour isn't defined (i.e no function defintion) it croaks.
    HTH

    broquaint

Re: ActivePerl 5.6.1.630 - echo problem
by thunders (Priest) on Nov 10, 2001 at 01:41 UTC
    You can put this sub in all of your scripts
    sub echo{ my $echo = join "", @_; print $echo; }
    Should clear up that problem.
    Seriously, print does every thing that php's print and echo do put together, multiple arguments, here docs, variable interpolation. Even the nearly useless return value.
    see perldoc -f print