Perldoc Search: "$b" perl-5.20.1

search official POD


36 PODs, 325 LINEs found.
perlfunc.pod
227 :                 $nread = sysread SOCKET, $buffer, $size;
312 :             $wantarray, $evaltext, $is_require, $hints, $bitmask, $hinthash)
315 :         Here, $subroutine is the function that the caller called (rather than the function containing the caller). Note that $subroutine may be "(eval)" if the frame is not a subroutine call, but an "eval". In such a case additional elements $evaltext and $is_require are set: $is_require is true if the frame is created by a "require" or "use" statement, $evaltext contains the text of the "eval EXPR" statement. In particular, for an "eval BLOCK" statement, $subroutine is "(eval)", but $evaltext is undefined. (Note also that each "use" statement creates a "require" frame inside an "eval EXPR" frame.) $subroutine may also be "(unknown)" if this particular subroutine happens to have been deleted from the symbol table. $hasargs is true if a new instance of @_ was set up for the frame. $hints and $bitmask contain pragmatic hints that the caller was compiled with. $hints corresponds to $^H, and $bitmask corresponds to "${^WARNING_BITS}". The $hints and $bitmask values are subject to change between versions of Perl, and are not meant for external use.
377 :         Note that parentheses are necessary when you're chomping anything that is not a simple variable. This is because "chomp $cwd = `pwd`;" is interpreted as "(chomp $cwd) = `pwd`;", rather than as "chomp( $cwd = `pwd` )" which you might expect. Similarly, "chomp $a, $b" is interpreted as "chomp($a), $b" rather than as "chomp($a, $b)".
590 :             sub foo { defined &$bar ? &$bar(@_) : die "No bar"; }
852 :             eval { $answer = $a / $b; }; warn $@ if $@;
855 :             eval '$answer = $a / $b'; warn $@ if $@;
866 :             eval { local $SIG{'__DIE__'}; $answer = $a / $b; };
1183 :             if ($BSD_STYLE) {
1192 :             if ($BSD_STYLE) {
1200 :         Determination of whether $BSD_STYLE should be set is left as an exercise to the reader.
1301 :             ($a,$b,$c,$d) = unpack('W4',$addr[0]);
1512 :             foreach $key (sort { $hash{$b} <=> $hash{$a} } keys %hash) {
2176 :             our($bar, $baz);
2181 :             our $bar;      # declares $Foo::bar for rest of lexical scope
2182 :             $bar = 20;
2185 :             print $bar;    # prints 20, as it refers to $Foo::bar
2191 :             our $bar;      # declares $Foo::bar for rest of lexical scope
2192 :             $bar = 20;
2195 :             our $bar = 30; # declares $Bar::bar for rest of lexical scope
2196 :             print $bar;    # prints 30
2198 :             our $bar;      # emits warning but has no other effect
2199 :             print $bar;    # still prints 30
2569 :             $bar = pack('s@4l', 12, 34);
2571 :             # $foo eq $bar
2572 :             $baz = pack('s.l', 12, 4, 34);
3108 :             print uc(scalar(&foo,$bar)),$baz;
3113 :             print(uc($bar),$baz);
3178 :                 my $bits = "";
3180 :                     vec($bits, fileno($fh), 1) = 1;
3182 :                 return $bits;
3364 :         If the subroutine's prototype is "($$)", the elements to be compared are passed by reference in @_, as for a normal subroutine. This is slower than unprototyped subroutines, where the elements to be compared are passed into the subroutine as the package global variables $a and $b (see example below). Note that in the latter case, it is usually highly counter-productive to declare $a and $b as lexicals.
3366 :         If the subroutine is an XSUB, the elements to be compared are pushed on to the stack, the way arguments are usually passed to XSUBs. $a and $b are not set.
3384 :             @articles = sort {$a cmp $b} @files;
3387 :             @articles = sort {fc($a) cmp fc($b)} @files;
3390 :             @articles = sort {$b cmp $a} @files;
3393 :             @articles = sort {$a <=> $b} @files;
3396 :             @articles = sort {$b <=> $a} @files;
3400 :             @eldest = sort { $age{$b} <=> $age{$a} } keys %age;
3404 :                 $age{$a} <=> $age{$b};  # presuming numeric
3408 :             sub backwards { $b cmp $a }
3423 :                 ($b =~ /=(\d+)/)[0] <=> ($a =~ /=(\d+)/)[0]
3425 :                             fc($a)  cmp  fc($b)
3438 :                                    $nums[$b] <=> $nums[$a]
3440 :                                    $caps[$a] cmp $caps[$b]
3446 :                    sort { $b->[1] <=> $a->[1]
3448 :                           $a->[2] cmp $b->[2]
3454 :             sub backwards ($$) { $_[1] cmp $_[0]; }  # $a and $b are
3461 :             @new = sort { substr($a, 3, 5) cmp substr($b, 3, 5) } @old;
3465 :             @new = sort { substr($a, 3, 5) cmp substr($b, 3, 5) } @old;
3469 :             @contact = sort { $a cmp $b } find_records @key;
3481 :         If you're using strict, you *must not* declare $a and $b as lexicals. They are package globals. That means that if you're in the "main" package and type
3483 :             @articles = sort {$b <=> $a} @files;
3485 :         then $a and $b are $main::a and $main::b (or $::a and $::b), but if you're in the "FooPack" package, it's the same as typing
3491 :         Because "<=>" returns "undef" when either operand is "NaN" (not-a-number), be careful when sorting with a comparison function like "$a <=> $b" any lists that might contain a "NaN". The following example takes advantage that "NaN != NaN" to eliminate any "NaN"s from the input list.
3493 :             @result = sort { $a <=> $b } grep { $_ == $_ } @input;
3727 :               printf "bits are %0*v8b\n", " ", $bits;   # random bitstring
3869 :                 printf "<%*.*s>", $a, $b, $c;
3871 :             uses $a for the width, $b for the precision, and $c as the value to format; while:
3873 :               printf '<%*1$.*s>', $a, $b;
3875 :             would use $a for the width and precision, and $b as the value to format.
3918 :                $atime,$mtime,$ctime,$blksize,$blocks)
4415 :             undef $bar{'blurfl'};      # Compare to: delete $bar{'blurfl'};
4422 :             ($a, $b, undef, $c) = &foo;       # Ignore third value returned
4653 :             $bits = unpack("b*", $vector);
4673 :                       $bits = (1<<$shift);
4674 :                       vec($str, $off, $width) = $bits;
4684 :           $off, $width, $bits, $val, $res
perlop.pod
5 :     In Perl, the operator determines what operation is performed, independent of the type of the operands. For example "$a + $b" is always a numeric addition, and if $a or $b do not contain numbers, an attempt is made to convert them to numbers first.
7 :     This is in contrast to many other dynamic languages, where the operation is determined by the type of the first argument. It also means that Perl has two versions of some operators, one for numeric and one for string comparison. For example "$a == $b" compares two numbers for equality, and "$a eq $b" compares two strings.
154 :     Binary "%" is the modulo operator, which computes the division remainder of its first argument with respect to its second argument. Given integer operands $a and $b: If $b is positive, then "$a % $b" is $a minus the largest multiple of $b less than or equal to $a. If $b is negative, then "$a % $b" is $a minus the smallest multiple of $b that is not less than $a (that is, the result will be less than or equal to zero). If the operands $a and $b are floating point values and the absolute value of $b (that is "abs($b)") is less than "(UV_MAX + 1)", only the integer portion of $a and $b will be used in the operation (Note: here "UV_MAX" means the maximum of the unsigned integer type). If the absolute value of the right operand ("abs($b)") is greater than or equal to "(UV_MAX + 1)", "%" computes the floating-point remainder $r in the equation "($r = $a - $i*$b)" where $i is a certain integer that makes $r have the same sign as the right operand $b (not as the left operand $a like C function "fmod()") and the absolute value less than that of $b. Note that when "use integer" is in scope, "%" gives you direct access to the modulo operator as implemented by your C compiler. This operator is not as well defined for negative operands, but it will execute faster.
413 :     If you were to set "$b[3] = 4", then instead of reporting that "a and b are deep copies of each other", it now reports that "b smartmatches in a". That because the corresponding position in @a contains an array that (eventually) has a 4 in it.
498 :     Although it has no direct equivalent in C, Perl's "//" operator is related to its C-style or. In fact, it's exactly the same as "||", except that it tests the left hand side's definedness instead of its truth. Thus, "EXPR1 // EXPR2" returns the value of "EXPR1" if it's defined, otherwise, the value of "EXPR2" is returned. ("EXPR1" is evaluated in scalar context, "EXPR2" in the context of "//" itself). Usually, this is the same result as "defined(EXPR1) ? EXPR1 : EXPR2" (except that the ternary-operator form can be used as a lvalue, while "EXPR1 // EXPR2" cannot). This is very useful for providing default values for variables. If you actually want to test if at least one of $a and $b is defined, use "defined($a // $b)".
640 :         $a = $ok ? $b : $c;  # get a scalar
646 :         ($a_or_b ? $a : $b) = $c;
766 :         $a = $b or $c;              # bug: this is wrong
767 :         ($a = $b) or $c;            # really means this
768 :         $a = $b || $c;              # better written this way
1217 :                 s/Login: $foo/Login: $bar/; # run-time pattern
1219 :                 ($foo = $bar) =~ s/this/that/;      # copy first, then
1221 :                 ($foo = "$bar") =~ s/this/that/;    # convert to string,
1223 :                 $foo = $bar =~ s/this/that/r;       # Same as above using /r
1224 :                 $foo = $bar =~ s/this/that/r
1294 :             $bar = q('This is it.');
1295 :             $baz = '\n';                # a two-character string
1304 :             $baz = "\n";                # a one-character string
1561 :             "$hash{"$foo/$bar"}"
1589 :             "\Q", "\U", "\u", "\L", "\l", "\F" (possibly paired with "\E") are converted to corresponding Perl constructs. Thus, "$foo\Qbaz$bar" is converted to "$foo . (quotemeta("baz" . $bar))" internally. The other escape sequences such as "\200" and "\t" and backslashed characters such as "\\" and "\-" are replaced with appropriate expansions.
1606 :             Note also that the interpolation code needs to make a decision on where the interpolated scalar ends. For instance, whether "a $b -> {c}" really means:
1608 :               "a " . $b . " -> {c}";
1612 :               "a " . $b -> {c};
1632 :             Interpolation in patterns has several quirks: $|, $(, $), "@+" and "@-" are not interpolated, and constructs $var[SOMETHING] are voted (by several different estimators) to be either an array element or $var followed by an RE alternative. This is where the notation "${arr[$bar]}" comes handy: "/${arr[0-9]}/" is interpreted as array element -9, not as a regular expression from the variable $arr followed by a digit, which would be the interpretation of "/$arr[0-9]/". Since voting among different estimators may occur, the result is not predictable.
1828 :         $baz = 0+$foo & 0+$bar;     # both ops explicitly numeric
1829 :         $biz = "$foo" ^ "$bar";     # both ops explicitly stringy
1884 :             $b = 4/6;
1885 :             say "a/b is ", $a/$b;
1886 :             say "a*b is ", $a*$b;
perlpacktut.pod
225 :        my( $ip, $cs, $flags, $ax, $bx, $cd, $dx, $si, $di, $bp, $ds, $es ) =
230 :        my( $fl, $fh, $al, $ah, $bl, $bh, $cl, $ch, $dl, $dh ) =
237 :            $ax,$al,$ah, $bx,$bl,$bh, $cx,$cl,$ch, $dx,$dl,$dh, 
238 :            $si, $di, $bp, $ds, $es ) =
248 :        my $buf = pack( 'N', length( $msg ) ) . $msg;
252 :        my $buf = pack( 'NA*', length( $msg ), $msg );
254 :     and pass $buf to your send routine. Some protocols demand that the count should include the length of the count itself: then just add 4 to the data length. (But make sure to read "Lengths and Widths" before you really code this!)
259 :        my @data = unpack 's*', pack 'S*', unpack 'n*', $buf;
263 :        my @data = unpack 's>*', $buf;
284 :        $byte = pack( 'B8', '10001100' ); # start with MSB
285 :        $byte = pack( 'b8', '00110001' ); # start with LSB
307 :        my $uubuf = pack( 'u', $bindat );
314 :         my $buf = pack( 'iii', 100, 20, 3 );
315 :         print unpack( '%32i3', $buf ), "\n";  # prints 123
325 :         my $bitcount = unpack( '%32b*', $mask );
360 :        my $berbuf = pack( 'w*', 1, 128, 128+1, 128*128+127 );
362 :     A hex dump of $berbuf, with spaces inserted at the right places, shows 01 8100 8101 81807F. Since the last byte is always less than 128, "unpack" knows where to stop.
430 :        my $buf = pack( 'A4/A*', "Humpty-Dumpty" );
431 :        # unpack $buf: '13  Humpty-Dumpty'
432 :        my $txt = unpack( 'A4/A*', $buf );
477 :        my $binrec = pack( 'H*', substr( $hexrec, 1 ) );
481 :        die unless unpack( "%8C*", $binrec ) == 0;
485 :        my( $addr, $type, $data ) = unpack( "x n C X4 C x3 /a", $bin );
662 :        my $buf = pack( 'p', "abc\x00efhijklmn" );
663 :        print unpack( 'p', $buf );    # prints "abc"
691 :         $bits = unpack( '%32I!', ~0 );
perldiag.pod
323 :             $BADREF = undef;
324 :             process $BADREF 1,2,3;
325 :             $BADREF->process(1,2,3);
333 :             $BADREF = 42;
334 :             process $BADREF 1,2,3;
335 :             $BADREF->process(1,2,3);
626 :         (F) The global variables $a and $b are reserved for sort comparisons. You mentioned $a or $b in the same line as the <=> or cmp operator, and the variable had earlier been declared as a lexical variable. Either qualify the sort variable with the package name, or rename the lexical variable.
834 :             $foo{$bar}
839 :             @foo[$bar, $baz, $xyzzy]
961 :             $foo{$bar}
1486 :         (F) In a subroutine signature, you wrote something like "$a = undef, $b", making an earlier parameter optional and a later one mandatory. Parameters are filled from left to right, so it's impossible for the caller to omit an earlier one and pass a later one. If you want to act as if the parameters are filled from right to left, declare the rightmost optional and then shuffle the parameters around in the subroutine's body.
1630 :         (W syntax) The package variables $a and $b are used for sort comparisons. You used $a or $b in as an operand to the "<=>" or "cmp" operator inside a sort comparison block, and the variable had earlier been declared as a lexical variable. Either qualify the sort variable with the package name, or rename the lexical variable.
2124 :             my $foo, $bar = @_;
2128 :             my ($foo, $bar) = @_;
2262 :             sub { return $a or $b; }
2266 :             sub { (return $a) or $b; }
2653 :         (W syntax) The package variables $a and $b are used for sort comparisons. You used $a or $b in as an operand to the "<=>" or "cmp" operator inside a sort comparison block, and the variable had earlier been declared as a lexical variable. Either qualify the sort variable with the package name, or rename the lexical variable.
3024 :          if ($a =~ /foo/and $bar == 3) { ... }
3028 :          if ($a =~ /foo/ and $bar == 3) { ... }
perlthrtut.pod
214 :         my $bar = 1;
215 :         threads->create(sub { $foo++; $bar++; })->join();
218 :         print("$bar\n");  # Prints 1 since $bar is not shared
256 :         sub sub2 { my $bar = $a; $a = $bar + 1; }
264 :         my $b :shared;
266 :         my $thr1 = threads->create(sub { $b = $a; $a = $b + 1; });
271 :     Two threads both access $a. Each thread can potentially be interrupted at any point, or be executed in any order. At the end, $a could be 3 or 4, and both $b and $c could be 2 or 3.
349 :         my $b :shared = 'foo';
353 :             lock($b);
356 :             lock($b);
363 :     The first thread will grab a lock on $a, then, after a pause during which the second thread has probably had time to do some work, try to grab a lock on $b. Meanwhile, the second thread grabs a lock on $b, then later tries to grab a lock on $a. The second lock attempt for both threads will block, each waiting for the other to release its lock.
367 :     There are a number of ways to handle this sort of problem. The best way is to always have all threads acquire locks in the exact same order. If, for example, you lock variables $a, $b, and $c, always lock $a before $b, and $b before $c. It's also best to hold on to locks for as short a period of time to minimize the risks of deadlock.
perlperf.pod
633 :                 my $browser = $5;
635 :                 push(@data, [$ip, $date, $query, $status, $browser, $line]);
640 :             $a->[3] cmp $b->[3]
642 :             $a->[2] cmp $b->[2]
644 :             $a->[0] cmp $b->[0]
646 :             $a->[1] cmp $b->[1]
648 :             $a->[4] cmp $b->[4]
690 :                 $a->[4] cmp $b->[4]
692 :                 $a->[3] cmp $b->[3]
694 :                 $a->[1] cmp $b->[1]
696 :                 $a->[2] cmp $b->[2]
698 :                 $a->[5] cmp $b->[5]
perlcall.pod
285 :             my($a, $b) = @_;
286 :             $a + $b;
352 :            my($a, $b) = @_;
353 :            ($a+$b, $a-$b);
505 :             my ($a, $b) = @_;
507 :             die "death can be fatal\n" if $a < $b;
509 :             $a - $b;
588 :             my($a,$b) = @_;
589 :             die "death can be fatal" if $a < $b;
590 :             $a - $b;
1056 :             my($handle, $buffer) = @_;
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.)
perldata.pod
250 :         @foo = ('cc', '-E', $bar);
254 :         $foo = ('cc', '-E', $bar);
256 :     assigns the value of variable $bar to the scalar variable $foo. Note that the value of an actual array in scalar context is the length of the array; the following assigns the value 3 to $foo:
258 :         @foo = ('cc', '-E', $bar);
305 :         ($a, $b, $c) = (1, 2, 3);
315 :         $x = (($foo,$bar) = (3,2,1));       # set $x to 3, not 2
316 :         $x = (($foo,$bar) = f());           # set $x to f()'s return count
332 :         ($a, $b, @rest) = split;
333 :         my($a, $b, %rest) = @_;
421 :         $foo{$a,$b,$c}
425 :         $foo{join($;, $a, $b, $c)}
perlsub.pod
61 :         $bestday = max($mon,$tue,$wed,$thu,$fri);
340 :         my $foo, $bar = 1;                  # WRONG
345 :         $bar = 1;
838 :         ($aref, $bref) = func(\@c, \@d);
839 :         print "@$aref has more than @$bref\n";
907 :        sub mysyswrite ($$$;$)  mysyswrite $buf, 0, length($buf) - $off, $off
908 :        sub myreverse (@)       myreverse $a, $b, $c
909 :        sub myjoin ($@)         myjoin ":", $a, $b, $c
915 :        sub mygrep (&@)         mygrep { /foo/ } $a, $b, $c
967 :         mygetprotobynumber $a > $b; # parsed as mygetprotobynumber($a > $b)
perlvar.pod
163 :                 $foo{$a,$b,$c}
167 :                 $foo{join($;, $a, $b, $c)}
171 :                 @foo{$a,$b,$c}      # a slice--note the @
175 :                 ($foo{$a},$foo{$b},$foo{$c})
184 :     $b      Special package variables when using "sort()", see "sort" in perlfunc. Because of this specialness $a and $b don't need to be declared (using "use vars", or "our()") even when using the "strict 'vars'" pragma. Don't lexicalize them with "my $a" or "my $b" if you want to be able to use them in the "sort()" comparison block or function.
307 :     $BASETIME
572 :                     foreach my $bufname (sort keys %-) {
573 :                         my $ary = $-{$bufname};
575 :                             print "\$-{$bufname}[$idx] : ",
1048 :                     bar->baz($boon);
perlunitut.pod
47 :         my (@length_content) = unpack "(V/a)*", $binary;
48 :         $binary =~ s/\x00\x0F/\xFF\xF0/;  # for the brave :)
49 :         print {$fh} $binary;
50 :         my $byte_count = length $binary;
84 :         my $bar   = decode('ISO-8859-1', readline STDIN);
93 :         $body = encode('UTF-8', $body);
95 :     If you needed to know the length of the string in bytes, now's the perfect time for that. Because $body is now a byte string, "length" will report the number of bytes, instead of the number of characters. The number of characters is no longer known, because characters only exist in text strings.
97 :         my $byte_count = length $body;
102 :         "Content-Length: $byte_count"
perlipc.pod
932 :         $BLANK = $EOL x 2;
939 :             print $remote "GET $document HTTP/1.0" . $BLANK;
1014 :         my $byte;
1015 :         while (sysread($handle, $byte, 1) == 1) {
1016 :             print STDOUT $byte;
1148 :         shmread($id, $buff, 0, 60)      || die "shmread: $!";
1149 :         print "read : '$buff'\n";
1152 :         substr($buff, index($buff, "\0")) = "";
1153 :         print "un" unless $buff eq $message;
perlref.pod
164 :             $bar = $$scalarref;
178 :             $bar = ${$scalarref};
250 :         my $bar = { foo => $foo };
251 :         $foo->{bar} = $bar;
269 :         my $bar = { foo => $foo };
270 :         $foo->{bar} = $bar;
274 :     The reference from $foo to $bar has been weakened. When the $bar variable goes out of scope, it will be garbage-collected. The next time you look at the value of the "$foo->{bar}" key, it will be "undef".
329 :         ${ bareword };      # Okay, means $bareword.
perlinterp.pod
235 :     Let's have a look at how Perl sees "$a = $b + $c":
237 :          % perl -MO=Terse -e '$a=$b+$c'
250 :     Let's start in the middle, at line 4. This is a BINOP, a binary operator, which is at location 0x8179828. The specific operator in question is "sassign" - scalar assignment - and you can find the code which implements it in the function "pp_sassign" in pp_hot.c. As a binary operator, it has two children: the add operator, providing the result of "$b+$c", is uppermost on line 5, and the left hand side is on line 10.
280 :                               $b   $c
282 :     However, it's impossible to perform the operations in this order: you have to find the values of $b and $c before you add them together, for instance. So, the other thread that runs through the op tree is the execution order: each op has a field "op_next" which points to the next op to be run, so following these pointers tells us how perl executes the code. We can traverse the tree in this order using the "exec" option to "B::Terse":
284 :          % perl -MO=Terse,exec -e '$a=$b+$c'
294 :     This probably makes more sense for a human: enter a block, start a statement. Get the values of $b and $c, and add them together. Find $a, and assign one to the other. Then leave.
296 :     The way Perl builds up these op trees in the parsing process can be unravelled by examining perly.y, the YACC grammar. Let's take the piece we need to construct the tree for "$a = $b + $c"
perlpod.pod
281 :         C<$a E<lt>=E<gt> $b>
283 :     This will produce: ""$a <=> $b""
287 :         C<< $a <=> $b >>
291 :         C<<< $a <=> $b >>>
292 :         C<<<<  $a <=> $b     >>>>
296 :         C<$a E<lt>=E<gt> $b>
300 :         C<< $a E<lt>=E<gt> $b >>
perldsc.pod
58 :     That's because Perl doesn't (ever) implicitly dereference your variables. If you want to get at the thing a reference is referring to, then you have to do this yourself using either prefix typing indicators, like "${$blah}", "@{$blah}", "@{$blah[$i]}", or else postfix pointer arrows, like "$a->[3]", "$h->{fred}", or even "$ob->method()->[3]".
311 :      foreach $family ( sort { @{$HoA{$b}} <=> @{$HoA{$a}} } keys %HoA ) {
317 :                                 @{$HoA{$b}} <=> @{$HoA{$a}}
319 :                                         $a cmp $b
502 :      foreach $family ( sort { keys %{$HoH{$b}} <=> keys %{$HoH{$a}} } keys %HoH ) {
515 :      foreach $family ( sort { keys %{ $HoH{$b} } <=> keys %{ $HoH{$a} } } keys %HoH ) {
518 :          for $role ( sort { $rank{$a} <=> $rank{$b} }  keys %{ $HoH{$family} } ) {
perltie.pod
604 :                 my($buf,$len,$offset) = @_;
605 :                 print "WRITE called, \$buf=$buf, \$len=$len, \$offset=$offset";
629 :                 my $bufref = \$_[0];
631 :                 print "READ called, \$buf=$bufref, \$len=$len, \$offset=$offset";
632 :                 # add to $$bufref, set $len to number of characters read
681 :         $a = 4; $b = 6;
682 :         print FOO $a, " plus ", $b, " equals ", $a + $b, "\n";
perlmod.pod
46 :         *foo = \$bar;
48 :     "*foo = *bar" makes the typeglobs themselves synonymous while "*foo = \$bar" makes the SCALAR portions of two distinct typeglobs refer to the same scalar value. This means that the following code:
50 :         $bar = 1;
51 :         *foo = \$bar;       # Make $foo an alias for $bar
54 :             local $bar = 2; # Restrict changes to block
58 :     Would print '1', because $foo holds a reference to the *original* $bar. The one that was stuffed away by "local()" and which will be restored when the block ends. Because variables are accessed through the typeglob, you can use "*foo = *bar" to create an alias which can be localized. (But be aware that this means you can't have a separate @foo and @bar, etc.)
perlguts.pod
1146 :       $a = $b + $c;
1154 :           $b     $c
1158 :          $b ---> $c ---> + ---> $a ---> assign-to
1160 :     But with the actual compile tree for "$a = $b + $c" it is different: some nodes *optimized away*. As a corollary, though the actual tree contains more nodes than our simplified example, the execution order is the same as in our example.
1163 :     If you have your perl compiled for debugging (usually done with "-DDEBUGGING" on the "Configure" command line), you may examine the compiled tree by specifying "-Dx" on the Perl command line. The output takes several lines per node, and for "$b+$c" it looks like this:
perlobj.pod
86 :       my $bar = $foo;
89 :       print blessed( $bar );      # prints "Class"
91 :       $bar = "some other value";
92 :       print blessed( $bar );      # prints undef
94 :     When we call "bless" on a variable, we are actually blessing the underlying data structure that the variable refers to. We are not blessing the reference itself, nor the variable that contains that reference. That's why the second call to "blessed( $bar )" returns false. At that point $bar is no longer storing a reference to an object.
perlretut.pod
968 :             foreach (sort {$chars{$b} <=> $chars{$a}} keys %chars);
1443 :         $bar = 5;
1445 :         /foo(?{ $bar })bar/; # compiles ok, $bar not interpolated
1446 :         /foo(?{ 1 })$bar/;   # compiles ok, $bar interpolated
1463 :         $bar = 5;
perlpodspec.pod
209 :           B<example: C<$a E<lt>=E<gt> $b>>
211 :           B<example: C<< $a <=> $b >>>
213 :           B<example: C<< $a E<lt>=E<gt> $b >>>
215 :           B<<< example: C<< $a E<lt>=E<gt> $b >> >>>
perluniintro.pod
321 :             $b = "\x{100}";
322 :             print "$a = $b\n";
390 :             $Unicode = decode_utf8($bytes);
394 :             $Unicode = pack("U0a*", $bytes);
perlrun.pod
274 :              ($backup = $extension) =~ s/\*/$file_name/g;
310 :                          $backup = $ARGV . $extension;
313 :                          ($backup = $extension) =~ s/\*/$ARGV/g;
315 :                      rename($ARGV, $backup);
perlgit.pod
326 :       $ git push origin HEAD:$branch
327 :       $ git checkout -b $branch origin/$branch
332 :       $ git checkout -b $branch
333 :       $ git push origin -u $branch
perlhacktips.pod
449 :     One way to get around this macro hell is to use the dumping functions in dump.c; these work a little like an internal Devel::Peek, but they also cover OPs and other structures that you can't get at from Perl. Let's take an example. We'll use the "$a = $b + $c" we used before, but give it a bit of context: "$b = "6XXXX"; $c = 2.3;". Where's a good place to stop and poke around?
458 :         (gdb) run -e '$b = "6XXXX"; $c = 2.3; $a = $b + $c'
476 :     Since we don't have an NV for $b, we'll have to use "sv_2nv" to convert it. If we step again, we'll find ourselves there:
551 :         if ($a && $b && do { BEGIN { study } 1 } && $c) { ... }
perlopentut.pod
160 :         my $BUFSIZ   = 64 * (2 ** 10);
164 :         my($in_fh, $out_fh, $buffer);
175 :         while (read($in_fh, $buffer, $BUFSIZ)) {
176 :             unless (print $out_fh $buffer) {
perlunifaq.pod
98 :         my $bar_string  = encode('BAR', $text_string);
108 :         open my $barfh, '>:encoding(BAR)', 'example.bar.txt';
109 :         print { $barfh } $_ while <$foofh>;
perlebcdic.pod
441 :          -e '          sort{$a->[1] <=> $b->[1]}' \
452 :         -e '          sort{$a->[1] <=> $b->[1]}' \
463 :          -e '          sort{$a->[1] <=> $b->[1]}' \
perldebguts.pod
18 :     *   Each hash "%{"_<$filename"}" contains breakpoints and actions keyed by line number. Individual entries (as opposed to the whole hash) are settable. Perl only cares about Boolean true here, although the values used by perl5db.pl have the form "$break_condition\0$action".
79 :         As previously noted, individual entries (as opposed to the whole hash) are settable. Perl only cares about Boolean true here, although the values used by perl5db.pl have the form "$break_condition\0$action".
perlre.pod
408 :     Braces are required in referring to named capture groups, but are optional for absolute or relative numbered ones. Braces are safer when creating a regex by concatenating smaller strings. For example if you have "qr/$a$b/", and $a contained "\g1", and $b contained "37", you would get "/\g137/" which is probably not what you intended.
439 :         $b = '(.)\g{1}';     # Avoids the problems.
perlembed.pod
468 :             my ($a, $b) = @_;
469 :             return $a ** $b;
perlunicode.pod
738 :     Sometimes (see "When Unicode Does Not Happen" or "The "Unicode Bug"") there are situations where you simply need to force a byte string into UTF-8, or vice versa. The low-level calls "utf8::upgrade($bytestring)" and "utf8::downgrade($utf8string[, FAIL_OK])" are the answers.
perlsec.pod
84 :         $bad = ($arg, 23);          # $bad will be tainted
perlrebackslash.pod
236 :     The "\g*N*" form can be equivalently written as "\g{*N*}" which avoids ambiguity when building a regex by concatenating shorter strings. Otherwise if you had a regex "qr/$a$b/", and $a contained "\g1", and $b contained "37", you would get "/\g137/" which is probably not what you intended.
perlintro.pod
254 :          print "We have no bananas" unless $bananas;
<< Back to Perldoc Search