Mastering Perl Learning Notes

This is for the book “mastering perl”. There are some code snippets in this book which I think is quite useful, thus I keep a note of them below.

1.global matching:

1
2
3
$_ = "Just another Perl hacker,";
my @words = /(\S+)/g; # "Just" "another" "Perl" "hacker,"
print join("",split(@words));

2.my $word_count = () = /(\S+)/g;
It will give out the number of matched items.

3.