=head1 NAME
Pugs::Doc::Run - How to run Pugs
=head1 SYNOPSYS
B<pugs> S<[ B<-h> ]> S<[ B<-v> ]>
S<[ B<-V>[:I<configvar>] ]>
S<[ B<-c> [I<file>] ]>
S<[ B<-C>I<backend> [I<file>] ]>
S<[ B<-B>I<backend> [I<file>] ]>
S<[ B<-M>I<module> ]>
S<[ B<--external> [I<file>] ] >
S<[ B<-e> I<program> ]>
=head1 DESCRIPTION
The normal way to run a Perl program is by making it directly executable, or
else
by passing the name of the source file as an argument on the command line.
An interactive Pugs environment is also available
when
B<pugs> is started
with
no
program source. Upon startup, Pugs looks
for
your program in one of the
following places:
WRITEME
=head2 Command line options
You can pass various command line options to Pugs.
=over
=item C<-e I<program>>
causes Pugs to not look
for
any program files in the command line options, but
instead run the one-line program specified. Multiple C<-e> commands work too.
=item C<-n>
causes Pugs to assume the following loop
around
your program, which makes it
iterate over filename arguments somewhat like sed -n or awk:
while
=<> {
...your program here...
}
=item C<-p>
causes Pugs to assume the following loop
around
your program, which makes it
iterate over filename arguments somewhat like sed:
while
=<> {
...your program here...
say
;
}
=item C<-c>
causes Pugs to not run the program, but merely check its syntax.
Note that C<BEGIN {...}> and C<CHECK {...}> blocks, as well as C<
use
Module>,
are still executed, because these might change the grammar or create new
operators, etc. So the following is B<not> safe:
pugs -c
'BEGIN { system "evil command" }'
If you want to run a potentially unsafe program safely, see the safemode Pugs
provides.
=item C<-BI<backend>>
causes Pugs to execute the program using C<I<backend>>. Currently, valid
backends are C<PIR> (execution via Parrot), C<JS> (JavaScript), and C<Pugs>.
To start the interactive shell of a backend, run C<pugs -BI<backend>>, but note
that currently only the Perl 5 and JavaScript backends provide interactive
shells.
The normal runcore supports more features than the other runcores, the Parrot
backend is quite fast, the JavaScript backend is good on binding and
references, and Perl 6 on Perl 5 offers excellent support
for
laziness.
=item C<-CI<backend>>
causes Pugs to compile the program using C<I<backend>>. Currently, valid
backends are C<Pugs>, C<PIR>, C<GHC>, C<JS>, and various variants of PIL:
C<PIL1>, C<PIL1-Binary>, C<PIL1-JSON>, C<PIL1-Perl5> (and C<PIL2-...>).
Note that, as
with
C<-c>, C<BEGIN {...}> and C<CHECK {...}> blocks, as well as
C<
use
Module> statements, are still executed. So don't
try
to compile
potentially unsafe code!
=item C<-MI<module>>
causes Pugs to load C<I<module>>
before
executing your program:
...your code here...
=item C<-h> or C<--help>
displays a short summary of the available command line options. No programs are
executed.
=item C<-V>
displays the version of Pugs you're running and long configuration information.
=item C<-V:I<item>>
displays short configuration information
for
C<I<item>>.
$ pugs -V:pugs_versnum
pugs_versnum: 6.2.6
=item C<-v> or C<--version>
displays the version of Pugs you're running.
=item C<-l>, C<-d>, and C<-w>
are ignored
for
compatibility
with
Perl 5.
=back
=head1 ENVIRONMENT
The Pugs runtime environment is affected by several environment variables.
The build environment is likewise controlled by several environment variables;
since Pugs is still in heavy development, they are listed here as well.
=over
=item C<HARNESS_PERL> [BUILD]
This does not affect C<pugs> itself at all. When building Pugs from source, the
Perl 5 test
system
should be instructed to
use
your copy of Pugs. If you
use
C<make test> or C<make smoke>, you should not need to set this manually; but
if
you want to
use
C<prove>, set it to C<./pugs> (or C<pugs.exe> on Windows).
=item C<PERL6LIB>
A list of directories in which to look
for
Perl library files
before
looking in
the standard library and the current directory. Any architecture-specific
directories under the specified locations are automatically included
if
they
exist. If C<PERL6LIB> is not
defined
, C<PERLLIB> is used.
Directories are separated (as in C<PATH>) by a colon on unixish platforms and
by a semicolon on Windows (the proper path separator being
given
by the command
C<pugs -V:path_sep>).
When building your own pugs, set C<PERL6LIB> to C<blib6/lib> to make tests
use
the correct version of the libraries. C<make test> and C<make smoke> should
do
this
for
you.
=item C<PERLLIB>
A list of directories in which to look
for
Perl library files
before
looking in the standard library and the current directory. Not consulted
if
C<PERL6LIB> is
defined
. See C<PERL6LIB>
for
details on paths.
=item C<PUGS_BYPASS_PRELUDE>
Many Perl subroutines are provided to Pugs by a library called the Standard
Prelude, which is inlined into the pugs executable and loaded by
default
on
each
startup of pugs. If C<PUGS_BYPASS_PRELUDE> is set to anything except C<
""
>
or C<
"0"
>, then pugs will not load the Prelude automatically. This gives a
minor speedup on startup, as well as allowing you to load your alternate
version of F<Prelude.pm> like this:
$ env PUGS_BYPASS_PRELUDE=1 pugs -MPrelude -e
'...'
=item C<PUGS_COMPILE_PRELUDE>
By
default
, the Prelude is not compiled in
when
compiling a Perl program
instead of running it. If you set C<PUGS_COMPILE_PRELUDE> to C<true>, you
override
this
default
and the Prelude will be compiled along
with
your code.
This is normally not needed, as the prelude should already be provided as
part of the target runtime environment.
=item C<PUGS_SAFEMODE>
Pugs provides a global
"safe mode"
which makes many operations that are deemed
"unsafe"
-- e.g. operations which
use
IO -- unavailable to a Perl program.
$ env PUGS_SAFEMODE=1 pugs -e
'unlink "foo"'
*** No compatible subroutine found:
"&unlink"
at -e line 1, column 1-13
=item C<PUGS_PARROT_OPTS>
If you haven't embedded Parrot in your Pugs build, Pugs will start an external
Parrot
if
needed. You can set additional options Pugs should pass to parrot:
$ env PUGS_PARROT_OPTS=
"-j"
pugs -e
'eval("...", :lang<PIR>)'
If C<PUGS_PARROT_OPTS> is not set, C<-C> will be passed to parrot, selecting
the computed
goto
core.
=item C<PUGS_SMOKE_UPLOAD> [BUILD]
If set, F<util/run-smoke.pl> (C<make smoke>) uses this to upload your smoke
tests results automatically. Set this to a command to run, e.g.
rsync -avz smoke.html perlcabal.org:public_html
You may alternatively set the C<smoke_upload> option in C<config.yml> to
have smokes uploaded to the public smokeserver automatically.
=item C<PUGS_TESTS_CONCURRENT> [BUILD]
Smoke tests can take quite some
time
to complete. If you have a
multiprocessor machine, you can set this to a small integer value, and
F<util/yaml_harness.pl> will run that amount of tests in parallel.
On a single-processor, HyperThreaded machine that is otherwise unused,
C<2> is a good value. On real multiprocessor machines, one more than the
CPU count is suggested.
This is equivalent to running C<< util/yaml_harness.pl -j I<number> >>.
(Has
no
effect on Windows.)
=item C<PUGS_BUILD_CONFIG> [BUILD]
If set, the file specified in C<PUGS_BUILD_CONFIG> will be used as
configuration file. The
default
is F<config.yml>.
=back
=head1 SEE ALSO
L<Perl6::Pugs>, L<Pugs::Doc::Hack>