#!/usr/bin/perl -w
use strict;
if ("helloworld" =~ / world/)
{
print "match"
}
else
{
print "bad."
}
print "/n";
# extract matches
my $time = "09:30:28";
my ($h, $m, $s) = ($time =~ /(/d/d):(/d/d):(/d/d)/);
print $h;
print $m;
print $s;
print "/n";
# replace
my $line = "hello world";
$line =~ s/world/perl/;
print $line;
print "/n";
#split
my @dict;
my $word_list = "apple banana orange";
@dict = split(//s+/, $word_list);
foreach(@dict) { print $_."/n"; };
# hash
my %hash1 = ();
foreach(@dict)
{
$hash1{$_} = $_."_value";
}
# print hash
print "$hash1{$_} = $_/n" for keys %hash1;
# read file
print "content of ".$0."/n";
my @lines = ();
open(H1, "<$0") or die "fail to open".$0;
@lines = <H1>;
#print @lines;
print "line count = ".scalar(@lines)."/n";
close(H1);
# grep
my @odds = grep { $_ % 2 } 1..100;
print @odds;
print "/n";
# print time
print scalar localtime;