$ perl -MTest::More -e 'plan "no_plan"; print use_ok("Does::Not::Exist"), "\n"; print pass("This is ok"), "\n"'
not ok 1 - use Does::Not::Exist;
# Failed test 'use Does::Not::Exist;'
# at -e line 1.
# Tried to use 'Does::Not::Exist'.
# Error: Can't locate Does/Not/Exist.pm in @INC (@INC contains: blah blah blah) at (eval 3) line 2.
# BEGIN failed--compilation aborted at -e line 1.
0
ok 2 - This is ok
1
1..2
# Looks like you failed 1 test of 2.
####
$ perl -MTest::More -e 'plan "no_plan"; BEGIN {print use_ok("Does::Not::Exist"), "\n"} print pass("This is ok"), "\n"'
ok 1 - This is ok
1
1..1
####
if ($a || # Some reason
$b # Some other reason
####
BEGIN {
my $success = eval {
use_ok($module);
1;
};
isnt($success, 1, "eval of use_ok failed (as expected)");
}
####
BEGIN {
if ($foo) { die "this case should not succeed"; }
}
####
use strict;
use warnings;
my ($ifh, $var1, $var2);
my $infilename = '/etc/issue';
open($ifh, '<', $infilename);
while (<$ifh>) {
chomp;
if ( /^(Red) (Hat)/ ) {
($var1, $var2) = ($1, $2);
print "$var1$var2\n";
}
}
close ($ifh);
####
my $nics = qx |/sbin/ifconfig| or die("Can't get info from ifconfig: $!\n");
my @nics = split /(?<=\n)(?=\w)/, $nics;
for (@nics) {
my %nic;
($nic{device}) = $_ =~ /^(eth\d)\s/
or next;
if (/\binet addr:([\d.]+)\s.+?:([\d.]+)\s.+?:([\d.]+)/) {
$nic{ip} = $1;
$nic{bcast} = $2;
$nic{mask} = $3;
# print "Device: $nic{device} has the IP Address of $nic{ip}\n\tMask: $nic{mask}\n\tBroadcast: $nic{bcast}\n";
}
if (/^\s+ inet6 addr:\s*(\S+)/m) {
$nic{ip6} = $1;
# print "Device: $nic{device} also has IPv6 address of $nic{ip6}\n";
}
# Do all printing here....
# this statement needs work.
# print "Device: $a\n\tIPv4: $b\n\tBcast: $c\n\tMask: $d\n\tIPv6: $e\n";
}
####
use strict;
use warnings;
use diagnostics;
binmode STDOUT;
# This should really be explicit about the \r\n
print "Content-Type: text/plain\n\n";
print 'Hello World';
####
use strict;
use warnings;
my $tr="" . ("| (.*?) | "x8) . "
";
while () {
my @x = m/\G$tr/cgo or next;
print join("|", @x), "\n";
}
__DATA__
| I | am | Santa | Clause | I | am | Santa | Clause |
Blah Blah This Will Not Match
| I | am | Easter | Bunny | I | am | Easter | Bunny |
| Neither | Will | This |
####
use Win32::OLE::Variant;
...
$property->{Value} =
Win32::OLE::Variant->new(VT_BOOL, 0xFFFFFFFF);
####
$blah->Disconnect;
$blah = Vendor::Lib->Connect(...);
####
$blah->Disconnect;
$blah = undef;
$blah = Vendor::Lib->Connect(...);
####
(cd d1 && find .) | sort > out.1
(cd d2 && find .) | sort > out.2
diff out.1 out.2
####
#!/bin/ksh
for x in *.pl; do
if [[ -f "$x" ]]; then
./what_you_want_to_do *.pl
break
fi
done
####
#!/bin/ksh
for x in *.pl; do
if [[ -f "$x" ]]; then
exec ./what_you_want_to_do *.pl
fi
done
####
#!perl
use strict;
use warnings;
my $base = shift;
my $pattern = shift;
print "Base = $base, pattern = $pattern\n\n";
my %checkthese;
while ($base =~ m/\G($pattern)/g) {
my $pos = pos($base);
print "POS = ", $pos, "\n";
my $pre = substr($base,0,$pos - 1);
my $match = $1;
my $post = substr($base,$pos);
$checkthese{"$pre:$match:$post"} = {
pre => $pre,
match => $match,
post => $post,
};
pos($base) = $pos + 1;
}
print "\n\n", "End", "\n\n";
print join("\n", keys %checkthese), "\n";