Home > Archive > PERL Beginners > July 2007 > how to launch perl
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
how to launch perl
|
|
| john@africanuniversityonline.com 2007-07-20, 7:02 pm |
| Hey Guys,
I am working on linux (redhat) 1999 version without the xwindows.
I have configured my dns server on this linux box and it works fine for my =
test lab network at home. apache and sendmail are also working fine without=
any problem.
I have this huge book called the camel about perl which i have read=20
over ten times before even touching the program perl itself to get the theo=
ry of the whole thing. now when i went to the shell as root
trying to launch perl from #!/usr/bin/perl -wT
nothing seems tobe working, it hangs and doesn't go any further on the next=
line for ever till i kill the process and then it tells me stopped perl. w=
hat is it that i am ding wrong , i need somebody to help me understand how =
to launch this program perl. i know it is installed because the program tel=
ls me everything is o.k when i rpm -q perl.
i even typed in all the example perl cgi scripts that i learned
still nothing, i like working upwards that is why i am using=20
a lower version of linux and then try to move on to the latest
kernels.=20
please let me know what to do .
thanks in advance
john conteh
africanuniversityonline.com
| |
| John W. Krahn 2007-07-20, 7:02 pm |
| john@africanuniversityonline.com wrote:
> Hey Guys,
Hello,
> I am working on linux (redhat) 1999 version without the xwindows.
It's either X or the X Window System.
http://en.wikipedia.org/wiki/X_Window_System
> I have configured my dns server on this linux box and it works fine
> for my test lab network at home. apache and sendmail are also working
> fine without any problem.
> I have this huge book called the camel about perl which i have read
> over ten times before even touching the program perl itself to get the
> theory of the whole thing. now when i went to the shell as root
You shouldn't normally login as root, especially if you are connected to the
internet.
> trying to launch perl from #!/usr/bin/perl -wT
> nothing seems tobe working, it hangs and doesn't go any further on the
> next line for ever till i kill the process and then it tells me stopped
> perl. what is it that i am ding wrong , i need somebody to help me
> understand how to launch this program perl. i know it is installed
> because the program tells me everything is o.k when i rpm -q perl.
> i even typed in all the example perl cgi scripts that i learned
> still nothing, i like working upwards that is why i am using
> a lower version of linux and then try to move on to the latest
> kernels.
> please let me know what to do .
If you are working in a shell from the command line then type 'perl ' and then
the program name or type 'perl -e' and then valid Perl code, for example:
$ cat myprogram
print "Hello John\n";
$ perl myprogram
Hello John
$ perl -e'print "Hello John\n";'
Hello John
$
And if you have your Perl program in a file you can put '#!/usr/bin/perl' on
the *first* line:
$ cat myprogram
#!/usr/bin/perl
print "Hello John\n";
$ ./myprogram
Hello John
There is some more information in the man page:
perldoc perlrun
And also at the web site:
http://learn.perl.org/
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
| |
| Adriano Ferreira 2007-07-20, 7:02 pm |
| On 7/20/07, john@africanuniversityonline.com
<john@africanuniversityonline.com> wrote:
> Hey Guys,
> I am working on linux (redhat) 1999 version without the xwindows.
> I have configured my dns server on this linux box and it works fine for my test lab network at home. apache and sendmail are also working fine without any problem.
> I have this huge book called the camel about perl which i have read
> over ten times before even touching the program perl itself to get the theory of the whole thing. now when i went to the shell as root
> trying to launch perl from #!/usr/bin/perl -wT
> nothing seems tobe working, it hangs and doesn't go any further on the next line for ever till i kill the process and then it tells me stopped perl. what is it that i am ding wrong , i need somebody to help me understand how to launch this program perl.
i know it is installed because the program tells me everything is o.k when i rpm -q perl.
Just adding to what John already said, it hangs because, when used
without arguments like script file names or " -e 'print qq{Hello,
world\n}' ", it expects the script is coming from the standard
input.
So you can do
$ perl -wT
print "Hello, world!\n";
for (1..10) {
print STDOUT ('one','two','three')[$_ % 3];
}
Hello, world!
^D (or something that tells your system the stream is over)
twothreeonetwothreeonetwothreeonetwo
> i even typed in all the example perl cgi scripts that i learned
> still nothing, i like working upwards that is why i am using
> a lower version of linux and then try to move on to the latest
> kernels.
> please let me know what to do .
> thanks in advance
> john conteh
> africanuniversityonline.com
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> http://learn.perl.org/
>
>
>
| |
| Chas Owens 2007-07-20, 7:02 pm |
| On 7/20/07, Adriano Ferreira <a.r.ferreira@gmail.com> wrote:
snip
> Just adding to what John already said, it hangs because, when used
> without arguments like script file names or " -e 'print qq{Hello,
> world\n}' ", it expects the script is coming from the standard
> input.
>
> So you can do
>
> $ perl -wT
>
> print "Hello, world!\n";
>
> for (1..10) {
> print STDOUT ('one','two','three')[$_ % 3];
> }
>
> Hello, world!
>
> ^D (or something that tells your system the stream is over)
>
> twothreeonetwothreeonetwothreeonetwo
snip
There are also some Perl REPLs* out there that allow you to use a Perl
interpreter interactively.
zoidberg, a Perl shell:
http://search.cpan.org/~pardus/Zoid...lib/Zoidberg.pm
psh, another Perl shell: http://sourceforge.net/projects/psh/
Devel::REPL, a modern Perl REPL:
http://search.cpan.org/~mstrout/Dev...b/Devel/REPL.pm
There are probably others out there.
* REPL stands for Read, Eval, Print, Loop.
| |
| Mr. Shawn H. Corey 2007-07-20, 7:02 pm |
| Adriano Ferreira wrote:
> Just adding to what John already said, it hangs because, when used
> without arguments like script file names or " -e 'print qq{Hello,
> world\n}' ", it expects the script is coming from the standard
> input.
Well, actually the OP said he was using '#!/usr/bin/perl -wT' A shell
should interpret this a comment, ignore it, and come back immediately.
I don't understand his comment about the shell hanging. Nothing should
happen.
--
Just my 0.00000002 million dollars worth,
Shawn
"For the things we have to learn before we can do them, we learn by
doing them."
Aristotle
| |
| Mr. Shawn H. Corey 2007-07-20, 7:02 pm |
| Chas Owens wrote:
> There are also some Perl REPLs* out there that allow you to use a Perl
> interpreter interactively.
>
> zoidberg, a Perl shell:
> http://search.cpan.org/~pardus/Zoid...lib/Zoidberg.pm
> psh, another Perl shell: http://sourceforge.net/projects/psh/
> Devel::REPL, a modern Perl REPL:
> http://search.cpan.org/~mstrout/Dev...b/Devel/REPL.pm
>
> There are probably others out there.
>
> * REPL stands for Read, Eval, Print, Loop.
>
Oh, you mean:
perl -ple '$_=eval'
Or on DOS:
perl -ple "$_=eval"
--
Just my 0.00000002 million dollars worth,
Shawn
"For the things we have to learn before we can do them, we learn by
doing them."
Aristotle
| |
| Chas Owens 2007-07-20, 7:02 pm |
| On 7/20/07, Mr. Shawn H. Corey <shawnhcorey@magma.ca> wrote:
> Chas Owens wrote:
>
> Oh, you mean:
>
> perl -ple '$_=eval'
>
> Or on DOS:
>
> perl -ple "$_=eval"
snip
Nope, take a look at this:
cowens@amans:~$ perl -ple '$_=eval'
my $c = 5
5
$c+1
1
Now this:
pugs> my $c = 5
5
pugs> $c + 1
6
The problem is that "my $c = 5" creates a lexical inside the while
loop created by -p and it goes out of scope immediately. Also, REPLs
tend to provide more services (such as command line completion,
command history, ability to save the current buffer, etc.). As you
can see, Perl 6 already has a REPL. Of course, Pugs* is a lot more
than just a REPL, it is also a compiler for the Parrot virtual
machine** and it can interpret the code directly (like perl does
currently).
* http://www.pugscode.com
** http://www.parrotcode.org
| |
| Adriano Ferreira 2007-07-20, 7:02 pm |
| On 7/20/07, Chas Owens <chas.owens@gmail.com> wrote:
> On 7/20/07, Adriano Ferreira <a.r.ferreira@gmail.com> wrote:
> snip
> snip
>
> There are also some Perl REPLs* out there that allow you to use a Perl
> interpreter interactively.
>
> zoidberg, a Perl shell:
> http://search.cpan.org/~pardus/Zoid...lib/Zoidberg.pm
zoidberg is intented to be a shell (like bash, zsh) only that the
command language is Perl. Not exactly a simple REPL.
> psh, another Perl shell: http://sourceforge.net/projects/psh/
> Devel::REPL, a modern Perl REPL:
> http://search.cpan.org/~mstrout/Dev...b/Devel/REPL.pm
The modernity of Devel::REPL is at using state-of-art Perl OO like
Moose and being extendable. Beyond that, this modernity means today
some 5 seconds to start the interactive interpreter ;-)
$ re.pl
(5 seconds later, your prompt:)
$
>
> There are probably others out there.
I am one of the contenders here, having written Shell::Perl
http://search.cpan.org/dist/Shell-Perl/
which needs severely more work to be a really decent REPL. But for
now, it works (if you accept its limitations)
> * REPL stands for Read, Eval, Print, Loop.
>
Cheers,
Adriano Ferreira
| |
| Mr. Shawn H. Corey 2007-07-20, 7:02 pm |
| Chas Owens wrote:
> The problem is that "my $c = 5" creates a lexical inside the while
> loop created by -p and it goes out of scope immediately.
Yes, that's what 'my' means. If you do it without the 'my', it works.
And it has a lot of security problems. But it's also quick and easy to
remember. Like any tool, it cannot be used to solve all your problems.
--
Just my 0.00000002 million dollars worth,
Shawn
"For the things we have to learn before we can do them, we learn by
doing them."
Aristotle
| |
| Chas Owens 2007-07-20, 7:02 pm |
| On 7/20/07, Mr. Shawn H. Corey <shawnhcorey@magma.ca> wrote:
> Chas Owens wrote:
>
> Yes, that's what 'my' means. If you do it without the 'my', it works.
> And it has a lot of security problems. But it's also quick and easy to
> remember. Like any tool, it cannot be used to solve all your problems.
Yes, but that is not what a good REPL should do with it. Take a look
at the pugs example again. The problem is that you are executing my
code in your context. My code should be evaluated in a separate
context. There should be no difference between
perl -e '
my $n = 5;
$n++;
print "$n\n";
'
and
mythical_perl_repl
> my $n = 5
5
> $n++
5
> print "$n\n"
6
1
(note: 1 is what print would return).
In fact, here is an example using pugs:
cowens@amans:~$ cat t.p6
my $c = 5;
$c++;
say $c;
cowens@amans:~$ pugs t.p6
6
cowens@amans:~$ pugs
______
/\ __ \
\ \ \/\ \ __ __ ______ ______ (P)erl6
\ \ __//\ \/\ \/\ __ \/\ ___\ (U)ser's
\ \ \/ \ \ \_\ \ \ \/\ \ \___ \ (G)olfing
\ \__\ \ \____/\ \____ \/\_____\ (S)ystem
\/__/ \/___/ \/___/\ \/____/
/\____/ Version: 6.2.13
\/___/ Copyright 2005-2006, The Pugs Contributors
--------------------------------------------------------------------
Web: http://pugscode.org/ Email: perl6-compiler@perl.org
Welcome to Pugs -- Perl6 User's Golfing System
Type :h for help.
Loading Prelude... done.
pugs> my $c = 5
5
pugs> $c++
5
pugs> say $c
6
Bool::True
pugs>
| |
| Mr. Shawn H. Corey 2007-07-20, 9:59 pm |
| Chas Owens wrote:
> Yes, but that is not what a good REPL should do with it. Take a look
> at the pugs example again. The problem is that you are executing my
> code in your context. My code should be evaluated in a separate
> context. There should be no difference between
No, I am executing my code in my context. Neither your REPL or my
little Perl command can replace a well thought out Perl program.
--
Just my 0.00000002 million dollars worth,
Shawn
"For the things we have to learn before we can do them, we learn by
doing them."
Aristotle
| |
| Chas Owens 2007-07-21, 3:59 am |
| On 7/20/07, Mr. Shawn H. Corey <shawnhcorey@magma.ca> wrote:
> Chas Owens wrote:
snip[color=darkred]
> No, I am executing my code in my context. Neither your REPL or my
> little Perl command can replace a well thought out Perl program.
snip
You fail to understand what a REPL is for. A REPL is for learning and
playing with a language. Some people also use them as a debugging or
prototyping environment*. It isn't supposed to be a well thought out
program, well the REPL is, but the stuff the user types into it isn't.
*Lisp and Scheme people actually use them as editors.
| |
| Mr. Shawn H. Corey 2007-07-21, 3:59 am |
| Chas Owens wrote:
> *Lisp and Scheme people actually use them as editors.
OK, you just scare the Hel out of me. You're one of those people who
think everyone should write programs that write programs that do real work.
Do not want.
--
Just my 0.00000002 million dollars worth,
Shawn
"For the things we have to learn before we can do them, we learn by
doing them."
Aristotle
| |
| Chas Owens 2007-07-21, 3:59 am |
| On 7/20/07, Mr. Shawn H. Corey <shawnhcorey@magma.ca> wrote:
> Chas Owens wrote:
>
> OK, you just scare the Hel out of me. You're one of those people who
> think everyone should write programs that write programs that do real work.
>
> Do not want.
snip
I think that but north-north-west: when the wind is southerly I know a
hawk from a handsaw.
In general, I write programs that do stuff directly, and I like Perl
more than I like Lisp, but the lure of writing programs to write
programs and DSLs* is strong.
* Domain Specific Languages
|
|
|
|
|