Perldoc Search: "$/" perl-5.20.1

search official POD


31 PODs, 172 LINEs found.
perlretut.pod
148 :         "housekeeper" =~ /keeper$/;   # matches
149 :         "housekeeper\n" =~ /keeper$/; # matches
155 :         "keeper" =~ /^keep$/;      # doesn't match
156 :         "keeper" =~ /^keeper$/;    # matches
157 :         ""       =~ /^$/;          # ^$ matches an empty string
166 :         "bertram" =~ /^bert$/; # doesn't match, good
167 :         "dilbert" =~ /^bert$/; # doesn't match, good
168 :         "bert"    =~ /^bert$/; # matches, perfect
263 :         ""   =~ /^$/;    # matches
264 :         "\n" =~ /^$/;    # matches, $ anchors before "\n"
267 :         ""   =~ /^.$/;    # doesn't match; it needs a char
268 :         "\n" =~ /^.$/;    # doesn't match; it needs a char other than "\n"
269 :         "a"  =~ /^.$/;    # matches
270 :         "a\n"  =~ /^.$/;  # matches, $ anchors before "\n"
301 :         $x =~ /girl$/m;  # matches, "girl" at end of first line
428 :         if ($line =~ /^(\w+)=$a99a$/){   # unexpected behavior!
540 :         $year =~ /^\d{2,4}$/;  # make sure year is at least 2 but not more
542 :         $year =~ /^\d{4}$|^\d{2}$/; # better match; throw out 3-digit dates
543 :         $year =~ /^\d{2}(\d{2})?$/; # same thing written differently.
558 :         $x =~ /^(.*)(cat)(.*)$/; # matches,
565 :         $x =~ /^(.*)(at)(.*)$/; # matches,
587 :         $x =~ /^(.+)(e|r)(.*)$/;  # matches,
594 :         $x =~ /(m{1,2})(.*)$/;  # matches,
600 :         $x =~ /.*(m{1,2})(.*)$/;  # matches,
606 :         $x =~ /(.?)(m{1,2})(.*)$/;  # matches,
634 :         $x =~ /^(.+?)(e|r)(.*)$/; # matches,
641 :         $x =~ /(m{1,2}?)(.*?)$/;  # matches,
647 :         $x =~ /(.*?)(m{1,2}?)(.*)$/;  # matches,
654 :         $x =~ /(.??)(m{1,2})(.*)$/;  # matches,
668 :         $x =~ /^(.*)(at)(.*)$/; # matches,
696 :         /^\w+\s+\w+$/; # a word, spaces, a word
739 :         /^(optional sign)(integer | f.p. mantissa)(optional exponent)$/;
747 :        /^[+-]?(\d+\.\d+|\d+\.|\.\d+|\d+)([eE][+-]?\d+)?$/;  # Ta da!
760 :        $/x;
773 :        $/x;
787 :        $/x;
791 :         /^[+-]?\ *(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/;
831 :         $x =~ /^\s*(\w+)\s+(\w+)\s+(\w+)\s*$/; # matches,
912 :         if ($x =~ s/^(Time.*hacker)!$/$1 now!/) {
916 :         $y =~ s/^'(.*)'$/$1/;  # strip single quotes,
1172 :             $cmd =~ s/^\s+|\s+$//g;  # trim leading and trailing spaces
1316 :         /[ATGC]+(?(?<=AA)G|C)$/;
1343 :         my $pp = qr/^(\W* (?: (\w) (?1) \g{-1} | \w? ) \W*)$/ix;
1500 :         /^1(?:((??{ $z0 }))1(?{ $z0 = $z1; $z1 .= $^N; }))+$/
1536 :         /^(.*)$/s;       # output debugging info
1539 :         /^(.*)$/s;       # output debugging info in living color
perlop.pod
375 :         say "some keys end in e" if /e$/ ~~  %hash;
376 :         say "some keys end in e" if /e$/ ~~ \%hash;
556 :         next LINE if (1 .. /^$/);  # skip header lines, short for
557 :                                    #   next LINE if ($. == 1 .. /^$/);
560 :         s/^/> / if (/^$/ .. eof());  # quote body
564 :             $in_header =   1  .. /^$/;
565 :             $in_body   = /^$/ .. eof;
1083 :                 local $/ = "";
1109 :              local $/ = "";
1267 :                 s/^\s*(.*?)\s*$/$1/;        # trim whitespace in $_,
1273 :                     s/\s+$//;
1308 :         A string which is (possibly) interpolated and then executed as a system command with /bin/sh or its equivalent. Shell wildcards, pipes, and redirections will be honored. The collected standard output of the command is returned; standard error is unaffected. In scalar context, it comes back as a single (potentially multi-line) string, or undef if the command failed. In list context, returns a list of lines (however you've defined lines with $/ or $INPUT_RECORD_SEPARATOR), or an empty list if the command failed.
1665 :     A string enclosed by backticks (grave accents) first undergoes double-quote interpolation. It is then interpreted as an external command, and the output of that command is the value of the backtick string, like in a shell. In scalar context, a single string consisting of all output is returned. In list context, a list of values is returned, one per line of output. (You can set $/ to use a different line terminator.) The command is executed each time the pseudo-literal is evaluated. The status value of the command is returned in $? (see perlvar for the interpretation of $?). Unlike in csh, no translation is done on the return data--newlines remain newlines. Unlike in any of the shells, single quotes do not hide variable names in the command from interpretation. To pass a literal dollar-sign through to the shell you need to hide it with a backslash. The generalized form of backticks is "qx//". (Because backticks always undergo shell expansion as well, see perlsec for security concerns.)
1667 :     In scalar context, evaluating a filehandle in angle brackets yields the next line from that file (the newline, if any, included), or "undef" at end-of-file or on error. When $/ is set to "undef" (sometimes known as file-slurp mode) and the file is empty, it returns '' the first time, followed by "undef" subsequently.
1732 :         @ARGV = map { /\.(gz|Z)$/ ? "gzip -dc < $_ |" : $_ } @ARGV;
1738 :             last if /^--$/;
perlvar.pod
356 :                       unless $this_perl =~ m/$Config{_exe}$/i;
365 :                         unless $secure_perl_path =~ m/$Config{_exe}$/i;
638 :         local $/; # enable localized slurp mode
645 :         undef $/; # enable slurp mode
649 :     since some other module, may want to read data from some file in the default "line mode", so if the code we have just presented has been executed, the global value of $/ is now changed for any other code running inside the same Perl interpreter.
656 :             local $/;
710 :             Each filehandle in Perl counts the number of lines that have been read from it. (Depending on the value of $/, Perl's idea of what constitutes a line may not match yours.) When a line is read from a filehandle (via "readline()" or "<>"), or when "tell()" or "seek()" is called on it, $. becomes an alias to the line counter for that filehandle.
723 :     $/      The input record separator, newline by default. This influences Perl's idea of what a "line" is. Works like awk's RS variable, including treating empty lines as a terminator if set to the null string (an empty line cannot contain any spaces or tabs). You may set it to a multi-character string to match a multi-character terminator, or to "undef" to read through the end of file. Setting it to "\n\n" means something slightly different than setting to "", if the file contains consecutive empty lines. Setting to "" will treat two or more consecutive empty lines as a single empty line. Setting to "\n\n" will blindly assume that the next input character belongs to the next paragraph, even if it's a newline.
725 :                 local $/;           # enable "slurp" mode
729 :             Remember: the value of $/ is a string, not a regex. awk has to be better for something. :-)
731 :             Setting $/ to a reference to an integer, scalar containing an integer, or scalar that's convertible to an integer will attempt to read records instead of lines, with the maximum record size being the referenced integer number of characters. So this:
733 :                 local $/ = \32768; # or \"32768", or \$var_containing_32768
737 :             will read a record of no more than 32768 characters from $fh. If you're not reading from a record-oriented file (or your OS doesn't have record-oriented files), then you'll likely get a full chunk of data with every read. If a record is larger than the record size you've set, you'll get the record back in pieces. Trying to set the record size to zero or less is deprecated and will cause $/ to have the value of "undef", which will cause reading in the (rest of the) whole file.
739 :             As of 5.19.9 setting $/ to any other form of reference will throw a fatal exception. This is in preparation for supporting new ways to set $/ in the future.
756 :             Mnemonic: you set $\ instead of adding "\n" at the end of the print. Also, it's just like $/, but it's what you get "back" from Perl.
perlfunc.pod
282 :         binmode() is important not only for readline() and print() operations, but also when using read(), seek(), sysread(), syswrite() and tell() (see perlport for more details). See the $/ and $\ variables in perlvar for how to manually set your input and output line-termination sequences.
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.
659 :         If the last element of LIST does not end in a newline, the current script line number and input line number (if any) are also printed, and a newline is supplied. Note that the "input line number" (also known as "chunk") is subject to whatever notion of "line" happens to be currently in effect, and is also available as the special variable $.. See "$/" in perlvar and "$." in perlvar.
1569 :                 last LINE if /^$/;  # exit when done with header
2092 :             $filename =~ s/(.*\.gz)\s*$/gzip -dc < $1|/;
2780 :         Reads from the filehandle whose typeglob is contained in EXPR (or from *ARGV if EXPR is not provided). In scalar context, each call reads and returns the next line until end-of-file is reached, whereupon the subsequent call returns "undef". In list context, reads until end-of-file is reached and returns a list of lines. Note that the notion of "line" used here is whatever you may have defined with $/ or $INPUT_RECORD_SEPARATOR). See "$/" in perlvar.
2782 :         When $/ is set to "undef", when "readline" is in scalar context (i.e., file slurp mode), and when an empty file is read, it returns '' the first time, followed by "undef" subsequently.
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 $_.
4056 :         Note that if you have to look for strings that you don't know till runtime, you can build an entire loop as a string and "eval" that to avoid recompiling all your patterns all the time. Together with undefining $/ to input entire files as one record, this can be quite fast, often faster than specialized programs like fgrep(1). The following scans a list of files (@files) for a list of words (@words), and prints out the names of those files that contain a match:
4064 :             undef $/;
4066 :             $/ = "\n";        # put back to normal input delimiter
4468 :                 local $/;  # slurp!
perlrebackslash.pod
167 :          /^($pat)\1000$/;   #  Matches 'aa'; there are 1000 capture groups.
168 :          /^$pat\1000$/;     #  Matches 'a@0'; there are 999 capture groups
284 :         "\z" and "\Z" match at the end of the string. If the "/m" modifier isn't used, then "/\Z/" is equivalent to "/$/"; that is, it matches at the end of the string, or one before the newline at the end of the string. If the "/m" modifier is used, then "/$/" matches at internal newlines, but the meaning of "/\Z/" isn't changed by the "/m" modifier. "\Z" matches at the end of the string (or just before a trailing newline) regardless whether the "/m" modifier is used.
343 :          "\x0D\x0A" =~ /^\R\x0A$/   # No match
363 :      "\n"   =~ /^\R$/;         # Match, \n   is a generic newline.
364 :      "\r"   =~ /^\R$/;         # Match, \r   is a generic newline.
365 :      "\r\n" =~ /^\R$/;         # Match, \r\n is a generic newline.
367 :      "P\x{307}" =~ /^\X$/     # \X matches a P with a dot above.
perlrequick.pod
80 :         "housekeeper" =~ /keeper$/;        # matches
81 :         "housekeeper\n" =~ /keeper$/;      # matches
82 :         "housekeeper" =~ /^housekeeper$/;  # matches
238 :         $year =~ /^\d{2,4}$/;  # make sure year is at least 2 but not more
240 :         $year =~ /^\d{4}$|^\d{2}$/; # better match; throw out 3 digit dates
245 :         $x =~ /^(.*)(at)(.*)$/; # matches,
281 :         $y =~ s/^'(.*)'$/$1/;  # strip single quotes,
perldata.pod
135 :         warn "not a natural number" unless /^\d+$/;             # rejects -3
136 :         warn "not an integer"       unless /^-?\d+$/;           # rejects +3
137 :         warn "not an integer"       unless /^[+-]?\d+$/;
138 :         warn "not a decimal number" unless /^-?\d+\.?\d*$/;     # rejects .2
139 :         warn "not a decimal number" unless /^-?(?:\d+(?:\.\d*)?|\.\d+)$/;
141 :             unless /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/;
457 :             s/\s+$//;           # trim trailing whitespace
perldiag.pod
2581 :     Setting $/ to a reference to %s as a form of slurp is deprecated, treating as undef
2582 :         (W deprecated) You assigned a reference to a scalar to $/ where the referenced item is not a positive integer. In older perls this appeared to work the same as setting it to "undef" but was in fact internally different, less efficient and with very bad luck could have resulted in your file being split by a stringified form of the reference.
2584 :         In Perl 5.20.0 this was changed so that it would be exactly the same as setting $/ to undef, with the exception that this warning would be thrown.
2586 :         You are recommended to change your code to set $/ to "undef" explicitly if you wish to slurp the file. In future versions of Perl assigning a reference to will throw a fatal error.
2588 :     Setting $/ to %s reference is forbidden
2589 :         (F) You tried to assign a reference to a non integer to $/. In older Perls this would have behaved similarly to setting it to a reference to a positive integer, where the integer was the address of the reference. As of Perl 5.20.0 this is a fatal error, to allow future versions of Perl to use non-integer refs for more interesting purposes.
perlsub.pod
305 :     The "my" operator declares the listed variables to be lexically confined to the enclosing block, conditional ("if/unless/elsif/else"), loop ("for/foreach/while/until/continue"), subroutine, "eval", or "do/require/use"'d file. If more than one value is listed, the list must be placed in parentheses. All listed elements must be legal lvalues. Only alphanumeric identifiers may be lexically scoped--magical built-ins like $/ must currently be "local"ized with "local" instead.
367 :         if ((my $answer = <STDIN>) =~ /^yes$/i) {
369 :         } elsif ($answer =~ /^no$/i) {
521 :         { local $/ = undef; $slurp = <FILE>; }
754 :                 local $/ = undef;
756 :                 @Fields = split /^\s*=+\s*$/;
perlrun.pod
22 :     Some switches do care if they are processed twice, for instance combinations of -l and -0. Either put all the switches after the 32-character boundary (if applicable), or replace the use of -0*digits* by "BEGIN{ $/ = "\0digits"; }".
114 :          specifies the input record separator ($/) as an octal or hexadecimal number. If there are no digits, the null character is the separator. Other switches may precede or follow the digits. For example, if you have a version of *find* which can print filenames terminated by the null character, you can say this:
355 :          enables automatic line-ending processing. It has two separate effects. First, it automatically chomps $/ (the input record separator) when used with -n or -p. Second, it assigns $\ (the output record separator) to have the value of *octnum* so that any print statements will have that separator added back on. If *octnum* is omitted, sets $\ to the current value of $/. For instance, to trim lines to 80 columns:
359 :          Note that the assignment "$\ = $/" is done when the switch is processed, so the input record separator can be different than the output record separator if the -l switch is followed by a -0 switch:
363 :          This sets $\ to newline and then sets $/ to the null character.
perlsyn.pod
180 :             last LINE if /^$/;      # exit when done with header
190 :             if (s/\\$//) {
201 :             if ($line =~ s/\\$//) {
528 :          $/x
625 :         when (/^\d+$/ && $_ < 75) { ... }
perlport.pod
37 :     When dealing with binary files (or text files in binary mode) be sure to explicitly set $/ to the appropriate value for your file format before using chomp().
51 :     When reading from a socket, remember that the default input record separator $/ is "\n", but robust socket code will recognize as either "\012" or "\015\012" as end of line:
60 :         local($/) = LF;      # not needed if $/ is already \012
236 :         {$thisperl .= $Config{_exe} unless $thisperl =~ m/$Config{_exe}$/i;}
243 :         {$thisperl .= $Config{_exe} unless $thisperl =~ m/$Config{_exe}$/i;}
perlrecharclass.pod
24 :      "ab" =~  /^.$/     # No match (dot matches one character)
215 :      "ae" =~  /^[aeiou]$/      # No match, a character class only matches
217 :      "ae" =~  /^[aeiou]+$/     # Match, due to the quantifier.
289 :      "ss" =~ /^[^\xDF]+$/ui;   # Matches!
perltie.pod
47 :                 if ($pid !~ /^\d+$/) {
391 :                 $user = getpwuid($user) if $user =~ /^\d+$/;
639 :         As per "readline", in scalar context it should return the next line, or "undef" for no more data. In list context it should return all remaining lines, or an empty list for no more data. The strings returned should include the input record separator $/ (see perlvar), unless it is "undef" (which means "slurp" mode).
perldebtut.pod
337 :             if ($arg =~ /^\-(c|f)((\-|\+)*\d+(\.\d+)*)$/) {
348 :                     $out =~ s/^((\-|\+)*\d+)\.0+$/$1/;
501 :             > perl -Dr -e '/^pe(a)*rl$/i'
perldbmfilter.pod
64 :         $db->filter_fetch_key  ( sub { s/\0$//    } );
67 :             sub { no warnings 'uninitialized'; s/\0$// } );
perlintro.pod
421 :          /^$/                nothing in the string (start and end are
430 :              next if /^$/;
perltrap.pod
16 :         allows you to refer to special variables (like $/) with names (like $RS), as though they were in awk; see perlvar for details.
66 :               RS        $/
perlembed.pod
570 :             local($/) = undef;
593 :          #print Devel::Symdump->rnew($package)->as_string, $/;
perlipc.pod
619 :         die "invalid port" unless if $port =~ /^ \d+ $/x;
660 :         die "invalid port" unless $port =~ /^ \d+ $/x;
perlebcdic.pod
904 :         $string =~ s/=[\n\r]+$//;
909 :         $string =~ s/=[\n\r]+$//;
perlperf.pod
626 :                 )$/x
712 :             )$/xo ]
perlreguts.pod
240 :     Now for something much more complex: "/x(?:foo*|b[a][rR])(foo|bar)$/"
perlre.pod
1197 :     In other words, the two zero-width assertions next to each other work as though they're ANDed together, just as you'd use any built-in assertions: "/^$/" matches only if you're at the beginning of the line AND the end of the line simultaneously. The deeper underlying truth is that juxtaposition in regular expressions always means AND, except when you write an explicit OR using the vertical bar. "/ab/" means match "a" AND (then) match "b", although the attempted matches are made at different positions because "a" is not a zero-width assertion, but a one-width assertion.
perlpod.pod
52 :           =head2 Possible Values for C<$/>
perliol.pod
282 :         The *mode* string is an ""fopen()"-like" string which would match the regular expression "/^[I#]?[rwa]\+?[bt]?$/".
perlunitut.pod
36 :         if ($string =~ /^\d+$/) { ... }
perlsec.pod
117 :         if ($data =~ /^([-\@\w.]+)$/) {
perluniintro.pod
211 :         local $/; ## read in the whole file of 8-bit characters
perlcheat.pod
62 :        2 mode   2 hour        2 line        $/    input separator
perlform.pod
227 :      $/ = '';
<< Back to Perldoc Search