my ( $second_word ) = $string =~ m{\|([^|]*)\|}; #### my ( $second_word ) = $string =~ m{ \| # "|" escaped because it's special inside a regexp ( # start capturing [^|]* # some not |'s ) # end capture \| # another "|" }x;