#!/usr/bin/perl -w use strict; use warnings; my $mystring = "ABCblahblahDEF"; if ( $mystring =~ /($.)<\/ID>/) { my $ID = $1; print "$ID\n"; } #### dpich@m6400-vb:~/Documents$ perl ./xml.pl Use of uninitialized value $. in regexp compilation at ./xml.pl line 6. dpich@m6400-vb:~/Documents$