Date: Thursday November 28, 2019 @ 01:10 Author: argrath Update of /cvsroot/perldocjp/docs/modules/Scalar-List-Utils-1.21/Scalar In directory sf-cvs:/tmp/cvs-serv40257/modules/Scalar-List-Utils-1.21/Scalar Added Files: Util.pod Log Message: Scalar-List-Utils-1.21 =================================================================== File: Util.pod Status: Up-to-date Working revision: 1.1 Wed Nov 27 16:10:05 2019 Repository revision: 1.1 /cvsroot/perldocjp/docs/modules/Scalar-List-Utils-1.21/Scalar/Util.pod,v Existing Tags: No Tags Exist -------------- next part -------------- Index: docs/modules/Scalar-List-Utils-1.21/Scalar/Util.pod diff -u /dev/null docs/modules/Scalar-List-Utils-1.21/Scalar/Util.pod:1.1 --- /dev/null Thu Nov 28 01:10:05 2019 +++ docs/modules/Scalar-List-Utils-1.21/Scalar/Util.pod Thu Nov 28 01:10:05 2019 @@ -0,0 +1,417 @@ + +=encoding euc-jp + +=head1 NAME + +=begin original + +Scalar::Util - A selection of general-utility scalar subroutines + +=end original + +Scalar::Util - °ìÈÌŪ¤ËÍÍѤʥ¹¥«¥é¥µ¥Ö¥ë¡¼¥Á¥ó½¸ + +=head1 SYNOPSIS + + use Scalar::Util qw(blessed dualvar isweak readonly refaddr reftype tainted + weaken isvstring looks_like_number set_prototype); + # and other useful utils appearing below + +=head1 DESCRIPTION + +=begin original + +C<Scalar::Util> contains a selection of subroutines that people have +expressed would be nice to have in the perl core, but the usage would +not really be high enough to warrant the use of a keyword, and the size +so small such that being individual extensions would be wasteful. + +=end original + +C<Scalar::Util> ¤Ï¡¢¿Í¡¹¤¬ perl ¥³¥¢¤Ë¤¢¤ì¤Ð¤¤¤¤¤Î¤Ë¤ÈɽÌÀ¤¹¤ë¤±¤ì¤É¤â¡¢ +¥¡¼¥ï¡¼¥É¤Î»ÈÍѤòÊݾڤ·¡¢ÆÈΩ¤·¤¿³ÈÄ¥¤Ë¤¹¤ë¤Î¤¬ÌµÂ̤ʤۤɥµ¥¤¥º¤¬¾®¤µ¤¤¡¢¤È +¤¤¤¦¤Û¤É¼ÂºÝ¤Î»ÈÍÑÉÑÅÙ¤¬¹â¤¯¤Ê¤¤¥µ¥Ö¥ë¡¼¥Á¥ó½¸¤Ç¤¹¡£ + +=begin original + +By default C<Scalar::Util> does not export any subroutines. The +subroutines defined are + +=end original + +¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï C<Scalar::Util> ¤Ï²¿¤Î¥µ¥Ö¥ë¡¼¥Á¥ó¤â¥¨¥¯¥¹¥Ý¡¼¥È¤·¤Þ¤»¤ó¡£ +ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥µ¥Ö¥ë¡¼¥Á¥ó¤Ï: + +=over 4 + +=item blessed EXPR + +=begin original + +If EXPR evaluates to a blessed reference the name of the package +that it is blessed into is returned. Otherwise C<undef> is returned. + +=end original + +EXPR ¤¬ bless ¤µ¤ì¤¿¥ê¥Õ¥¡¥ì¥ó¥¹¤Ëɾ²Á¤µ¤ì¤ë¾ì¹ç¡¢ +bless ¤µ¤ì¤¿¥Ñ¥Ã¥±¡¼¥¸¤Î̾Á°¤òÊÖ¤·¤Þ¤¹¡£ +¤µ¤â¤Ê¤±¤ì¤Ð C<undef> ¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ + + $scalar = "foo"; + $class = blessed $scalar; # undef + + $ref = []; + $class = blessed $ref; # undef + + $obj = bless [], "Foo"; + $class = blessed $obj; # "Foo" + +=item dualvar NUM, STRING + +=begin original + +Returns a scalar that has the value NUM in a numeric context and the +value STRING in a string context. + +=end original + +¿ôÃÍ¥³¥ó¥Æ¥¥¹¥È¤Ç¤ÏÃÍ NUM ¤ò¡¢Ê¸»úÎó¥³¥ó¥Æ¥¥¹¥È¤Ç¤ÏÃÍ STRING ¤ò»ý¤Ä +¥¹¥«¥é¤òÊÖ¤·¤Þ¤¹¡£ + + $foo = dualvar 10, "Hello"; + $num = $foo + 2; # 12 + $str = $foo . " world"; # Hello world + +=item isvstring EXPR + +=begin original + +If EXPR is a scalar which was coded as a vstring the result is true. + +=end original + +EXPR ¤¬ v ʸ»úÎó¤È¤·¤Æ¥³¡¼¥É²½¤µ¤ì¤Æ¤¤¤ë¥¹¥«¥é¤Ê¤é¡¢·ë²Ì¤Ï¿¿¤Ç¤¹¡£ + + $vs = v49.46.48; + $fmt = isvstring($vs) ? "%vd" : "%s"; #true + printf($fmt,$vs); + +=item isweak EXPR + +=begin original + +If EXPR is a scalar which is a weak reference the result is true. + +=end original + +EXPR ¤¬¼å¤¤¥ê¥Õ¥¡¥ì¥ó¥¹¤Ç¤¢¤ë¥¹¥«¥é¤Ê¤é¡¢·ë²Ì¤Ï¿¿¤Ç¤¹¡£ + + $ref = \$foo; + $weak = isweak($ref); # false + weaken($ref); + $weak = isweak($ref); # true + +=begin original + +B<NOTE>: Copying a weak reference creates a normal, strong, reference. + +=end original + +B<NOTE>: ¼å¤¤¥ê¥Õ¥¡¥ì¥ó¥¹¤ò¥³¥Ô¡¼¤¹¤ë¤È¡¢Ä̾ï¤Î(¶¯¤¤)¥ê¥Õ¥¡¥ì¥ó¥¹¤Ë¤Ê¤ê¤Þ¤¹¡£ + + $copy = $ref; + $weak = isweak($copy); # false + +=item looks_like_number EXPR + +=begin original + +Returns true if perl thinks EXPR is a number. See +L<perlapi/looks_like_number>. + +=end original + +EXPR ¤¬¿ôÃͤǤ¢¤ë¤È perl ¤¬¹Í¤¨¤¿¤È¤¤Ë¿¿¤Ë¤Ê¤ê¤Þ¤¹¡£ +L<perlapi/looks_like_number> ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ + +=item openhandle FH + +=begin original + +Returns FH if FH may be used as a filehandle and is open, or FH is a tied +handle. Otherwise C<undef> is returned. + +=end original + +FH ¤¬¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤È¤·¤Æ»È¤ï¤ì¤Æ¤¤¤Æ³«¤¤¤Æ¤¤¤ë¤«¡¢FH ¤¬ tie ¤µ¤ì¤¿ +¥Ï¥ó¥É¥ë¤Ê¤é¡¢FH ¤òÊÖ¤·¤Þ¤¹¡£ +¤µ¤â¤Ê¤±¤ì¤Ð C<undef> ¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ + + $fh = openhandle(*STDIN); # \*STDIN + $fh = openhandle(\*STDIN); # \*STDIN + $fh = openhandle(*NOTOPEN); # undef + $fh = openhandle("scalar"); # undef + +=item readonly SCALAR + +=begin original + +Returns true if SCALAR is readonly. + +=end original + +SCALAR ¤¬Æɤ߹þ¤ßÀìÍѤξì¹ç¤Ë¿¿¤òÊÖ¤·¤Þ¤¹¡£ + + sub foo { readonly($_[0]) } + + $readonly = foo($bar); # false + $readonly = foo(0); # true + +=item refaddr EXPR + +=begin original + +If EXPR evaluates to a reference the internal memory address of +the referenced value is returned. Otherwise C<undef> is returned. + +=end original + +EXPR ¤¬¥ê¥Õ¥¡¥ì¥ó¥¹¤Èɾ²Á¤µ¤ì¤ë¾ì¹ç¡¢»²¾È¤·¤Æ¤¤¤ëÃͤÎÆâÉô¥á¥â¥ê¥¢¥É¥ì¥¹¤¬ +ÊÖ¤µ¤ì¤Þ¤¹¡£ +¤µ¤â¤Ê¤±¤ì¤Ð C<undef> ¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ + + $addr = refaddr "string"; # undef + $addr = refaddr \$var; # eg 12345678 + $addr = refaddr []; # eg 23456784 + + $obj = bless {}, "Foo"; + $addr = refaddr $obj; # eg 88123488 + +=item reftype EXPR + +=begin original + +If EXPR evaluates to a reference the type of the variable referenced +is returned. Otherwise C<undef> is returned. + +=end original + +EXPR ¤¬¥ê¥Õ¥¡¥ì¥ó¥¹¤Èɾ²Á¤µ¤ì¤ë¾ì¹ç¡¢»²¾È¤·¤Æ¤¤¤ëÊÑ¿ô¤Î·¿¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ +¤µ¤â¤Ê¤±¤ì¤Ð C<undef> ¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£ + + $type = reftype "string"; # undef + $type = reftype \$var; # SCALAR + $type = reftype []; # ARRAY + + $obj = bless {}, "Foo"; + $type = reftype $obj; # HASH + +=item set_prototype CODEREF, PROTOTYPE + +=begin original + +Sets the prototype of the given function, or deletes it if PROTOTYPE is +undef. Returns the CODEREF. + +=end original + +Í¿¤¨¤é¤ì¤¿´Ø¿ô¤Î¥×¥í¥È¥¿¥¤¥×¤òÀßÄꤷ¤Þ¤¹; PROTOTYPE ¤¬ undef ¤Î¾ì¹ç¤Ï +ºï½ü¤·¤Þ¤¹¡£ +CODEREF ¤òÊÖ¤·¤Þ¤¹¡£ + + set_prototype \&foo, '$$'; + +=item tainted EXPR + +=begin original + +Return true if the result of EXPR is tainted + +=end original + +EXPR ¤Î·ë²Ì¤¬±øÀ÷¤µ¤ì¤Æ¤¤¤ì¤Ð¿¿¤òÊÖ¤·¤Þ¤¹¡£ + + $taint = tainted("constant"); # false + $taint = tainted($ENV{PWD}); # true if running under -T + +=item weaken REF + +=begin original + +REF will be turned into a weak reference. This means that it will not +hold a reference count on the object it references. Also when the reference +count on that object reaches zero, REF will be set to undef. + +=end original + +REF ¤Ï¼å¤¤¥ê¥Õ¥¡¥ì¥ó¥¹¤ËÊѤï¤ê¤Þ¤¹¡£ +¤³¤ì¤Ï¡¢»²¾ÈÀè¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Î»²¾È¥«¥¦¥ó¥È¤Ë±Æ¶Á¤òÍ¿¤¨¤Ê¤¤¤È¤¤¤¦¤³¤È¤Ç¤¹¡£ +¤Þ¤¿¡¢¤½¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Î»²¾È¥«¥¦¥ó¥È¤¬¥¼¥í¤Ë¤Ê¤ë¤È¡¢REF ¤Ï undef ¤Ë +ÀßÄꤵ¤ì¤Þ¤¹¡£ + +=begin original + +This is useful for keeping copies of references , but you don't want to +prevent the object being DESTROY-ed at its usual time. + +=end original + +¤³¤ì¤Ï¥ê¥Õ¥¡¥ì¥ó¥¹¤Î¥³¥Ô¡¼¤òÊݸ¤·¤¿¤¤¤±¤ì¤É¤â¡¢Ä̾ï»þ¤Ë +¥ª¥Ö¥¸¥§¥¯¥È¤¬ DESTROY ¤µ¤ì¤ë¤Î¤ò˸¤²¤¿¤¯¤Ê¤¤¾ì¹ç¤ËÍÍѤǤ¹¡£ + + { + my $var; + $ref = \$var; + weaken($ref); # Make $ref a weak reference + } + # $ref is now undef + +=begin original + +Note that if you take a copy of a scalar with a weakened reference, +the copy will be a strong reference. + +=end original + +¼å¤¯¤·¤¿¥ê¥Õ¥¡¥ì¥ó¥¹¤ò¥³¥Ô¡¼¤¹¤ë¤È¡¢¤½¤Î¥³¥Ô¡¼¤Ï¶¯¤¤¥ê¥Õ¥¡¥ì¥ó¥¹¤Ë¤Ê¤ë¤³¤È¤Ë +Ãí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£ + + my $var; + my $foo = \$var; + weaken($foo); # Make $foo a weak reference + my $bar = $foo; # $bar is now a strong reference + +=begin original + +This may be less obvious in other situations, such as C<grep()>, for instance +when grepping through a list of weakened references to objects that may have +been destroyed already: + +=end original + +¤³¤ì¤Ï¡¢C<grep()> ¤Î¤è¤¦¤Ë¡¢¤½¤Î¾¤Î¾ì¹ç¤Û¤ÉÌÀ¤é¤«¤Ç¤Ê¤¤¤«¤â¤·¤ì¤Þ¤»¤ó; +Î㤨¤Ð¡¢´û¤ËÇ˲õ¤µ¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Ø¤Î¼å¤¤¥ê¥Õ¥¡¥ì¥ó¥¹¤Î +¥ê¥¹¥È¤ËÂФ·¤Æ grep ¤¹¤ë¤È: + + @object = grep { defined } @object; + +=begin original + +This will indeed remove all references to destroyed objects, but the remaining +references to objects will be strong, causing the remaining objects to never +be destroyed because there is now always a strong reference to them in the + @ object array. + +=end original + +¤³¤ì¤Ï³Î¤«¤ËÇ˲õ¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È¤Ø¤ÎÁ´¤Æ¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤ò½üµî¤·¤Þ¤¹¤¬¡¢ +»Ä¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤Ï¶¯¤¯¤Ê¤ê¡¢»Ä¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È¤Ï +·è¤·¤ÆÇ˲õ¤µ¤ì¤Ê¤¯¤Ê¤ê¤Þ¤¹; ¤Ê¤¼¤Ê¤é @object ÇÛÎó¤ÎÃæ¤Ë¾ï¤Ë¤½¤ì¤é¤ËÂФ¹¤ë +¶¯¤¤¥ê¥Õ¥¡¥ì¥ó¥¹¤¬¤¢¤ë¤«¤é¤Ç¤¹¡£ + +=back + +=head1 DIAGNOSTICS + +=begin original + +Module use may give one of the following errors during import. + +=end original + +¥â¥¸¥å¡¼¥ë¤Î use ¤Ï¡¢¥¤¥ó¥Ý¡¼¥ÈÃæ¤Ë°Ê²¼¤Î¥¨¥é¡¼¤Î°ì¤Ä¤¬µ¯¤¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£ + +=over + +=item Weak references are not implemented in the version of perl + +=begin original + +The version of perl that you are using does not implement weak references, to use +C<isweak> or C<weaken> you will need to use a newer release of perl. + +=end original + +»È¤Ã¤Æ¤¤¤ë¥Ð¡¼¥¸¥ç¥ó¤Î perl ¤Ï¼å¤¤¥ê¥Õ¥¡¥ì¥ó¥¹¤ò¼ÂÁõ¤·¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢ +C<isweak> ¤ä C<weaken> ¤ò»È¤¦¤Ë¤Ï¤è¤ê¿·¤·¤¤¥ê¥ê¡¼¥¹¤Î perl ¤¬É¬ÍפǤ¹¡£ + +=item Vstrings are not implemented in the version of perl + +=begin original + +The version of perl that you are using does not implement Vstrings, to use +C<isvstring> you will need to use a newer release of perl. + +=end original + +»È¤Ã¤Æ¤¤¤ë¥Ð¡¼¥¸¥ç¥ó¤Î perl ¤Ï v ʸ»úÎó¤ò¼ÂÁõ¤·¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢ +C<isvstring> ¤ò»È¤¦¤Ë¤Ï¤è¤ê¿·¤·¤¤¥ê¥ê¡¼¥¹¤Î perl ¤¬É¬ÍפǤ¹¡£ + +=item C<NAME> is only available with the XS version of Scalar::Util + +=begin original + +C<Scalar::Util> contains both perl and C implementations of many of its functions +so that those without access to a C compiler may still use it. However some of the functions +are only available when a C compiler was available to compile the XS version of the extension. + +=end original + +C<Scalar::Util> ¤Ï¡¢¤½¤Î¿¤¯¤Î´Ø¿ô¤Ë perl ¼ÂÁõ¤È C ¼ÂÁõ¤ÎξÊý¤ò»ý¤Ä¤Î¤Ç¡¢ +C ¥³¥ó¥Ñ¥¤¥é¤Ë¥¢¥¯¥»¥¹½ÐÍè¤Ê¤¯¤Æ¤â»È¤¨¤Þ¤¹¡£ +¤·¤«¤·¡¢°ìÉô¤Î´Ø¿ô¤Ï¡¢³ÈÄ¥¤Î XS ÈǤò¥³¥ó¥Ñ¥¤¥ë¤Ç¤¤ë C ¥³¥ó¥Ñ¥¤¥é¤¬ +ÍøÍѲÄǽ¤Ê¾ì¹ç¤Ë¤Î¤ßÍøÍѲÄǽ¤Ç¤¹¡£ + +=begin original + +At present that list is: weaken, isweak, dualvar, isvstring, set_prototype + +=end original + +¸½ºß¤Î¤È¤³¤í¡¢¤½¤Î´Ø¿ô¤Ï: weaken, isweak, dualvar, isvstring, set_prototype + +=back + +=head1 KNOWN BUGS + +=begin original + +There is a bug in perl5.6.0 with UV's that are >= 1<<31. This will +show up as tests 8 and 9 of dualvar.t failing + +=end original + +¤³¤ì¤Ï perl5.6.0 ¤Ç¤Î UV ¤¬ >= 1<<31 ¤Î¾ì¹ç¤Î¥Ð¥°¤Ç¤¹¡£ +¤³¤ì¤Ï dualvar.t ¤Î¥Æ¥¹¥È 8 ¤È 9 ¤¬¼ºÇԤȤ·¤Æ¸½¤ì¤Þ¤¹¡£ + +=head1 SEE ALSO + +L<List::Util> + +=head1 COPYRIGHT + +Copyright (c) 1997-2007 Graham Barr <gbarr****@pobox*****>. All rights reserved. +This program is free software; you can redistribute it and/or modify it +under the same terms as Perl itself. + +=begin original + +Except weaken and isweak which are + +=end original + +Îã³°¤È¤·¤Æ¡¢weaken ¤È isweak ¤Ï: + +Copyright (c) 1999 Tuomas J. Lukka <lukka****@iki*****>. All rights reserved. +This program is free software; you can redistribute it and/or modify it +under the same terms as perl itself. + +=begin meta + +Translate: Kentaro Shirakata <argra****@ub32*****> +Status: completed + +=end meta + +=cut +