package Switch; use Exporter; @ISA = qw(Exporter); @EXPORT = qw(switch case break);
=usage
use Switch; chomp($value = <>); switch $value, case 'a' => sub { print "This is first a.\n"; }, case 'b' => sub { print "This is first b.\n"; break; }, case 'a' => sub { print "This is second a.\n"; }, case 'b' => sub { print "This is second b, but will not display ...\n"; }, default => sub { print "Other.\n"; }; =cut
BEGIN { _init; }
sub break { 'break'; }
sub switch ($%) { my($value, %other) = @_; _default(%other);
%subs = map{($_ => \&{$_} )} qw(a b c d e f); &{$subs{$mode} or "default"}();
#サブルーチン(内容は適当) sub a{ print "a() called";} sub b{ print "b() called";} sub c{ print "c() called";} sub d{ print "d() called";} sub e{ print "e() called";} sub f{ print "f() called";} sub default{print "default() called";}
my %subs = ( a => sub { return 'a called' }, b => sub { return 'b called' }, c => sub { return 'c called' }, d => sub { return 'd called' }, e => sub { return 'e called' }, f => sub { return 'f called' }, def => sub { return 'default called' } );
Class-Tom depends on Devel-Symdump GDTextUtil depends on GD Tk-ObjScanner depends on Tk URI depends on MIME-Base64 GDGraph depends on GDTextUtil,GD libwww-perl depends on HTML-Parser,URI DBD-CSV depends on Text-CSV_XS,SQL-Statement,DBI Chart depends on GD PPM depends on HTML-Parser,Archive-Tar,URI,Compress-Zlib,XML-Element,MIME-Base64,libwww-perl,XML-Parser Jcode depends on MIME-Base64 Tk-GBARR depends on Tk XML-Element depends on XML-Parser SOAP-Lite depends on URI,MIME-Base64,libwww-perl,XML-Parser,MIME-Tools
>>222 \bは、\Wと\wの境界です・・・・って日本人には余り馴染みがなひから、確かにわかりづらいですね。 試しに、 ---- ($str = "When it comes to health, the best thingis not to get angry in the first place.") =~ s/\b/%/g; print $str; ---- として表示されるものを眺めると、大体の感じが掴めるかと思います。
perldoc -f stat >10 ctime inode change time (NOT creation time!) in seconds since the epoch ^^^^^^^^^^^^^^^^^^^^^ How do I find the creation time of a file?
You can't - it isn't stored anywhere. Files have a last-modified time (shown by "ls -l"), a last-accessed time (shown by "ls -lu") and an inode change time (shown by "ls -lc"). The latter is often referred to as the "creation time" - even in some man pages - but that's wrong; it's also set by such operations as mv, ln, chmod, chown and chgrp.
Only the first entry returned is nonzero. (Mac OS) ``cumulative'' times will be bogus. On anything other than Windows NT or Windows 2000, ``system'' time will be bogus, and ``user'' time is actually the time returned by the clock() function in the C runtime library. (Win32)
Constant Functions Functions with a prototype of () are potential candidates for inlining If the result after optimization and constant folding is either a constant or a lexically-scoped scalar which has no other references, then it will be used in place of function calls made without &. Calls made using & are never inlined.
>>551 perldoc strict This generates a compile-time error if you access a variable that wasn't declared via ``our'' or use vars, localized via my(), or wasn't fully qualified.
ですので、Perl5.6以降ならばourを用いて our $X = "a"; と宣言するのが一番です。 又は、(5..6以前ならば) $main::X = 'a'; や my $X = 'a'; や use vars qw[$X]; とするといいです。