Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
3
Task/Introspection/Perl/introspection-1.pl
Normal file
3
Task/Introspection/Perl/introspection-1.pl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
require v5.6.1; # run time version check
|
||||
require 5.6.1; # ditto
|
||||
require 5.006_001; # ditto; preferred for backwards compatibility
|
||||
3
Task/Introspection/Perl/introspection-2.pl
Normal file
3
Task/Introspection/Perl/introspection-2.pl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#$bloop = -123; # uncomment this line to see the difference
|
||||
no strict 'refs'; # referring to variable by name goes against 'strict' pragma
|
||||
if (defined($::{'bloop'})) {print abs(${'bloop'})} else {print "bloop isn't defined"};
|
||||
2
Task/Introspection/Perl/introspection-3.pl
Normal file
2
Task/Introspection/Perl/introspection-3.pl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
eval('abs(0)'); # eval("") instead of eval{}; the latter is not for run-time check
|
||||
print "abs() doesn't seem to be available\n" if $@;
|
||||
8
Task/Introspection/Perl/introspection-4.pl
Normal file
8
Task/Introspection/Perl/introspection-4.pl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
use Math::Complex;
|
||||
my $cpl = Math::Complex->new(1,1);
|
||||
|
||||
print "package Math::Complex has 'make' method\n"
|
||||
if Math::Complex->can('make');
|
||||
|
||||
print "object \$cpl does not have 'explode' method\n"
|
||||
unless $cpl->can('explode');
|
||||
13
Task/Introspection/Perl/introspection-5.pl
Normal file
13
Task/Introspection/Perl/introspection-5.pl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
use 5.010;
|
||||
our $bloop = -12;
|
||||
if (defined $::bloop) {
|
||||
if (eval { abs(1) }) {
|
||||
say 'abs($bloop) is ' . abs($::bloop);
|
||||
}
|
||||
else {
|
||||
say 'abs() is not available';
|
||||
}
|
||||
}
|
||||
else {
|
||||
say '$bloop is not defined';
|
||||
}
|
||||
16
Task/Introspection/Perl/introspection-6.pl
Normal file
16
Task/Introspection/Perl/introspection-6.pl
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
use 5.010;
|
||||
package test;
|
||||
use Regexp::Common;
|
||||
use List::Util qw(sum);
|
||||
|
||||
our $a = 7;
|
||||
our $b = 1;
|
||||
our $c = 2;
|
||||
our $d = -5;
|
||||
our $e = 'text';
|
||||
our $f = 0.25;
|
||||
|
||||
my @ints = grep { /^$RE{num}{int}$/ } map { $$_ // '' } values %::test::;
|
||||
my $num = @ints;
|
||||
my $sum = sum @ints;
|
||||
say "$num integers, sum = $sum";
|
||||
7
Task/Introspection/Perl/introspection-7.pl
Normal file
7
Task/Introspection/Perl/introspection-7.pl
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
use 5.010;
|
||||
use Regexp::Common;
|
||||
use List::Util qw(sum);
|
||||
my @ints = grep { /^$RE{num}{int}$/ } map { $$_ // '' } values %::;
|
||||
my $num = @ints;
|
||||
my $sum = sum @ints;
|
||||
say "$num integers, sum = $sum";
|
||||
Loading…
Add table
Add a link
Reference in a new issue