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
Post a Comment