Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: pattern matching once

by jo37 (Deacon)
on Aug 11, 2023 at 09:30 UTC ( [id://11153808] : note . print w/replies, xml ) Need Help??


in reply to Re: pattern matching once
in thread pattern matching once

if ( $line =~ ?<FILENAME>.*\.htm? ) {

This should be:

if ( $line =~ m?<FILENAME>.*\.htm? ) {

Greetings,
-jo

$gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$

Replies are listed 'Best First'.
Re^3: pattern matching once
by jwkrahn (Abbot) on Aug 11, 2023 at 17:27 UTC

    perldoc perlop
    
    ...
    
           "m/PATTERN/msixpodualngc"
           "/PATTERN/msixpodualngc"
    
    ...
    
           "m?PATTERN?msixpodualngc"
           "?PATTERN?msixpodualngc"
    
    

    With the // or ?? delimiters the m at the beginning is optional.

    Naked blocks are fun! -- Randal L. Schwartz, Perl hacker
      With the // or ?? delimiters the m at the beginning is optional.

      That was true until about 8 years ago. Now:

      In the past, the leading m in m?PATTERN? was optional, but omitting it would produce a deprecation warning. As of v5.22.0, omitting it produces a syntax error. If you encounter this construct in older code, you can just add m.

      Typo fix

        -- for perl golf :-(

        Naked blocks are fun! -- Randal L. Schwartz, Perl hacker

      I guess it's time to switch to a modern Perl?

      That seems to be gone in Perl 5.26, though I failed to spot it in perldelta.