Perldoc Search: "$_" perl-5.20.1

search official POD


39 PODs, 482 LINEs found.
perlfunc.pod
121 :     -X  A file test, where X is one of the letters listed below. This unary operator takes one argument, either a filename, a filehandle, or a dirhandle, and tests the associated file to see if something is true about it. If the argument is omitted, tests $_, except for "-t", which tests STDIN. Unless otherwise documented, it returns 1 for true and '' for false. If the file doesn't exist or can't be examined, it returns "undef" and sets $! (errno). Despite the funny names, precedence is the same as any other named unary operator. The operator may be any of:
163 :                 next unless -f $_;  # ignore specials
205 :     abs Returns the absolute value of its argument. If VALUE is omitted, uses $_.
214 :         Arranges to have a SIGALRM delivered to this process after the specified number of wallclock seconds has elapsed. If SECONDS is not specified, the value stored in $_ is used. (On some machines, unfortunately, the elapsed time may be up to one second less or more than you specified because of how seconds are counted, and process scheduling may delay the delivery of the signal even further.)
247 :             sub tan { sin($_[0]) / cos($_[0])  }
360 :         This safer version of "chop" removes any trailing string that corresponds to the current value of $/ (also known as $INPUT_RECORD_SEPARATOR in the "English" module). It returns the total number of characters removed from all its arguments. It's often used to remove the newline from the end of an input record when you're worried that the final record may be missing its newline. When in paragraph mode ("$/ = """), it removes all trailing newlines from the string. When in slurp mode ("$/ = undef") or fixed-length record mode ($/ is a reference to an integer or the like; see perlvar) chomp() won't remove anything. If VARIABLE is omitted, it chomps $_. Example:
382 :         Chops off the last character of a string and returns the character chopped. It is much more efficient than "s/.$//s" because it neither scans nor copies the string. If VARIABLE is omitted, chops $_. If VARIABLE is a hash, it chops the hash's values, but not its keys, resetting the "each" iterator in the process.
425 :         If NUMBER is omitted, uses $_.
435 :         This function works like the system call by the same name: it makes the named directory the new root directory for all further pathnames that begin with a "/" by your process and all its children. (It doesn't change your current working directory, which is unaffected.) For security reasons, this call is restricted to the superuser. If FILENAME is omitted, does a "chroot" to $_.
493 :     cos Returns the cosine of EXPR (expressed in radians). If EXPR is omitted, takes the cosine of $_.
497 :             sub acos { atan2( sqrt(1 - $_[0] * $_[0]), $_[0] ) }
571 :         Returns a Boolean value telling whether EXPR has a value other than the undefined value "undef". If EXPR is not present, $_ is checked.
785 :         As of Perl 5.18 you can use a bare "each" in a "while" loop, which will set $_ on every iteration.
788 :                 print "$_=$ENV{$_}\n";
795 :             use 5.018;  # so each assigns to $_ in a lone while test
810 :                 print "$.\t$_";
831 :         Note that the value is parsed every time the "eval" executes. If EXPR is omitted, evaluates $_. This form is typically used to delay parsing and subsequent execution of the text of EXPR until run time.
833 :         If the "unicode_eval" feature is enabled (which is the default under a "use 5.16" or higher declaration), EXPR or $_ is treated as a string of characters, so "use utf8" declarations have no effect, and source filters are forbidden. In the absence of the "unicode_eval" feature, the string will sometimes be treated as characters and sometimes as bytes, depending on the internal encoding, and source filters activated within the "eval" exhibit the erratic, but historical, behaviour of affecting some outer file scope that is still compiling. See also the "evalbytes" keyword, which always treats its input as a byte stream and works properly with source filters, and the feature pragma.
874 :                       sub { (my $x = $_[0]) =~ s/foo/bar/g; die $x };
914 :         This function is like "eval" with a string argument, except it always parses its argument, or $_ if EXPR is omitted, as a string of bytes. A string containing characters whose ordinal value exceeds 255 results in an error. Source filters activated within the evaluated code apply to the code itself.
1020 :     exp Returns *e* (the natural logarithm base) to the power of EXPR. If EXPR is omitted, gives "exp($_)".
1043 :         If EXPR is omitted, uses $_.
1370 :         In list context, returns a (possibly empty) list of filename expansions on the value of EXPR such as the standard Unix shell /bin/csh would do. In scalar context, glob iterates through such filename expansions, returning undef when the list is exhausted. This is the internal function implementing the "<*.c>" operator, but you can use it directly. If EXPR is omitted, $_ is used. The "<*.c>" operator is discussed in more detail in "I/O Operators" in perlop.
1422 :         Evaluates the BLOCK or EXPR for each element of LIST (locally setting $_ to each element) and returns the list value consisting of those elements for which the expression evaluated to true. In scalar context, returns the number of times the expression was true.
1430 :         Note that $_ is an alias to the list value, so it can be used to modify the elements of the LIST. While this is useful and supported, it can cause bizarre results if the elements of LIST are not variables. Similarly, grep returns aliases into the original list, much as a for loop's index variable aliases the list elements. That is, modifying an element of a list returned by grep (for example, in a "foreach", "map" or another "grep") actually modifies the element in the original list. This is usually something to be avoided when writing clear code.
1432 :         If $_ is lexical in the scope where the "grep" appears (because it has been declared with the deprecated "my $_" construct) then, in addition to being locally aliased to the list elements, $_ keeps being lexical inside the block; i.e., it can't be seen from the outside, avoiding any potential side-effects.
1437 :     hex Interprets EXPR as a hex string and returns the corresponding value. (To convert strings that might start with either 0, "0x", or "0b", see "oct".) If EXPR is omitted, uses $_.
1452 :     int Returns the integer portion of EXPR. If EXPR is omitted, uses $_. You should not use this function for rounding: one because it truncates towards 0, and two because machine representations of floating-point numbers can sometimes produce counterintuitive results. For example, "int(-6.725/0.025)" produces -268 rather than the correct -269; that's because it's really more like -268.99999999999994315658 instead. Usually, the "sprintf", "printf", or the "POSIX::floor" and "POSIX::ceil" functions will serve you better than will int().
1584 :         If EXPR is omitted, uses $_.
1609 :         If EXPR is omitted, uses $_.
1615 :         Returns the length in *characters* of the value of EXPR. If EXPR is omitted, returns the length of $_. If EXPR is undefined, returns "undef".
1698 :     log Returns the natural logarithm (base *e*) of EXPR. If EXPR is omitted, returns the log of $_. To get the log of another base, use basic algebra: The base-N log of a number is equal to the natural log of that number divided by the natural log of N. For example:
1713 :         If EXPR is omitted, stats $_.
1721 :         Evaluates the BLOCK or EXPR for each element of LIST (locally setting $_ to each element) and returns the list value composed of the results of each such evaluation. In scalar context, returns the total number of elements so generated. Evaluates BLOCK or EXPR in list context, so each element of LIST may produce zero, one, or more elements in the returned value.
1727 :             my @squares = map { $_ * $_ } @numbers;
1731 :             my @squares = map { $_ > 5 ? ($_ * $_) : () } @numbers;
1735 :             my @squares = map { $_ * $_ } grep { $_ > 5 } @numbers;
1741 :             %hash = map { get_a_key_for($_) => $_ } @array;
1747 :                 $hash{get_a_key_for($_)} = $_;
1750 :         Note that $_ is an alias to the list value, so it can be used to modify the elements of the LIST. While this is useful and supported, it can cause bizarre results if the elements of LIST are not variables. Using a regular "foreach" loop for this purpose would be clearer in most cases. See also "grep" for an array composed of those items of the original list for which the BLOCK or EXPR evaluates to true.
1752 :         If $_ is lexical in the scope where the "map" appears (because it has been declared with the deprecated "my $_" construct), then, in addition to being locally aliased to the list elements, $_ keeps being lexical inside the block; that is, it can't be seen from the outside, avoiding any potential side-effects.
1756 :             %hash = map {  "\L$_" => 1  } @array # perl guesses EXPR. wrong
1757 :             %hash = map { +"\L$_" => 1  } @array # perl guesses BLOCK. right
1758 :             %hash = map { ("\L$_" => 1) } @array # this also works
1759 :             %hash = map {  lc($_) => 1  } @array # as does this.
1760 :             %hash = map +( lc($_) => 1 ), @array # this is EXPR and works!
1762 :             %hash = map  ( lc($_), 1 ),   @array # evaluates to (1, @array)
1766 :             @hashes = map +{ lc($_) => 1 }, @array # EXPR, so needs
1774 :         Creates the directory specified by FILENAME, with permissions specified by MASK (as modified by "umask"). If it succeeds it returns true; otherwise it returns false and sets $! (errno). MASK defaults to 0777 if omitted, and FILENAME defaults to $_ if omitted.
1850 :         If EXPR is omitted, uses $_. To go the other way (produce a number in octal), use sprintf() or printf():
1981 :                 local $_;
2137 :     ord Returns the numeric value of the first character of EXPR. If EXPR is an empty string, returns 0. If EXPR is omitted, uses $_. (Note *character*, not byte.)
2436 :                printf("%#02x ", $_) for unpack("W*", pack L=>0x12345678);
2474 :                   perl -CS -ne 'printf "%v04X\n", $_ for unpack("C0A*", $_)'
2477 :                   perl -CS -ne 'printf "%v02X\n", $_ for unpack("U0A*", $_)'
2480 :                   perl -C0 -ne 'printf "%v02X\n", $_ for unpack("C0A*", $_)'
2483 :                   perl -C0 -ne 'printf "%v02X\n", $_ for unpack("U0A*", $_)'
2623 :     pos Returns the offset of where the last "m//g" search left off for the variable in question ($_ is used when the variable is not specified). Note that 0 is a valid match offset. "undef" indicates that the search position is reset (usually due to match failure, but can also be because no match has yet been run on the scalar).
2635 :         Prints a string or a list of strings. Returns true if successful. FILEHANDLE may be a scalar variable containing the name of or a reference to the filehandle, thus introducing one level of indirection. (NOTE: If FILEHANDLE is a variable and the next token is a term, it may be misinterpreted as an operator unless you interpose a "+" or put parentheses around the arguments.) If FILEHANDLE is omitted, prints to the last selected (see "select") output handle. If LIST is omitted, prints $_ to the currently selected output handle. To use FILEHANDLE alone to print the content of $_ to it, you must use a real filehandle like "FH", not an indirect one like $fh. To set the default output handle to something other than STDOUT, use the select operation.
2650 :         Equivalent to "print FILEHANDLE sprintf(FORMAT, LIST)", except that $\ (the output record separator) is not appended. The FORMAT and the LIST are actually parsed as a single list. The first argument of the list will be interpreted as the "printf" format. This means that "printf(@_)" will use $_[0] as the format. See sprintf for an explanation of the format argument. If "use locale" (including "use locale ':not_characters'") is in effect and POSIX::setlocale() has been called, the character used for the decimal separator in formatted floating-point numbers is affected by the LC_NUMERIC locale setting. See perllocale and POSIX.
2652 :         For historical reasons, if you omit the list, $_ is used as the format; to use FILEHANDLE without a list, you must use a real filehandle like "FH", not an indirect one like $fh. However, this will rarely do what you want; if $_ contains formatting codes, they will be replaced with the empty string and a warning will be emitted if warnings are enabled. Just use "print" if you want to print the contents of $_.
2690 :         If EXPR is omitted, uses $_.
2763 :             @dots = grep { /^\./ && -f "$some_dir/$_" } readdir($dh);
2766 :         As of Perl 5.12 you can use a bare "readdir" in a "while" loop, which will set $_ on every iteration.
2770 :                 print "$some_dir/$_\n";
2776 :             use 5.012; # so readdir assigns to $_ in a lone while test
2792 :                 defined( $_ = <$fh> ) or die "readline failed: $!";
2802 :                     defined( $_ = <$fh> )
2810 :         Returns the value of a symbolic link, if symbolic links are implemented. If not, raises an exception. If there is a system error, returns the undefined value and sets $! (errno). If EXPR is omitted, uses $_.
2816 :         EXPR is executed as a system command. The collected standard output of the command is returned. In scalar context, it comes back as a single (potentially multi-line) string. In list context, returns a list of lines (however you've defined lines with $/ or $INPUT_RECORD_SEPARATOR). This is the internal function implementing the "qx/EXPR/" operator, but you can use it directly. The "qx/EXPR/" operator is discussed in more detail in "I/O Operators" in perlop. If EXPR is omitted, uses $_.
2834 :                     $front = $_;
2854 :     ref Returns a non-empty string if EXPR is a reference, the empty string otherwise. If EXPR is not specified, $_ will be used. The value returned depends on the type of thing the reference is a reference to.
2901 :         Demands a version of Perl specified by VERSION, or demands some semantics specified by EXPR or by $_ if EXPR is not supplied.
2992 :         3   A reference to a subroutine. If there is no filehandle (previous item), then this subroutine is expected to generate one line of source code per call, writing the line into $_ and returning 1, then finally at end of file returning 0. If there is a filehandle, then the subroutine will be called to act as a simple source filter, with the line as read in $_. Again, return 1 for each valid line, and 0 after all lines have been returned.
2994 :         4   Optional state for the subroutine. The state is passed in as $_[1]. A reference to the subroutine itself is passed in as $_[0].
3060 :         Used without arguments in scalar context, reverse() reverses $_.
3062 :             $_ = "dlrow ,olleH";
3083 :         Deletes the directory specified by FILENAME if that directory is empty. If it succeeds it returns true; otherwise it returns false and sets $! (errno). If FILENAME is omitted, uses $_.
3093 :     say Just like "print", but implicitly appends a newline. "say LIST" is simply an abbreviation for "{ local $\ = "\n"; print LIST }". To use FILEHANDLE without a LIST to print the contents of $_ to it, you must use a real filehandle like "FH", not an indirect one like $fh.
3133 :                 for ($curpos = tell(FILE); $_ = <FILE>;
3310 :     sin Returns the sine of EXPR (expressed in radians). If EXPR is omitted, returns sine of $_.
3314 :             sub asin { atan2($_[0], sqrt(1 - $_[0] * $_[0])) }
3434 :                 push @caps, fc($_);
3445 :             @new = map { $_->[0] }
3449 :                    } map { [$_, /=(\d+)/, fc($_)] } @old;
3454 :             sub backwards ($$) { $_[1] cmp $_[0]; }  # $a and $b are
3493 :             @result = sort { $a <=> $b } grep { $_ == $_ } @input;
3536 :         If only PATTERN is given, EXPR defaults to $_.
3888 :         Return the positive square root of EXPR. If EXPR is omitted, uses $_. Works only for non-negative operands unless you've loaded the "Math::Complex" module.
3915 :         Returns a 13-element list giving the status info for a file, either the file opened via FILEHANDLE or DIRHANDLE, or named by EXPR. If EXPR is omitted, it stats $_ (not "_"!). Returns the empty list if "stat" fails. Typically used as follows:
4041 :         Takes extra time to study SCALAR ($_ if unspecified) in anticipation of doing many pattern matches on the string before it is next modified. This may or may not save time, depending on the nature and number of patterns you are searching and the distribution of character frequencies in the string to be searched; you probably want to compare run times with and without it to see which is faster. Those loops that scan for many short constant strings (including the constant parts of more complex patterns) will benefit most. (The way "study" works is this: a linked list of every character in the string to be searched is made, so we know, for example, where all the 'k' characters are. From each search string, the rarest character is selected, based on some static frequency tables constructed from some C programs and English text. Only those places that contain this "rarest" character are examined.)
4054 :         In searching for "/\bfoo\b/", only locations in $_ that contain "f" will be looked at, because "f" is rarer than "o". In general, this is a big win except in pathological cases. The only question is whether it saves you more time than it took to build the linked list in the first place.
4118 :                 $_ = 'a';   print $x,"\n";    # prints 1a4
4119 :                 $_ = 'xyz'; print $x,"\n";    # prints 1xyz4
4121 :                 $_ = 'pq';  print $x,"\n";    # prints 5pq9
4128 :                 $_ = 'a';   print $x,"\n";    # prints 1a4, as above
4130 :                 print $_,"\n";                # prints f
4201 :             sub systell { sysseek($_[0], 0, SEEK_CUR) }
4384 :         If EXPR is omitted, uses $_.
4392 :         If EXPR is omitted, uses $_.
4442 :         If LIST is omitted, "unlink" uses $_.
4448 :         If EXPR is omitted, unpacks the $_ string. See perlpacktut for an introduction to this function.
4461 :             sub ordinal { unpack("W",$_[0]); } # same as ord()
4664 :                              unpack("V",$_) 01234567890123456789012345678901
4683 :           vec($_,@#,@#) = @<< == @######### @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
4691 :                              unpack("V",$_) 01234567890123456789012345678901
4693 :           vec($_, 0, 1) = 1   ==          1 10000000000000000000000000000000
4694 :           vec($_, 1, 1) = 1   ==          2 01000000000000000000000000000000
4695 :           vec($_, 2, 1) = 1   ==          4 00100000000000000000000000000000
4696 :           vec($_, 3, 1) = 1   ==          8 00010000000000000000000000000000
4697 :           vec($_, 4, 1) = 1   ==         16 00001000000000000000000000000000
4698 :           vec($_, 5, 1) = 1   ==         32 00000100000000000000000000000000
4699 :           vec($_, 6, 1) = 1   ==         64 00000010000000000000000000000000
4700 :           vec($_, 7, 1) = 1   ==        128 00000001000000000000000000000000
4701 :           vec($_, 8, 1) = 1   ==        256 00000000100000000000000000000000
4702 :           vec($_, 9, 1) = 1   ==        512 00000000010000000000000000000000
4703 :           vec($_,10, 1) = 1   ==       1024 00000000001000000000000000000000
4704 :           vec($_,11, 1) = 1   ==       2048 00000000000100000000000000000000
4705 :           vec($_,12, 1) = 1   ==       4096 00000000000010000000000000000000
4706 :           vec($_,13, 1) = 1   ==       8192 00000000000001000000000000000000
4707 :           vec($_,14, 1) = 1   ==      16384 00000000000000100000000000000000
4708 :           vec($_,15, 1) = 1   ==      32768 00000000000000010000000000000000
4709 :           vec($_,16, 1) = 1   ==      65536 00000000000000001000000000000000
4710 :           vec($_,17, 1) = 1   ==     131072 00000000000000000100000000000000
4711 :           vec($_,18, 1) = 1   ==     262144 00000000000000000010000000000000
4712 :           vec($_,19, 1) = 1   ==     524288 00000000000000000001000000000000
4713 :           vec($_,20, 1) = 1   ==    1048576 00000000000000000000100000000000
4714 :           vec($_,21, 1) = 1   ==    2097152 00000000000000000000010000000000
4715 :           vec($_,22, 1) = 1   ==    4194304 00000000000000000000001000000000
4716 :           vec($_,23, 1) = 1   ==    8388608 00000000000000000000000100000000
4717 :           vec($_,24, 1) = 1   ==   16777216 00000000000000000000000010000000
4718 :           vec($_,25, 1) = 1   ==   33554432 00000000000000000000000001000000
4719 :           vec($_,26, 1) = 1   ==   67108864 00000000000000000000000000100000
4720 :           vec($_,27, 1) = 1   ==  134217728 00000000000000000000000000010000
4721 :           vec($_,28, 1) = 1   ==  268435456 00000000000000000000000000001000
4722 :           vec($_,29, 1) = 1   ==  536870912 00000000000000000000000000000100
4723 :           vec($_,30, 1) = 1   == 1073741824 00000000000000000000000000000010
4724 :           vec($_,31, 1) = 1   == 2147483648 00000000000000000000000000000001
4725 :           vec($_, 0, 2) = 1   ==          1 10000000000000000000000000000000
4726 :           vec($_, 1, 2) = 1   ==          4 00100000000000000000000000000000
4727 :           vec($_, 2, 2) = 1   ==         16 00001000000000000000000000000000
4728 :           vec($_, 3, 2) = 1   ==         64 00000010000000000000000000000000
4729 :           vec($_, 4, 2) = 1   ==        256 00000000100000000000000000000000
4730 :           vec($_, 5, 2) = 1   ==       1024 00000000001000000000000000000000
4731 :           vec($_, 6, 2) = 1   ==       4096 00000000000010000000000000000000
4732 :           vec($_, 7, 2) = 1   ==      16384 00000000000000100000000000000000
4733 :           vec($_, 8, 2) = 1   ==      65536 00000000000000001000000000000000
4734 :           vec($_, 9, 2) = 1   ==     262144 00000000000000000010000000000000
4735 :           vec($_,10, 2) = 1   ==    1048576 00000000000000000000100000000000
4736 :           vec($_,11, 2) = 1   ==    4194304 00000000000000000000001000000000
4737 :           vec($_,12, 2) = 1   ==   16777216 00000000000000000000000010000000
4738 :           vec($_,13, 2) = 1   ==   67108864 00000000000000000000000000100000
4739 :           vec($_,14, 2) = 1   ==  268435456 00000000000000000000000000001000
4740 :           vec($_,15, 2) = 1   == 1073741824 00000000000000000000000000000010
4741 :           vec($_, 0, 2) = 2   ==          2 01000000000000000000000000000000
4742 :           vec($_, 1, 2) = 2   ==          8 00010000000000000000000000000000
4743 :           vec($_, 2, 2) = 2   ==         32 00000100000000000000000000000000
4744 :           vec($_, 3, 2) = 2   ==        128 00000001000000000000000000000000
4745 :           vec($_, 4, 2) = 2   ==        512 00000000010000000000000000000000
4746 :           vec($_, 5, 2) = 2   ==       2048 00000000000100000000000000000000
4747 :           vec($_, 6, 2) = 2   ==       8192 00000000000001000000000000000000
4748 :           vec($_, 7, 2) = 2   ==      32768 00000000000000010000000000000000
4749 :           vec($_, 8, 2) = 2   ==     131072 00000000000000000100000000000000
4750 :           vec($_, 9, 2) = 2   ==     524288 00000000000000000001000000000000
4751 :           vec($_,10, 2) = 2   ==    2097152 00000000000000000000010000000000
4752 :           vec($_,11, 2) = 2   ==    8388608 00000000000000000000000100000000
4753 :           vec($_,12, 2) = 2   ==   33554432 00000000000000000000000001000000
4754 :           vec($_,13, 2) = 2   ==  134217728 00000000000000000000000000010000
4755 :           vec($_,14, 2) = 2   ==  536870912 00000000000000000000000000000100
4756 :           vec($_,15, 2) = 2   == 2147483648 00000000000000000000000000000001
4757 :           vec($_, 0, 4) = 1   ==          1 10000000000000000000000000000000
4758 :           vec($_, 1, 4) = 1   ==         16 00001000000000000000000000000000
4759 :           vec($_, 2, 4) = 1   ==        256 00000000100000000000000000000000
4760 :           vec($_, 3, 4) = 1   ==       4096 00000000000010000000000000000000
4761 :           vec($_, 4, 4) = 1   ==      65536 00000000000000001000000000000000
4762 :           vec($_, 5, 4) = 1   ==    1048576 00000000000000000000100000000000
4763 :           vec($_, 6, 4) = 1   ==   16777216 00000000000000000000000010000000
4764 :           vec($_, 7, 4) = 1   ==  268435456 00000000000000000000000000001000
4765 :           vec($_, 0, 4) = 2   ==          2 01000000000000000000000000000000
4766 :           vec($_, 1, 4) = 2   ==         32 00000100000000000000000000000000
4767 :           vec($_, 2, 4) = 2   ==        512 00000000010000000000000000000000
4768 :           vec($_, 3, 4) = 2   ==       8192 00000000000001000000000000000000
4769 :           vec($_, 4, 4) = 2   ==     131072 00000000000000000100000000000000
4770 :           vec($_, 5, 4) = 2   ==    2097152 00000000000000000000010000000000
4771 :           vec($_, 6, 4) = 2   ==   33554432 00000000000000000000000001000000
4772 :           vec($_, 7, 4) = 2   ==  536870912 00000000000000000000000000000100
4773 :           vec($_, 0, 4) = 4   ==          4 00100000000000000000000000000000
4774 :           vec($_, 1, 4) = 4   ==         64 00000010000000000000000000000000
4775 :           vec($_, 2, 4) = 4   ==       1024 00000000001000000000000000000000
4776 :           vec($_, 3, 4) = 4   ==      16384 00000000000000100000000000000000
4777 :           vec($_, 4, 4) = 4   ==     262144 00000000000000000010000000000000
4778 :           vec($_, 5, 4) = 4   ==    4194304 00000000000000000000001000000000
4779 :           vec($_, 6, 4) = 4   ==   67108864 00000000000000000000000000100000
4780 :           vec($_, 7, 4) = 4   == 1073741824 00000000000000000000000000000010
4781 :           vec($_, 0, 4) = 8   ==          8 00010000000000000000000000000000
4782 :           vec($_, 1, 4) = 8   ==        128 00000001000000000000000000000000
4783 :           vec($_, 2, 4) = 8   ==       2048 00000000000100000000000000000000
4784 :           vec($_, 3, 4) = 8   ==      32768 00000000000000010000000000000000
4785 :           vec($_, 4, 4) = 8   ==     524288 00000000000000000001000000000000
4786 :           vec($_, 5, 4) = 8   ==    8388608 00000000000000000000000100000000
4787 :           vec($_, 6, 4) = 8   ==  134217728 00000000000000000000000000010000
4788 :           vec($_, 7, 4) = 8   == 2147483648 00000000000000000000000000000001
4789 :           vec($_, 0, 8) = 1   ==          1 10000000000000000000000000000000
4790 :           vec($_, 1, 8) = 1   ==        256 00000000100000000000000000000000
4791 :           vec($_, 2, 8) = 1   ==      65536 00000000000000001000000000000000
4792 :           vec($_, 3, 8) = 1   ==   16777216 00000000000000000000000010000000
4793 :           vec($_, 0, 8) = 2   ==          2 01000000000000000000000000000000
4794 :           vec($_, 1, 8) = 2   ==        512 00000000010000000000000000000000
4795 :           vec($_, 2, 8) = 2   ==     131072 00000000000000000100000000000000
4796 :           vec($_, 3, 8) = 2   ==   33554432 00000000000000000000000001000000
4797 :           vec($_, 0, 8) = 4   ==          4 00100000000000000000000000000000
4798 :           vec($_, 1, 8) = 4   ==       1024 00000000001000000000000000000000
4799 :           vec($_, 2, 8) = 4   ==     262144 00000000000000000010000000000000
4800 :           vec($_, 3, 8) = 4   ==   67108864 00000000000000000000000000100000
4801 :           vec($_, 0, 8) = 8   ==          8 00010000000000000000000000000000
4802 :           vec($_, 1, 8) = 8   ==       2048 00000000000100000000000000000000
4803 :           vec($_, 2, 8) = 8   ==     524288 00000000000000000001000000000000
4804 :           vec($_, 3, 8) = 8   ==  134217728 00000000000000000000000000010000
4805 :           vec($_, 0, 8) = 16  ==         16 00001000000000000000000000000000
4806 :           vec($_, 1, 8) = 16  ==       4096 00000000000010000000000000000000
4807 :           vec($_, 2, 8) = 16  ==    1048576 00000000000000000000100000000000
4808 :           vec($_, 3, 8) = 16  ==  268435456 00000000000000000000000000001000
4809 :           vec($_, 0, 8) = 32  ==         32 00000100000000000000000000000000
4810 :           vec($_, 1, 8) = 32  ==       8192 00000000000001000000000000000000
4811 :           vec($_, 2, 8) = 32  ==    2097152 00000000000000000000010000000000
4812 :           vec($_, 3, 8) = 32  ==  536870912 00000000000000000000000000000100
4813 :           vec($_, 0, 8) = 64  ==         64 00000010000000000000000000000000
4814 :           vec($_, 1, 8) = 64  ==      16384 00000000000000100000000000000000
4815 :           vec($_, 2, 8) = 64  ==    4194304 00000000000000000000001000000000
4816 :           vec($_, 3, 8) = 64  == 1073741824 00000000000000000000000000000010
4817 :           vec($_, 0, 8) = 128 ==        128 00000001000000000000000000000000
4818 :           vec($_, 1, 8) = 128 ==      32768 00000000000000010000000000000000
4819 :           vec($_, 2, 8) = 128 ==    8388608 00000000000000000000000100000000
4820 :           vec($_, 3, 8) = 128 == 2147483648 00000000000000000000000000000001
4869 :             BEGIN { $SIG{'__WARN__'} = sub { warn $_[0] if $DOWARN } }
perlop.pod
137 :     Binary "=~" binds a scalar expression to a pattern match. Certain operations search or modify the string $_ by default. This operator makes that kind of operation work on some other string. The right argument is a search pattern, substitution, or transliteration. The left argument is what is supposed to be searched, substituted, or transliterated instead of the default $_. When used in scalar context, the return value generally indicates the success of the operation. The exceptions are substitution (s///) and transliteration (y///) with the "/r" (non-destructive) option, which cause the return value to be the result of the substitution. Behavior in list context depends on the particular operator. See "Regexp Quote-Like Operators" for details and perlretut for examples using these operators.
280 :                     like: grep { exists HASH->{$_} } ARRAY
286 :                     like: grep { Any ~~ $_ } ARRAY
294 :                              grep { exists HASH2->{$_} } keys HASH1
296 :                     like: grep { exists HASH->{$_} } ARRAY
309 :                     like: !grep { !CODE->($_) } ARRAY
311 :                     like: !grep { !CODE->($_) } keys HASH
584 :                 print "$_\n";
592 :         for (101 .. 200) { print }      # print $_ 100 times
978 :                     my @compiled = map qr/$_/i, @$patterns;
1015 :             Searches a string for a pattern match, and in scalar context returns true if it succeeds, false if it fails. If no string is specified via the "=~" or "!~" operator, the $_ string is searched. (The string specified with "=~" need not be an lvalue--it may be the result of an expression evaluation, but remember the "=~" binds rather tightly.) See also perlre.
1120 :                 $_ = "ppooqppqq";
1145 :              $_ = <<'EOL';
1197 :             If no string is specified via the "=~" or "!~" operator, the $_ variable is searched and modified. Unless the "/r" option is used, the string specified must be a scalar variable, an array element, a hash element, or an assignment to one of those; that is, some sort of scalar lvalue.
1232 :                 $_ = 'abc123xyz';
1241 :                 $_ = 'abc123xyz';
1243 :                                             # $_ remains 'abc123xyz'.
1245 :                 # expand variables in $_, but dynamics only, using
1256 :                 # (including lexicals) in $_ : First $1 is interpolated
1267 :                 s/^\s*(.*?)\s*$/$1/;        # trim whitespace in $_,
1301 :             $_ .= qq
1377 :         Transliterates all occurrences of the characters found in the search list with the corresponding character in the replacement list. It returns the number of characters replaced or deleted. If no string is specified via the "=~" or "!~" operator, the $_ string is transliterated.
1405 :             $cnt = tr/*/*/;             # count the stars in $_
1409 :             $cnt = tr/0-9//;            # count the digits in $_
1669 :     Ordinarily you must assign the returned value to a variable, but there is one situation where an automatic assignment happens. If and only if the input symbol is the only thing inside the conditional of a "while" statement (even if disguised as a "for(;;)" loop), the value is automatically assigned to the global variable $_, destroying whatever was there previously. (This may seem like an odd thing to you, but you'll use the construct in almost every Perl script you write.) The $_ variable is not implicitly localized. You'll have to put a "local $_;" before the loop if you want that to happen.
1673 :         while (defined($_ = <STDIN>)) { print; }
1674 :         while ($_ = <STDIN>) { print; }
1677 :         print while defined($_ = <STDIN>);
1678 :         print while ($_ = <STDIN>);
1681 :     This also behaves similarly, but assigns to a lexical variable instead of to $_:
1687 :         while (($_ = <STDIN>) ne '0') { ... }
1688 :         while (<STDIN>) { last unless $_; ... }
1732 :         @ARGV = map { /\.(gz|Z)$/ ? "gzip -dc < $_ |" : $_ } @ARGV;
1736 :         while ($_ = $ARGV[0], /^-/) {
1760 :             chmod 0644, $_;
1768 :             chmod 0644, $_;
perlsyn.pod
70 :     The "for(each)" modifier is an iterator: it executes the statement once for each item in the LIST (with $_ aliased to each item in turn).
72 :         print "Hello $_!\n" for qw(world Dolly nurse);
107 :     The "when" modifier is an experimental feature that first appeared in Perl 5.14. To use it, you should include a "use v5.14" declaration. (Technically, it requires only the "switch" feature, but that aspect of it was not available before 5.14.) Operative only from within a "foreach" loop or a "given" block, it executes the statement only if the smartmatch "$_ ~~ *EXPR*" is true. If the statement executes, it is followed by a "next" from inside a "foreach" and "break" from inside a "given".
191 :                 $_ .= <>;
194 :             # now process $_
216 :             print "$ARGV $.: $_";
278 :         for ( prompt(); defined( $_ = <STDIN> ); prompt() ) {
285 :     The "foreach" keyword is actually a synonym for the "for" keyword, so you can use either. If VAR is omitted, $_ is set to each value.
412 :     The arguments to "given" and "when" are in scalar context, and "given" assigns the $_ variable its topic value.
414 :     Exactly what the *EXPR* argument to "when" does is hard to describe precisely, but in general, it tries to guess what you want done. Sometimes it is interpreted as "$_ ~~ *EXPR*", and sometimes it is not. It also behaves differently when lexically enclosed by a "given" block than it does when dynamically enclosed by a "foreach" loop. The rules are far too difficult to understand to be described here. See "Experimental Details on given and when" later on.
416 :     Due to an unfortunate bug in how "given" was implemented between Perl 5.10 and 5.16, under those implementations the version of $_ governed by "given" is merely a lexically scoped copy of the original, not a dynamically scoped alias to the original, as it would be if it were a "foreach" or under both the original and the current Perl 6 language specification. This bug was fixed in Perl 5.18. If you really want a lexical $_, specify that explicitly, but note that "my $_" is now deprecated and will warn unless warnings have been disabled:
418 :         given(my $_ = EXPR) { ... }
578 :             when ($_ < 100) {
589 :     Before Perl 5.18, "given(EXPR)" assigned the value of *EXPR* to merely a lexically scoped *copy* (!) of $_, not a dynamically scoped alias the way "foreach" does. That made it similar to
591 :             do { my $_ = EXPR; ... }
593 :     except that the block was automatically broken out of by a successful "when" or an explicit "break". Because it was only a copy, and because it was only lexically scoped, not dynamically scoped, you could not do the things with it that you are used to in a "foreach" loop. In particular, it did not work for arbitrary function calls if those functions might try to access $_. Best stick to "foreach" for that.
595 :     Most of the power comes from the implicit smartmatching that can sometimes apply. Most of the time, "when(EXPR)" is treated as an implicit smartmatch of $_, that is, "$_ ~~ EXPR". (See "Smartmatch Operator" in perlop for more information on smartmatching.) But when *EXPR* is one of the 10 exceptional cases (or things like them) listed below, it is used directly as a boolean.
603 :     4.  A boolean comparison operator such as "$_ < 10" or "$x eq "abc"". The relational operators that this applies to are the six numeric comparisons ("<", ">", "<=", ">=", "==", and "!="), and the six string comparisons ("lt", "gt", "le", "ge", "eq", and "ne").
605 :         NOTE: You will often have to use "$c ~~ $_" because the default case uses "$_ ~~ $c" , which is frequently the opposite of what you want.
625 :         when (/^\d+$/ && $_ < 75) { ... }
627 :     will be treated as a boolean match because the rules say both a regex match and an explicit test on $_ will be treated as boolean.
716 :     This doesn't work if you explicitly specify a loop variable, as in "for $item (@array)". You have to use the default variable $_.
perlsub.pod
44 :     Any arguments passed in show up in the array @_. (They may also show up in lexical variables introduced by a signature; see "Signatures" below.) Therefore, if you called a function with two arguments, those would be stored in $_[0] and $_[1]. The array @_ is a local array, but its elements are aliases for the actual scalar parameters. In particular, if an element $_[0] is updated, the corresponding argument is updated (or an error occurs if it is not updatable). If an argument is an array or hash element which did not exist when the function was called, that element is created only when (and if) it is modified or a reference to it is taken. (Some earlier versions of Perl created the element whether or not the element was assigned to.) Assigning to the whole array @_ removes that aliasing, and does not update any arguments.
200 :             my $left = $_[0];
201 :             my $right = $_[1];
249 :             print $filter->($_) foreach @inputs;
261 :             print $filter->($_, $inputs{$_}) foreach sort keys %inputs;
284 :         sub foo :prototype($) { $_[0] }
527 :     One exception is the default scalar variable: starting with perl 5.14 "local($_)" will always strip all magic from $_, to make it possible to safely reuse $_ in a subroutine.
557 :         print join(' ', map { "$_ $hash{$_}" } sort keys %hash),".\n";
559 :               join(', ', map { defined $_ ? $_ : 'undef' } @ary),"\n";
741 :     Scalars are already passed by reference, so you can modify scalar arguments without using this mechanism by referring explicitly to $_[0] etc. You can modify all the elements of an array by passing all the elements as scalars, but you have to use the "*" mechanism (or the equivalent reference mechanism) to "push", "pop", or change the size of an array. It will certainly be faster to pass the typeglob (or reference).
748 :     1.  You need to give a global variable a temporary value, especially $_.
755 :                 local $_ = <>;  
759 :         It particular, it's important to "local"ize $_ in any routine that assigns to it. Look out for implicit assignments in "while" conditionals.
823 :             return grep { $seen{$_} == @_ } keys %seen;
958 :     As the last character of a prototype, or just before a semicolon, a "@" or a "%", you can use "_" in place of "$": if this argument is not provided, $_ will be used instead.
975 :                 local $_ = $@;
979 :         sub catch (&) { $_[0] }
994 :             foreach $_ (@_) {
995 :                 push(@result, $_) if &$code;
perlvar.pod
29 :     Before you continue, note the sort order for variables. In general, we first list the variables in case-insensitive, almost-lexigraphical order (ignoring the "{" or "^" preceding words, as in "${^UNICODE}" or $^T), although $_ and @_ move up to the top of the pile. For variables with the same identifier, we list it in order of scalar, array, hash, and bareword.
33 :     $_      The default input and pattern-searching space. The following pairs are equivalent:
36 :                 while (defined($_ = <>)) {...}
39 :                 $_ =~ /^Subject:/
42 :                 $_ =~ tr/a-z/A-Z/
45 :                 chomp($_)
47 :             Here are the places where Perl will assume $_ even if you don't use it:
49 :             *  The following functions use $_ as a default argument:
65 :             $_ is by default a global variable. However, as of perl v5.10.0, you can use a lexical version of $_ by declaring it in a file or in a block with "my". Moreover, declaring "our $_" restores the global $_ in the current scope. Though this seemed like a good idea at the time it was introduced, lexical $_ actually causes more problems than it solves. If you call a function that expects to be passed information via $_, it may or may not work, depending on how the function is written, there not being any easy way to solve this. Just avoid lexical $_, unless you are feeling particularly masochistic. For this reason lexical $_ is still experimental and will produce a warning unless warnings have been disabled. As with other experimental features, the behavior of lexical $_ is subject to change without notice, including change into a fatal error.
282 :                 local $SIG{__WARN__} = sub { die $_[0] };
483 :                 local $_ = 'abcdefghi';
551 :             Thus, after a match against $_, $& coincides with "substr $_, $-[0], $+[0] - $-[0]". Similarly, $*n* coincides with "substr $_, $-[n], $+[n] - $-[n]" if $-[n] is defined, and $+ coincides with "substr $_, $-[$#-], $+[$#-] - $-[$#-]". One can use $#- to find the last matched subgroup in the last successful match. Contrast with $#+, the number of subgroups in the regular expression. Compare with "@+".
666 :             print "$_";
671 :             # do something with $_
694 :     ARGVOUT The special filehandle that points to the currently open output file when doing edit-in-place processing with -i. Useful when you have to do a lot of inserting and don't want to keep modifying $_. See perlrun for the -i switch.
726 :                 local $_ = <FH>;    # whole file now here
735 :                 local $_ = <$fh>;
perlpacktut.pod
43 :             my $date   = substr($_,  0, 11);
44 :             my $desc   = substr($_, 12, 27);
45 :             my $income = substr($_, 40,  7);
46 :             my $expend = substr($_, 52,  7);
65 :             my($date, $desc, $income, $expend) = unpack("A10xA27xA7A*", $_);
81 :         my($date) = unpack("A10", $_);
87 :         my($date,$description,$income) = unpack("A10xA27xA7", $_);
96 :             unpack("A10xA27xA7xA*", $_);
102 :                 unpack("A10xA27xA7xA*", $_);
371 :        join( '', map( substr( $_, 0, 1 ), @str ) )
385 :        $pd = pack( '(CCS)*', map( @$_, @dates ) );
450 :                        map( { ( $_, '=', $Env{$_} ) } keys( %Env ) ), 0 );
452 :     Let's examine the cogs of this byte mill, one by one. There's the "map" call, creating the items we intend to stuff into the $env buffer: to each key (in $_) it adds the "=" separator and the hash entry value. Each triplet is packed with the template code sequence "A*A*Z*" that is repeated according to the number of keys. (Yes, that's what the "keys" function returns in scalar context.) To get the very last null byte, we add a 0 at the end of the "pack" list, to be packed with "C". (Attentive readers may have noticed that we could have omitted the 0.)
457 :        my %env = map( split( /=/, $_ ), unpack( "(Z*)$n", $env ) );
603 :              map{ ( $_->{count}, $_->{glyph} ) } @buffer );
608 :              map{ ( $_->{count}, $_->{glyph} ) } @buffer );
699 :         print map( ++$i % 16 ? "$_ " : "$_\n",
perlretut.pod
51 :     If you're matching against the special default variable $_, the "$_ =~" part can be omitted:
53 :         $_ = "Hello World";
142 :     This program is easy to understand. "#!/usr/bin/perl" is the standard way to invoke a perl program from the shell. "$regexp = shift;" saves the first command line argument as the regexp to be used, leaving the rest of the command line arguments to be treated as files. "while (<>)" loops over all the lines in all the files. For each line, "print if /$regexp/;" prints the line if the regexp matches the line. In this line, both "print" and "/$regexp/" use the default variable $_ implicitly.
908 :     Regular expressions also play a big role in *search and replace* operations in Perl. Search and replace is accomplished with the "s///" operator. The general form is "s/regexp/replacement/modifiers", with everything we know about regexps and modifiers applying in this case as well. The "replacement" is a Perl double-quoted string that replaces in the string whatever is matched with the "regexp". The operator "=~" is also used here to associate a string with "s///". If matching against $_, the "$_ =~" can be dropped. If there is a match, "s///" returns the number of substitutions made; otherwise it returns false. Here are a few examples:
942 :     In "simple_replace" we used the "s///g" modifier to replace all occurrences of the regexp on each line. (Even though the regular expression appears in a loop, Perl is smart enough to compile it only once.) As with "simple_grep", both the "print" and the "s/$regexp/$replacement/g" use $_ implicitly.
967 :         print "frequency of '$_' is $chars{$_}\n"
1127 :         $regexp[$_] = shift foreach (0..$number-1);
1128 :         @compiled = map qr/$_/, @regexp;
1154 :         $regexp[$_] = shift foreach (0..$number-1);
1164 :         $regexp[$_] = shift foreach (0..$number-1);
1512 :        printf "%3d '%s'\n", $count{$_}, $_ for (sort keys %count);
1516 :        $count{lc($_)}++ for split('', "supercalifragilisticexpialidocious");
1517 :        printf "%3d '%s'\n", $count2{$_}, $_ for ( qw{ a e i o u } );
perlre.pod
233 :         $_ **= $_ , / {$_} / for 2 .. 42;
383 :         $_ = "123456789";
687 :         Inside a "(?{...})" block, $_ refers to the string the regular expression is matching against. You can also use "pos()" to know what is the current position of matching within this string.
691 :           $_ = 'a' x 8;
718 :           $_ = "The brown fox jumps over the lazy dog";
1090 :         $_ = "Food is on the foo table.";
1099 :         $_ =  "The food is under the bar in the barn.";
1115 :         $_ = "I have 2 numbers: 53147";
1126 :         $_ = "I have 2 numbers: 53147";
1162 :         $_ = "ABC123";
1164 :             print "Yup, no 123 in $_\n";
1304 :         $_ = 'bar';
1382 :         sub invalid { die "/$_[0]/: invalid escape '\\$_[1]'"}
perlebcdic.pod
439 :          -e '{push(@l,$_)}' \
440 :          -e 'END{print map{$_->[0]}' \
442 :          -e '          map{[$_,substr($_,34,3)]}@l;}' perlebcdic.pod
450 :         -e '{push(@l,$_)}' \
451 :         -e 'END{print map{$_->[0]}' \
453 :         -e '          map{[$_,substr($_,39,3)]}@l;}' perlebcdic.pod
461 :          -e '{push(@l,$_)}' \
462 :          -e 'END{print map{$_->[0]}' \
464 :          -e '          map{[$_,substr($_,44,3)]}@l;}' perlebcdic.pod
843 :         for (0..255) { $all_byte_chrs .= chr($_); }
866 :         $_ = <> until ($mode,$file) = /^begin\s*(\d*)\s*(\S*)/;
873 :             print OUT unpack("u", $_);
perlintro.pod
109 :         There are a number of "magic" scalars with names that look like punctuation or line noise. These special variables are used for all kinds of purposes, and are documented in perlvar. The only one you need to know about for now is $_ which is the "default variable". It's used as the default argument to a number of functions in Perl, and it's set implicitly by certain looping constructs.
111 :          print;          # prints contents of $_ by default
281 :              print "This element is $_\n";
284 :          print $list[$_] foreach 0 .. $max;
286 :          # you don't have to use the default $_ either...
359 :      while (<$in>) {     # assigns each line in turn to $_
360 :          print "Just read in this line: $_";
377 :          if (/foo/)       { ... }  # true if $_ contains "foo"
380 :         The "//" matching operator is documented in perlop. It operates on $_ by default, or can be bound to another variable using the "=~" binding operator (also documented in perlop).
383 :          s/foo/bar/;               # replaces foo with bar in $_
465 :      my $logmessage = $_[0];                 # uncommon, and ugly
perluniintro.pod
199 :         while (<$nihongo>) { print $unicode $_ }
227 :            map { $_ > 255 ?                  # if wide character...
228 :                   sprintf("\\x{%04X}", $_) :  # \x{...}
229 :                   chr($_) =~ /[[:cntrl:]]/ ?  # else if control character...
230 :                   sprintf("\\x%02X", $_) :    # \x..
231 :                   quotemeta(chr($_))          # else quoted or as themselves
232 :              } unpack("W*", $_[0]));           # unpack Unicode characters
perldiag.pod
1578 :             sub mod { $_[0] = 1 }
2606 :         (W syntax) You have used a pattern where Perl expected to find a string, as in the first argument to "join". Perl will treat the true or false result of matching the pattern against $_ as the string, which is probably not what you had in mind.
3360 :     Use of my $_ is experimental
3361 :         (S experimental::lexical_topic) Lexical $_ is an experimental feature and its behavior may change or even be removed in any future release of perl. See the explanation under "$_" in perlvar.
3376 :     Use of state $_ is experimental
3377 :         (S experimental::lexical_topic) Lexical $_ is an experimental feature and its behavior may change or even be removed in any future release of perl. See the explanation under "$_" in perlvar.
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.
136 :     *   An object's members cannot be made accessible as variables. The closest Perl equivalent to "with(object) { method() }" is "for", which can alias $_ to the object:
139 :                 $_->method;
181 :     *   People have a hard time remembering that some functions default to $_, or @ARGV, or whatever, but that others which you might expect to do not.
183 :     *   The <FH> construct is not the name of the filehandle, it is a readline operation on that handle. The data read is assigned to $_ only if the file read is the sole condition in a while loop:
186 :             while (defined($_ = <FH>)) { }..
perltie.pod
209 :                   $self->STORE( $_, '' );
268 :               $self->STORE( $last + $_, $list[$_] ) foreach 0 .. $#list;
298 :               $self->STORE( $_, $list[$_] ) foreach 0 .. $#list;
405 :                 foreach $dot ( grep /^\./ && -f "$dir/$_", readdir(DIR)) {
611 :             sub PRINT { $r = shift; $$r++; print join($,,map(uc($_),@_)),$\ }
629 :                 my $bufref = \$_[0];
perldbmfilter.pod
38 :     When each filter is called by Perl, a local copy of $_ will contain the key or value to be filtered. Filtering is achieved by modifying the contents of $_. The return code from the filter is ignored.
65 :         $db->filter_store_key  ( sub { $_ .= "\0" } );
68 :         $db->filter_store_value( sub { $_ .= "\0" } );
100 :         $db->filter_fetch_key  ( sub { $_ = unpack("i", $_) } );
101 :         $db->filter_store_key  ( sub { $_ = pack ("i", $_) } );
perllocale.pod
262 :                 printf "%-20s = %s\n", $_, $locale_values->{$_}
297 :             $_ = int;    # Chop non-integer part
300 :             print "$_";
416 :                 $long_month_name[$_] =
417 :                     strftime("%B", 0, 0, 0, 1, $_, 96);
perlcall.pod
456 :             ++ $_[0];
457 :             ++ $_[1];
586 :         sub new { bless {}, $_[0] }
736 :             foreach (@list) { print "$_\n" }
1283 :     It is usual to pass parameters using global variables (typically $_ for one parameter, or $a and $b for two parameters) rather than via @_. (It is possible to use the @_ mechanism if you know what you're doing, though there is as yet no supported API for it. It's also inherently slower.)
perlport.pod
333 :         while (<$fh>) {$file .= $_}                # sometimes bad
516 :     For ODS-2, filenames are in the format "name.extension;version". The maximum length for filenames is 39 characters, and the maximum length for extensions is also 39 characters. Version is a number from 1 to 32767. Valid characters are "/[A-Z0-9$_-]/".
552 :      $ perl -ne "$_=~s/\s+.*//; print if scalar(split /\//) > 8;" < MANIFEST
821 :     exit    Emulates Unix exit() (which considers "exit 1" to indicate an error) by mapping the 1 to SS$_ABORT (44). This behavior may be overridden with the pragma "use vmsish 'exit'". As with the CRTL's exit() function, "exit 0" is also mapped to an exit status of SS$_NORMAL (1); this mapping cannot be overridden. Any other argument to exit() is used directly as Perl's exit status. On VMS, unless the future POSIX_EXIT mode is enabled, the exit code should always be a valid VMS exit code and not a generic number. When the POSIX_EXIT mode is enabled, a generic number will be encoded in a method compatible with the C library _POSIX_EXIT macro so that it can be decoded by other programs, particularly ones written in C, like the GNV package. (VMS)
perlrequick.pod
28 :     If you're matching against $_, the "$_ =~" part can be omitted:
30 :         $_ = "Hello World";
276 :     Search and replace is performed using "s/regex/replacement/modifiers". The "replacement" is a Perl double-quoted string that replaces in the string whatever is matched with the "regex". The operator "=~" is also used here to associate a string with "s///". If matching against $_, the "$_ =~" can be dropped. If there is a match, "s///" returns the number of substitutions made; otherwise it returns false. Here are a few examples:
291 :     The non-destructive modifier "s///r" causes the result of the substitution to be returned instead of modifying $_ (or whatever variable the substitute was bound to with "=~"):
perldsc.pod
372 :          push @AoH, { parsepairs($_) };
512 :      for ( qw(lead wife son daughter pal pet) ) { $rank{$_} = ++$i }
533 :              THISCODE  => sub { $_[0] ** $_[1] },
653 :              print join (", ", map { $_->{name} } @{ $TV{$family}{kids} } );
perlvms.pod
269 :     die "die" will force the native VMS exit status to be an SS$_ABORT code if neither of the $! or $? status values are ones that would cause the native status to be interpreted as being what VMS classifies as SEVERE_ERROR severity for DCL error handling.
437 :         Conversely, when setting $? in an END block, an attempt is made to convert the POSIX value into a native status intelligible to the operating system upon exiting Perl. What this boils down to is that setting $? to zero results in the generic success value SS$_NORMAL, and setting $? to a non-zero value results in the generic failure status SS$_ABORT. See also "exit" in perlport.
441 :         The pragma "use vmsish 'status'" makes $? reflect the actual VMS exit status instead of the default emulation of POSIX status described above. This pragma also disables the conversion of non-zero values to SS$_ABORT when setting $? in an END block (but zero will still be converted to SS$_NORMAL).
perlref.pod
374 :         *$name = sub ($) { "<FONT COLOR='$name'>$_[0]</FONT>" };
385 :             my $x = $_[0] + 35;
393 :             my $x = $_[0] + 35;
perlunicode.pod
883 :                  defined && /[^\000-\177]/ && Encode::_utf8_on($_);
892 :                    && Encode::_utf8_on($_) for $ret->{$k};
896 :                  defined && /[^\000-\177]/ && Encode::_utf8_on($_) for $ret;
perldebtut.pod
296 :             DB<4> p 'saw -> '.($cnt += map { print "\t:\t$_\n" } grep(/the/, sort @data))
308 :             4: p 'saw -> '.($cnt += map { print "\t:\t$_\n" } grep(/the/, sort @data))
318 :             p 'saw -> '.($cnt += map { print "$_\n" } grep(/the/, sort @data))
perlperf.pod
612 :             my $line = $_;
687 :             map $_->[0] =>
700 :             map  [ $_, m/^(
perlutil.pod
40 :                ($Fld1,$Fld2) = split(/[:\n]/, $_, -1);
60 :                (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
perlobj.pod
138 :     Just as with any Perl subroutine, all of the arguments passed in @_ are aliases to the original argument. This includes the object itself. If you assign directly to $_[0] you will change the contents of the variable that holds the reference to the object. We recommend that you don't do this unless you know exactly what you're doing.
554 :     This is called just like any other method, with the object as the first argument. It does not receive any additional arguments. However, the $_[0] variable will be read-only in the destructor, so you cannot assign a value to it.
perlmod.pod
12 :     Only identifiers starting with letters (or underscore) are stored in a package's symbol table. All other symbols are kept in package "main", including all punctuation variables, like $_. In addition, when unqualified, the identifiers STDIN, STDOUT, STDERR, ARGV, ARGVOUT, ENV, INC, and SIG are forced to be in package "main", even when used for other purposes than their built-in ones. If you have a package called "m", "s", or "y", then you can't use the qualified form of an identifier because it would be instead interpreted as a pattern match, a substitution, or a transliteration.
14 :     Variables beginning with underscore used to be forced into package main, but we decided it was more useful for package writers to be able to use leading underscore to indicate private variables and method names. However, variables and functions named with a single "_", such as $_ and "sub _", are still forced into the package "main". See also "The Syntax of Variable Names" in perlvar.
perlrun.pod
357 :              perl -lpe 'substr($_, 80) = ""'
361 :              gnufind / -print0 | perl -ln0e 'print "found $_" if -p'
perllol.pod
292 :         @newAoA = map { [ @{ $AoA[$_] } [ 7..12 ] ] } 4 .. 8;
303 :                 [ @{ $lrr->[$_] } [ $y_lo .. $y_hi ] ]
perlreref.pod
8 :     "=~" determines to which variable the regex is applied. In its absence, $_ is used.
239 :        $_    Default variable for operators to use
perlfilter.pod
175 :     If a line was available from the source stream, "filter_read()" returns a status value greater than zero and appends the line to $_. A status value of zero indicates end-of-file, less than zero means an error. The filter function itself is expected to return its status in the same way, and put the filtered line it wants written to the source stream in $_. The use of $_ accounts for the brevity of most Perl source filters.
perliol.pod
503 :      FAILURE        Set errno (to EINVAL in Unixish, to LIB$_INVARG in VMS) and
perlcheat.pod
60 :        0 dev    0 second      0 package     $_    default variable
perlform.pod
223 :      $_
perlreapi.pod
103 :         If "split" is invoked as "split ' '" or with no arguments (which really means "split(' ', $_)", see split), Perl will set this flag. The regex engine can then check for it and set the SKIPWHITE and WHITE extflags. To do this, the Perl engine does:
perlexperiment.pod
26 :     Lexical $_
perlopentut.pod
76 :             # do something with data in $_
perlunifaq.pod
109 :         print { $barfh } $_ while <$foofh>;
<< Back to Perldoc Search