arrays - basic perl: regex statement not working in perl 5.10.1 machine but works in 5.18? -


I'm testing the following code that compares the words of a string and searches for matches problem only code In the lower part of the regex statement, it does not produce any results / matches on the Linux server in the school which is going to run / test me, on which Perl 5.10.1 is used. Does it work fine on strawberry pearl for some reason on my local windows machine?

Is there any other way that the Regex statement given below can be modified, to get the same result on the earlier versions of Perl (or have I made a mistake somewhere)?

  Strict use; Use warnings; Use data: Dumper; My $ keyword_file = "keywords.txt"; # It changes for an array @keywords My $ myString = "This string will be logged in later; print"; #read Keywords my @keywords; Open (FH, "$ keyword_file") or die "Can not open $ keyword_file to read: $!"; While (& lt; FH & gt;) {chomp; Push (@keywords, $ _); } Close FH or die "$ keyword_file can not be closed: $!"; #compare Keywords and File String Foreign Currency (@keywords) {if ($ myString = ~ / $ _ /) {# has problems here & lt; ********** match ";}}   

The keyword file is just a simple text file that contains a word like print, .. etc ..

keywords.txt:

  Exit ls print grep    

On the Windows made you use Windows CR LF as the line end, then you can do this in Unix system without converting the end of the line to Unix Line Ending (LF). S It means that instead of just exit instead of $ _ in exit one cart refund. < P> Fix the end of the line (eg using dos2unix ), or on Unix system (windows s / \ s + \ z Handling Windows files on Change ).

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -