pattern searching in perl -


use strict;  use warnings;  open(file1, "/cygdrive/c/cpros/mola.txt"); $line = <file1>; print $line; close(file1); open(file1, ">/cygdrive/c/cpros/mola.txt");  if ($line = ~ /karthik/) {   print file1 ("1"); } else {   print file1 ("0"); }  close(file1); 

i have stored hello world in mola.txt file still printing 1 pattern karthik not saved in file why printing 1 ? how make search patterns?

=~ separate operator, shouldn't have whitespace between characters. whitespace, condition of if statement becomes assignment yields true.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -