#!/usr/bin/perl
use strict;
use warnings;
print "How old are you?";
$age = <>;
print "What is your favorite color?";
$color = <>;
print "You are $age, and your favorite color is $color.";
####
Global Symbol "$age" requires explicit package name at agecolor.pl line 5
Global Symbol "$color" requires explicit package name at agecolor.pl line 7
Global Symbol "$age" requires explicit package name at agecolor.pl line 8
Global Symbol "$color" requires explicit package name at agecolor.pl line 8
Execution of agecolor.pl aborted due to compilation errors.
####
#!/usr/bin/perl
use strict;
use warnings;
print "What is the radius of the circle?";
chomp ($r = <>);
$diameter = (2 * $r);
$area = (3.14 * ($r ** 2));
$cir = ($diameter * 3.14);
print "Radius: $r\n Diameter: $diameter\n Circumference: $cir\n Area: $area";
####
Global symbol "$r" requires explicit package name at diameter.pl line 5.
Global symbol "$diameter" requires explicit package name at diameter.pl line 6.
Global symbol "$r" requires explicit package name at diameter.pl line 6.
Global symbol "$area" requires explicit package name at diameter.pl line 7.
Global symbol "$r" requires explicit package name at diameter.pl line 7.
Global symbol "$cir" requires explicit package name at diameter.pl line 8.
Global symbol "$diameter" requires explicit package name at diameter.pl line 8.
Global symbol "$r" requires explicit package name at diameter.pl line 9.
Global symbol "$diameter" requires explicit package name at diameter.pl line 9.
Global symbol "$cir" requires explicit package name at diameter.pl line 9.
Global symbol "$area" requires explicit package name at diameter.pl line 9.
Execution of diameter.pl aborted due to compilation errors.
####
#!/usr/bin/perl -w
use strict;
use warnings;
# slowcat - emulate a slow line printer
# usage: slowcat [-DELAY] [files ...]
$DELAY = ($ARGV[0] =~ /^-([.\d]+)/) ? (shift, $1) : 1;
$| = 1;
while (<>) {
for (slit(//)) {
print;
select(undef,undef,undef, 0.005 * $DELAY);
}
}
####
Global symbol "$DELAY" requires explicit package name at 1.1slowcat.pl line 6.
Global symbol "$DELAY" requires explicit package name at 1.1slowcat.pl line 11.
Execution of 1.1slowcat.pl aborted due to compilation errors.
####
#!/usr/bin/perl -p
#
randcap: filter to randomly capitalize 20% of the letters
# call to srand() is unnecessary in 5.004
BEGIN { srand(time() ^ ($$ + ($$ << 15))) }
sub randcase { rand(100) < 20 ? "\u$_[0]" : "\l$_[0]" }
s/(\w)/randcase($1)/ge;
####
% randcap < genesis | head -9
####
Semicolon seems to be missing at 1.2randcap.pl line 5.
syntax error at 1.2randcap.pl line 6, near "letters
# call to srand() is unnecessary in 5.004
BEGIN "
syntax error at 1.2randcap.pl line 10, near ";}"
Execution of 1.2randcap.pl aborted due to compilation errors.
####
#!/usr/bin/perl -w
use strict;
use warnings;
# wrapdemo - show how Text::Wrap works
@input = ("Folding and splicing is the work of an editor, ",
"not a mere collection of silicon",
"and",
"mobile electrons!");
use Text::Wrap qw($columns &wrap);
$colums = 20;
print "0123456789" x 2, "\n";
print wrap(" ", " ", @input), "\n";
####
Global symbol "@input" requires explicit package name at 1.3wrapdemo.pl line 6.
BEGIN not safe after errors--compilation aborted at 1.3wrapdemo.pl line 11.