Perldoc Search: "$"" perl-5.20.1

search official POD


19 PODs, 69 LINEs found.
perlretut.pod
144 :     With all of the regexps above, if the regexp matched anywhere in the string, it was considered a match. Sometimes, however, we'd like to specify *where* in the string the regexp should try to match. To do this, we would use the *anchor* metacharacters "^" and "$". The anchor "^" means match at the beginning of the string and the anchor "$" means match at the end of the string, or before a newline at the end of the string. Here is how they are used:
151 :     The second regexp doesn't match because "^" constrains "keeper" to match only at the beginning of the string, but "housekeeper" has keeper starting in the middle. The third regexp does match, since the "$" constrains "keeper" to match only at the end of the string.
153 :     When both "^" and "$" are used at the same time, the regexp has to match both the beginning and the end of the string, i.e., the regexp matches the whole string. Consider
159 :     The first regexp doesn't match because the string has more to it than "keep". Since the second regexp is exactly the string, it matches. Using both "^" and "$" in a regexp forces the complete string to match, so it gives you complete control over which strings match and which don't. Suppose you are looking for a fellow named bert, off in a string by himself:
170 :     Of course, in the case of a literal string, one could just as easily use the string comparison "$string eq 'bert'" and it would be more efficient. The "^...$" regexp really becomes useful when we add in the more powerful regexp tools below.
189 :     We saw in the section above that there were ordinary characters, which represented themselves, and special characters, which needed a backslash "\" to represent themselves. The same is true in a character class, but the sets of ordinary and special characters inside a character class are different than those outside a character class. The special characters for a character class are "-]\^$" (and the pattern delimiter, whatever it is). "]" is special because it denotes the end of a character class. "$" is special because it denotes a scalar variable. "\" is special because it is used in escape sequences, just like above. Here is how the special characters "]$\" are handled:
197 :     The last two are a little tricky. In "[\$x]", the backslash protects the dollar sign, so the character class has two members "$" and "x". In "[\\$x]", the backslash is protected, so $x is treated as a variable and substituted in double quote fashion.
272 :     This behavior is convenient, because we usually want to ignore newlines when we count and match characters in a line. Sometimes, however, we want to keep track of newlines. We might even want "^" and "$" to anchor at the beginning and end of lines within the string, rather than just the beginning and end of the string. Perl allows us to choose between ignoring and paying attention to newlines by using the "//s" and "//m" modifiers. "//s" and "//m" stand for single line and multi-line and they determine whether a string is to be treated as one continuous string, or as a set of lines. The two modifiers affect two aspects of how the regexp is interpreted: 1) how the '.' character class is defined, and 2) where the anchors "^" and "$" are able to match. Here are the four possible combinations:
274 :     *   no modifiers (//): Default behavior. '.' matches any character except "\n". "^" matches only at the beginning of the string and "$" matches only at the end or before a newline at the end.
276 :     *   s modifier (//s): Treat string as a single long line. '.' matches any character, even "\n". "^" matches only at the beginning of the string and "$" matches only at the end or before a newline at the end.
278 :     *   m modifier (//m): Treat string as a set of multiple lines. '.' matches any character except "\n". "^" and "$" are able to match at the start or end of *any* line within the string.
280 :     *   both s and m modifiers (//sm): Treat string as a single long line, but detect multiple lines. '.' matches any character, even "\n". "^" and "$", however, are able to match at the start or end of *any* line within the string.
296 :     Most of the time, the default behavior is what is wanted, but "//s" and "//m" are occasionally very useful. If "//m" is being used, the start of the string can still be matched with "\A" and the end of the string can still be matched with the anchors "\Z" (matches both the end and the newline before, like "$"), and "\z" (matches only the end):
645 :     The first string position that this regexp can match is at the first 'm' in "programming". At this position, the minimal "m{1,2}?" matches just one 'm'. Although the second quantifier ".*?" would prefer to match no characters, it is constrained by the end-of-string anchor "$" to match the rest of the string.
1040 :     It does not protect "$" or "@", so that variables can still be substituted.
1236 :     Checking the environment entails either looking ahead on the trail, looking behind, or both. "^" looks behind, to see that there are no characters before. "$" looks ahead, to see that there are no characters after. "\b" looks both ahead and behind, to see if the characters on either side differ in their "word-ness".
perlop.pod
928 :     For constructs that do interpolate, variables beginning with ""$"" or ""@"" are interpolated. Subscripted variables such as $a[3] or "$href->{key}[0]" are also interpolated, as are array and hash slices. But method calls such as "$obj->meth" are not.
930 :     Interpolating an array or slice interpolates the elements in order, separated by the value of $", so is equivalent to interpolating "join $", @array". "Punctuation" arrays such as "@*" are usually interpolated only if the name is enclosed in braces "@{*}", but the arrays @_, "@+", and "@-" are interpolated even without braces.
940 :     For the pattern of regex operators ("qr//", "m//" and "s///"), the quoting from "\Q" is applied after interpolation is processed, but before escapes are processed. This allows the pattern to match literally (except for "$" and "@"). For example, the following matches:
944 :     Because "$" or "@" trigger interpolation, you'll need to use something like "/\Quser\E\@\Qhost/" to match them literally.
1600 :               $foo . " XXX '" . (join $", @arr) . "'";
1604 :             Because the result of "\Q STRING \E" has all metacharacters quoted, there is no way to insert a literal "$" or "@" inside a "\Q\E" pair. If protected by "\", "$" will be quoted to became "\\\$"; if not, it is interpreted as the start of an interpolated scalar.
perldiag.pod
633 :         (F) You've told Perl to dereference a string, something which "use strict" blocks to prevent it happening accidentally. See "Symbolic references" in perlref. This can be triggered by an "@" or "$" in a double-quoted string immediately before interpolating a variable, for example in "user @$twitter_id", which says to treat the contents of $twitter_id as an array reference; use a "\" to have a literal "@" symbol followed by the contents of $twitter_id: "user \@$twitter_id".
2484 :         (F) The lexer couldn't find the final delimiter of a // or m{} construct. Remember that bracketing delimiters count nesting level. Missing the leading "$" from a variable $m may cause this error.
2701 :         (F) The lexer couldn't find the interior delimiter of an s/// or s{}{} construct. Remember that bracketing delimiters count nesting level. Missing the leading "$" from variable $s may cause this error.
2704 :         (F) The lexer couldn't find the final delimiter of an s/// or s{}{} construct. Remember that bracketing delimiters count nesting level. Missing the leading "$" from variable $s may cause this error.
2892 :         (F) The lexer couldn't find the interior delimiter of a tr/// or tr[][] or y/// or y[][] construct. Missing the leading "$" from variables $tr or $y may cause this error.
perlfunc.pod
1959 :             open(EXTRACT, "|sort >Tmp$$")            # $$ is our process id
3678 :             An explicit format parameter index, such as "2$". By default sprintf will format the next unused argument in the list, but this allows you to take the arguments out of order:
3735 :             Arguments are usually formatted to be only as wide as required to display the given value. You can override the width by putting a number here, or get the width from the next argument (with "*") or from a specified argument (e.g., with "*2$"):
3803 :             You cannot currently get the precision from a specified number, but it is intended that this will be possible in the future, for example using ".*2$":
3877 :             Here are some more examples; be aware that when using an explicit index, the "$" may need escaping:
perlsub.pod
205 :     An argument can be ignored by omitting the main part of the name from a parameter declaration, leaving just a bare "$" sigil. For example,
919 :     Any backslashed prototype character represents an actual argument that must start with that character (optionally preceded by "my", "our" or "local"), with the exception of "$", which will accept any scalar lvalue expression, such as "$foo = 7" or "my_function()->[0]". The value passed as part of @_ will be a reference to the actual argument given in the subroutine call, obtained by applying "\" to that argument.
935 :     Unbackslashed prototype characters have special meanings. Any unbackslashed "@" or "%" eats all remaining arguments, and forces list context. An argument represented by "$" forces scalar context. An "&" requires an anonymous subroutine, which, if passed as the first argument, does not require the "sub" keyword or a subsequent comma.
946 :     The "+" prototype is a special alternative to "$" that will act like "\[@%]" when given a literal array or hash variable, but will otherwise force scalar context on the argument. This is useful for functions which should accept either a literal array or an array reference as the argument:
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.
perlperf.pod
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);
perlre.pod
14 :     m   Treat string as multiple lines. That is, change "^" and "$" from matching the start of the string's first line and the end of its last line to matching the start and end of each line within the string.
18 :         Used together, as "/ms", they let the "." match any character whatsoever, while still allowing "^" and "$" to match, respectively, just after and just before newlines within the string.
211 :     By default, the "^" character is guaranteed to match only the beginning of the string, the "$" character only the end (or before the newline at the end), and Perl does certain optimizations with the assumption that the string contains only one line. Embedded newlines will not be matched by "^" or "$". You may, however, wish to treat a string as a multi-line buffer, such that the "^" will match after any newline within the string (except if the newline is the last character in the string), and "$" will match before any newline. At the cost of a little more overhead, you can do this by using the /m modifier on the pattern match operator. (Older programs did this by setting $*, but this option was removed in perl 5.10.)
367 :     A word boundary ("\b") is a spot between two characters that has a "\w" on one side of it and a "\W" on the other side of it (in either order), counting the imaginary characters off the beginning and end of the string as matching a "\W". (Within character classes "\b" represents backspace rather than a word boundary, just as it normally does in any double-quoted string.) The "\A" and "\Z" are just like "^" and "$", except that they won't match multiple times when the "/m" modifier is used, while "^" and "$" will match at every internal line boundary. To match the actual end of the string and not ignore an optional trailing newline, use "\z".
perldata.pod
10 :     Perl also has its own built-in variables whose names don't follow these rules. They have strange names so they don't accidentally collide with one of your normal variables. Strings that match parenthesized parts of a regular expression are saved under names containing only digits after the "$" (see perlop and perlre). In addition, several special variables that provide windows into the inner working of Perl have names containing punctuation characters and control characters. These are documented in perlvar.
232 :     Arrays and slices are interpolated into double-quoted strings by joining the elements with the delimiter specified in the $" variable ($LIST_SEPARATOR if "use English;" is specified), space by default. The following are equivalent:
234 :         $temp = join($", @ARGV);
395 :     An array can be accessed one scalar at a time by specifying a dollar sign ("$"), then the name of the array (without the leading "@"), then the subscript inside square brackets. For example:
perltrap.pod
22 :     *   Variables begin with "$", "@" or "%" in Perl.
85 :     *   Variables begin with "$", "@" or "%" in Perl.
149 :     *   Backreferences in substitutions use "$" rather than "\".
perldebug.pod
66 :                 Display all (or some) variables in package (defaulting to "main") using a data pretty-printer (hashes show their keys and values so you see what's what, control characters are made printable, etc.). Make sure you don't put the type specifier (like "$") there, just the symbol names, like this:
364 :                 This module should implement a method named "new" that returns an object with two methods: "IN" and "OUT". These should return filehandles to use for debugging input and output correspondingly. The "new" method should inspect an argument containing the value of $ENV{PERLDB_NOTTY} at startup, or "$ENV{HOME}/.perldbtty$$" otherwise. This file is not inspected for proper ownership, so security hazards are theoretically possible.
424 :             The left-hand character up there indicates the context in which the function was called, with "$" and "@" meaning scalar or list contexts respectively, and "." meaning void context (which is actually a sort of scalar context). The display above says that you were in the function "main::infested" when you ran the stack dump, and that it was called in scalar context from line 10 of the file *Ambulation.pm*, but without any arguments at all, meaning it was called as &infested. The next stack frame shows that the function "Ambulation::legs" was called in list context from the *camel_flea* file with four arguments. The last stack frame shows that "main::pests" was called in scalar context, also from *camel_flea*, but from line 4.
perlreguts.pod
149 :     "regbranch()" in turn calls "regpiece()" which handles "things" followed by a quantifier. In order to parse the "things", "regatom()" is called. This is the lowest level routine, which parses out constant strings, character classes, and the various special symbols like "$". If "regatom()" encounters a "(" character it in turn calls "reg()".
336 :     Here we can see a much more complex program, with various optimisations in play. At regnode 10 we see an example where a character class with only one character in it was turned into an "EXACT" node. We can also see where an entire alternation was turned into a "TRIE-EXACT" node. As a consequence, some of the regnodes have been marked as optimised away. We can see that the "$" symbol has been converted into an "EOL" regop, a special piece of code that looks for "\n" or the end of the string.
perlvar.pod
75 :     $"      When an array or an array slice is interpolated into a double-quoted string or a similar context such as "/.../", its elements are separated by this value. Default is a space. For example, this:
81 :                 print "The array is: " . join($", @array) . "\n";
perldebguts.pod
86 :     *   "DB::dump_trace(skip[,count])" skips the specified number of frames and returns a list containing information about the calling frames (all of them, if "count" is missing). Each entry is reference to a hash with keys "context" (either ".", "$", or "@"), "sub" (subroutine name, or info about "eval"), "args" ("undef" or a reference to an array), "file", and "line".
336 :     If a substring is known to match at end-of-line only, it may be followed by "$", as in "floating 'k'$".
perlrequick.pod
76 :     With all of the regexes above, if the regex matched anywhere in the string, it was considered a match. To specify *where* it should match, we would use the anchor metacharacters "^" and "$". The anchor "^" means match at the beginning of the string and the anchor "$" means match at the end of the string, or before a newline at the end of the string. Some examples:
99 :     Character classes also have ordinary and special characters, but the sets of ordinary and special characters inside a character class are different than those outside a character class. The special characters for a character class are "-]\^$" and are matched using an escape:
perlintro.pod
133 :         The elements we're getting from the array start with a "$" because we're getting just a single value out of the array; you ask for a scalar, you get a scalar.
perlunicode.pod
495 :         [8] Should do "^" and "$" also on "U+000B" ("\v" in C), "FF" ("\f"), "CR" ("\r"), "CRLF" ("\r\n"), "NEL" ("U+0085"), "LS" ("U+2028"), and "PS" ("U+2029"); should also affect "<>", $., and script line numbers; should not split lines within "CRLF" (i.e. there is no empty line between "\r" and "\n"). For "CRLF", try the ":crlf" layer (see PerlIO).
perlport.pod
700 :     Note that ""ADFS::HardDisk.$.File" ne 'ADFS::HardDisk.$.File'" and that the second stage of "$" interpolation in regular expressions will fall foul of the $. if scripts are not careful.
perldsc.pod
152 :     The seemingly equivalent construct in Perl, $$aref[$i] first does the deref of $aref, making it take $aref as a reference to an array, and then dereference that, and finally tell you the *i'th* value of the array pointed to by $AoA. If you wanted the C notion, you'd have to write "${$AoA[$i]}" to force the $AoA[$i] to get evaluated first before the leading "$" dereferencer.
perlebcdic.pod
846 :         M``$"`P0%!@<("0H+#`T.#Q`1$A,4%187&!D:&QP='A\@(2(C)"4F)R@I*BLL
<< Back to Perldoc Search