$var = ".declare book_num a13"; $var =~ s/^\.\w+\s+(\w+).*$/$1/g; #### $var = ".declare book_num a13"; $var =~ /^\.\w+\s+(\w+)/; print $1;