Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changed Regex 1

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
I posted a regex question in thread
[URL unfurl="true"]http://www.tek-tips.com/viewthread.cfm?qid=1727047[/url]

and you guys came up with the solution of

Code:
$str =~ s!\.(\d{4})!$1~~[1800..2030]?".<sup>$1</sup>":$&!ge;

You also warned that Smartmatch was to be experimental and not to rely on the solution.
The regex has now stopped working and I find myself looking once again for a solution.

Is there a supported alternative to Smartmatch or can you suggest a different approach?


Keith
 
Hi

Which Perl version ?

The original code still works for me in Perl 5.18.2. Indeed now yells "Smartmatch is experimental at audiopro.pl line 7." to STDERR, but the regular expression is not affected and works as before. ( Getting rid of the warning by adding [tt]no warnings [green]'experimental::smartmatch'[/green][teal];[/teal][/tt], results no visible difference compared to original functionality. )


Feherke.
feherke.ga
 
I have recently moved the site to a new server which uses version 5.008008.

All I get is a 500 error when I run the previously working script, rather than a warning.
Not sure how to implement that 'no warnings' command but I would have thought that turning Warnings off altogether would give a similar result but still the 500 error.
I will knit a manual solution if it is going to be troublesome.




Keith
 
Hi

Then that is the problem. The smartmatch operator was introduced only in Perl 5.10.

So you will have to use Miller's solution posted on 16 Feb 14 20:03 in the original thread219-1727047 .


Feherke.
feherke.ga
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top