in reply to "Use strict" and "Use warnings" not working

Perl isn't like bash, ksh, tcsh, zsh, etc. Those are all shells that interpret one command at a time, allow for interactive use (which is pretty easy since there is no pre-compiling done), etc. Perl isn't a shell -- it's strictly a scripting language, there is a bunch of preprocessing and compiling done before actually running the script, etc.

So you either have to use perl's command line switch to run code from the command line like so:

perl -e 'your code goes here' perl -E 'your code goes here' # This enables Perl 5.10 features

Or you have to create a Perl script as toolic and Davido have already mentioned. For example:

#!/usr/bin/perl use feature ":5.10"; # Use all new features in Perl 5.10 use strict; use warnings; # Your code goes here here

Elda Taluta; Sarks Sark; Ark Arks

Replies are listed 'Best First'.
Re^2: "Use strict" and "Use warnings" not working
by choroba (Cardinal) on Jun 03, 2010 at 20:36 UTC
    Well, you can enter your script right ahead from the command line, but with no chance to edit previous lines:
    $ perl print "Hello world\n"; ^D Hello world $
      That's getting really nitpicky!! :-) It certainly doesn't offer the typical UNIX shell-like experience the OP seemed to expect. And the commands are not interpreted line by line.

      Elda Taluta; Sarks Sark; Ark Arks