Perl contains local special variables $1 to $9. These variables contains the sub patterns which are matched from the earlier pattern. For example:
#!/usr/bin/perl my $var="Perl is beautiful"; my $var1="Perl is beautiful"; $var =~ m/(\w+) (.*)/; print "The first word is: ", $1, "\n"; print "The remaining part is: ", $2, "\n";