Perldoc Search: "$0" perl-5.20.1

search official POD


13 PODs, 53 LINEs found.
perlopentut.pod
50 :             || die "$0: can't open $filename for reading: $!";
89 :             || die "$0: can't open $filename for reading: $!";
103 :             || die "$0: can't open $filename for appending: $!";
116 :             || die "$0: can't open $filename in write-open mode: $!";
134 :             || die "$0: can't open $filename for reading: $!";
137 :             || die "$0: can't open $filename for appending: $!";
140 :             || die "$0: can't open $filename in write-open mode: $!";
167 :             || die "$0: cannot open $name_in for reading: $!";
169 :             || die "$0: cannot open $name_out for writing: $!";
perlipc.pod
132 :       my $script = File::Basename::basename($0);
138 :           exec($SELF, @ARGV)        || die "$0: couldn't restart: $!";
616 :         sub logmsg { print "$0 $$: @_ at ", scalar localtime(), "\n" }
657 :         sub logmsg { print "$0 $$: @_ at ", scalar localtime(), "\n" }
810 :         sub logmsg { print "$0 $$: @_ at ", scalar localtime(), "\n" }
929 :         unless (@ARGV > 1) { die "usage: $0 host url ..." }
978 :         unless (@ARGV == 2) { die "usage: $0 host port" }
1056 :      print "[Server $0 accepting clients]\n";
1060 :        print $client "Welcome to $0; type help for command list.\n";
perlvar.pod
100 :     $0      Contains the name of the program being executed.
102 :             On some (but not all) operating systems assigning to $0 modifies the argument area that the "ps" program sees. On some platforms you may have to use special "ps" options or a different "ps" to see the changes. Modifying the $0 is more useful as a way of indicating the current program state than it is for hiding the program you're running.
104 :             Note that there are platform-specific limitations on the maximum length of $0. In the most extreme case it may be limited to the space occupied by the original $0.
108 :             Note for BSD users: setting $0 does not completely remove "perl" from the ps(1) output. For example, setting $0 to "foobar" may result in "perl: foobar (perl)" (whether both the "perl: " prefix and the " (perl)" suffix are shown depends on your exact BSD variant and version). This is an operating system feature, Perl cannot help it.
110 :             In multithreaded scripts Perl coordinates the threads so that any thread may modify its copy of the $0 and the change becomes visible to ps(1) (assuming the operating system plays along). Note that the view of $0 the other threads have will not change since they have their own copies of it.
112 :             If the program has been given to perl via the switches "-e" or "-E", $0 will contain the string "-e".
114 :             On Linux as of perl v5.14.0 the legacy process name will be set with prctl(2), in addition to altering the POSIX name via "argv[0]" as perl has done since version 4.000. Now system utilities that read the legacy process name such as ps, top and killall will recognize the name you set when assigning to $0. The string you supply will be cut off at 16 bytes, this is a limitation imposed by Linux.
690 :     @ARGV   The array @ARGV contains the command-line arguments intended for the script. $#ARGV is generally the number of arguments minus one, because $ARGV[0] is the first argument, *not* the program's command name itself. See "$0" for the command name.
perlperf.pod
161 :             die("Usage: $0 -f filename [-d]");
216 :         $0 report for $file:
768 :                     debug( "A $0 logging message via process-id: $$" . Dumper(\%INC) )
771 :                     debug( "A $0 logging message via process-id: $$" . Dumper(\%INC) ) if $DEBUG
810 :                     debug( "A $0 logging message via process-id: $$" . Dumper(\%INC) )
813 :                     debug( "A $0 logging message via process-id: $$" . Dumper(\%INC) ) if DEBUG
840 :             debug "A $0 logging message via process-id: $$" . Dumper(\%INC);
perlrun.pod
28 :         eval 'exec perl -x -wS $0 ${1+"$@"}'
427 :              eval 'exec /usr/bin/perl -wS $0 ${1+"$@"}'
430 :          The system ignores the first line and feeds the program to /bin/sh, which proceeds to try to execute the Perl program as a shell script. The shell executes the second line as a normal shell command, and thus starts up the Perl interpreter. On some systems $0 doesn't always contain the full pathname, so the -S tells Perl to search for the program if necessary. After Perl locates the program, it parses the lines and ignores them because the variable $running_under_some_shell is never true. If the program will be interpreted by csh, you will need to replace "${1+"$@"}" with $*, even though that doesn't understand embedded spaces (and such) in the argument list. To start up *sh* rather than *csh*, some systems may have to replace the "#!" line with a line containing just a colon, which will be politely ignored by Perl. Other systems can't control that, and need a totally devious construct that will work under any of *csh*, *sh*, or Perl, such as the following:
432 :                  eval '(exit $?0)' && eval 'exec perl -wS $0 ${1+"$@"}'
433 :                  & eval 'exec /usr/bin/perl -wS $0 $argv:q'
perlembed.pod
630 :          PL_origalen = 1; /* don't let $0 assignment update the
688 :   $0 assignments
689 :     When a perl script assigns a value to $0 then the perl runtime will try to make this value show up as the program name reported by "ps" by updating the memory pointed to by the argv passed to perl_parse() and also calling API functions like setproctitle() where available. This behaviour might not be appropriate when embedding perl and can be disabled by assigning the value 1 to the variable "PL_origalen" before perl_parse() is called.
691 :     The persistent.c example above is for instance likely to segfault when $0 is assigned to if the "PL_origalen = 1;" assignment is removed. This because perl will try to write to the read only memory of the "embedding[]" strings.
perltrap.pod
34 :     *   The current input line is normally in $_, not $0. It generally does not have the newline stripped. ($0 is the name of the program executed.) See perlvar.
56 :               ARGV[0]   $0
91 :     *   "ARGV" must be capitalized. $ARGV[0] is C's "argv[1]", and "argv[0]" ends up in $0.
perldata.pod
91 :     A sigil, followed solely by digits matching \p{POSIX_Digit}, like $0, $1, or $10000.
198 :     Without the braces, Perl would have looked for a $whospeak, a $who::0, and a $who's variable. The last two would be the $0 and the $s variables in the (presumably) non-existent package "who".
perlsyn.pod
30 :         $me = myname $0             or die "can't get myname";
35 :       $me = myname $0             || die "can't get myname";
perlport.pod
632 :             eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
perlre.pod
447 :     Several special variables also refer back to portions of the previous match. $+ returns whatever the last bracket match matched. $& returns the entire matched string. (At one point $0 did also, but now it returns the name of the program.) $` returns everything before the matched string. $' returns everything after the matched string. And $^N contains whatever was matched by the most-recently closed group (submatch). $^N can be used in extended patterns (see below), for example to assign a submatch to a variable.
perlcheat.pod
61 :        1 ino    1 minute      1 filename    $0    program name
perldebtut.pod
351 :                     print "Usage: $0 -[c|f] num\n";
<< Back to Perldoc Search