Perl Basics
my $name = "Alice";
my @nums = (1, 2, 3);
my %hash = (name => "Alice", age => 25);
print "Hello, $name!\n";
foreach my $n (@nums) { print "$n\n"; }
Regular Expressions
if ($text =~ /pattern/) { print "Matched!"; }
$text =~ s/old/new/g; # substitute all
Summary
- Perl excels at text processing
- $ for scalar, @ for array, % for hash
YouTip