~ubuntu-branches/ubuntu/precise/perl/precise

« back to all changes in this revision

Viewing changes to pod/perlvar.pod

  • Committer: Bazaar Package Importer
  • Author(s): Niko Tyni
  • Date: 2011-02-06 11:31:38 UTC
  • mto: (8.2.12 experimental) (1.1.12)
  • mto: This revision was merged to the branch mainline in revision 46.
  • Revision ID: james.westby@ubuntu.com-20110206113138-lzpm3g6rur7i3eyp
Tags: upstream-5.12.3
ImportĀ upstreamĀ versionĀ 5.12.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
=head2 Predefined Names
8
8
 
9
 
The following names have special meaning to Perl.  Most 
 
9
The following names have special meaning to Perl.  Most
10
10
punctuation names have reasonable mnemonics, or analogs in the
11
11
shells.  Nevertheless, if you wish to use long variable names,
12
12
you need only say
153
153
abs, alarm, chomp, chop, chr, chroot, cos, defined, eval, exp, glob,
154
154
hex, int, lc, lcfirst, length, log, lstat, mkdir, oct, ord, pos, print,
155
155
quotemeta, readlink, readpipe, ref, require, reverse (in scalar context only),
156
 
rmdir, sin, split (on its second argument), sqrt, stat, study, uc, ucfirst, 
 
156
rmdir, sin, split (on its second argument), sqrt, stat, study, uc, ucfirst,
157
157
unlink, unpack.
158
158
 
159
159
=item *
418
418
=item $/
419
419
X<$/> X<$RS> X<$INPUT_RECORD_SEPARATOR>
420
420
 
421
 
The input record separator, newline by default.  This 
 
421
The input record separator, newline by default.  This
422
422
influences Perl's idea of what a "line" is.  Works like B<awk>'s RS
423
423
variable, including treating empty lines as a terminator if set to
424
424
the null string.  (An empty line cannot contain any spaces
481
481
you are outputting to a pipe or socket, such as when you are running
482
482
a Perl program under B<rsh> and want to see the output as it's
483
483
happening.  This has no effect on input buffering.  See L<perlfunc/getc>
484
 
for that.  See L<perldoc/select> on how to select the output channel. 
 
484
for that.  See L<perldoc/select> on how to select the output channel.
485
485
See also L<IO::Handle>. (Mnemonic: when you want your pipes to be piping hot.)
486
486
 
487
487
=item IO::Handle->output_field_separator EXPR
572
572
X<$=> X<$FORMAT_LINES_PER_PAGE>
573
573
 
574
574
The current page length (printable lines) of the currently selected
575
 
output channel.  Default is 60.  
 
575
output channel.  Default is 60.
576
576
Used with formats.
577
577
(Mnemonic: = has horizontal lines.)
578
578
 
584
584
X<$-> X<$FORMAT_LINES_LEFT>
585
585
 
586
586
The number of lines left on the page of the currently selected output
587
 
channel.  
 
587
channel.
588
588
Used with formats.
589
589
(Mnemonic: lines_on_page - lines_printed.)
590
590
 
622
622
 
623
623
=item C<$'> is the same as C<substr($var, $+[0])>
624
624
 
625
 
=item C<$1> is the same as C<substr($var, $-[1], $+[1] - $-[1])>  
 
625
=item C<$1> is the same as C<substr($var, $-[1], $+[1] - $-[1])>
626
626
 
627
627
=item C<$2> is the same as C<substr($var, $-[2], $+[2] - $-[2])>
628
628
 
753
753
 
754
754
    END {
755
755
        $? = 1 if $? == 255;  # die would make it 255
756
 
    } 
 
756
    }
757
757
 
758
758
Under VMS, the pragma C<use vmsish 'status'> makes C<$?> reflect the
759
759
actual VMS exit status, instead of the default emulation of POSIX
856
856
the last error from within the Win32 API.  Most Win32-specific
857
857
code will report errors via C<$^E>.  ANSI C and Unix-like calls
858
858
set C<errno> and so most portable Perl code will report errors
859
 
via C<$!>. 
 
859
via C<$!>.
860
860
 
861
861
Caveats mentioned in the description of C<$!> generally apply to
862
862
C<$^E>, also.  (Mnemonic: Extra error explanation.)
906
906
The real uid of this process.  (Mnemonic: it's the uid you came I<from>,
907
907
if you're running setuid.)  You can change both the real uid and
908
908
the effective uid at the same time by using POSIX::setuid().  Since
909
 
changes to $< require a system call, check $! after a change attempt to 
 
909
changes to $< require a system call, check $! after a change attempt to
910
910
detect any possible errors.
911
911
 
912
912
=item $EFFECTIVE_USER_ID
923
923
 
924
924
You can change both the effective uid and the real uid at the same
925
925
time by using POSIX::setuid().  Changes to $> require a check to $!
926
 
to detect any possible errors after an attempted change. 
 
926
to detect any possible errors after an attempted change.
927
927
 
928
928
(Mnemonic: it's the uid you went I<to>, if you're running setuid.)
929
929
C<< $< >> and C<< $> >> can be swapped only on machines
1562
1562
    $SIG{"PIPE"} = Plumber();   # oops, what did Plumber() return??
1563
1563
 
1564
1564
Be sure not to use a bareword as the name of a signal handler,
1565
 
lest you inadvertently call it. 
 
1565
lest you inadvertently call it.
1566
1566
 
1567
1567
If your system has the sigaction() function then signal handlers are
1568
1568
installed using it.  This means you get reliable signal handling.
1569
1569
 
1570
 
The default delivery policy of signals changed in Perl 5.8.0 from 
1571
 
immediate (also known as "unsafe") to deferred, also known as 
 
1570
The default delivery policy of signals changed in Perl 5.8.0 from
 
1571
immediate (also known as "unsafe") to deferred, also known as
1572
1572
"safe signals".  See L<perlipc> for more information.
1573
1573
 
1574
1574
Certain internal hooks can be also set using the %SIG hash.  The
1674
1674
interpreter, C library, operating system, or an external program,
1675
1675
respectively.
1676
1676
 
1677
 
To illustrate the differences between these variables, consider the 
 
1677
To illustrate the differences between these variables, consider the
1678
1678
following Perl expression, which uses a single-quoted string:
1679
1679
 
1680
1680
    eval q{
1683
1683
        close $pipe or die "bad pipe: $?, $!";
1684
1684
    };
1685
1685
 
1686
 
After execution of this statement all 4 variables may have been set.  
 
1686
After execution of this statement all 4 variables may have been set.
1687
1687
 
1688
1688
C<$@> is set if the string to be C<eval>-ed did not compile (this
1689
1689
may happen if C<open> or C<close> were imported with bad prototypes),
1695
1695
When the eval() expression above is executed, open(), C<< <PIPE> >>,
1696
1696
and C<close> are translated to calls in the C run-time library and
1697
1697
thence to the operating system kernel.  C<$!> is set to the C library's
1698
 
C<errno> if one of these calls fails. 
 
1698
C<errno> if one of these calls fails.
1699
1699
 
1700
1700
Under a few operating systems, C<$^E> may contain a more verbose
1701
1701
error indicator, such as in this case, "CDROM tray not closed."
1760
1760
 
1761
1761
In particular, the new special C<${^_XYZ}> variables are always taken
1762
1762
to be in package C<main>, regardless of any C<package> declarations
1763
 
presently in scope.  
 
1763
presently in scope.
1764
1764
 
1765
1765
=head1 BUGS
1766
1766