On Dec 27, 2:34 pm, paragka...@gmail.com (Parag Kalra) wrote:

> I was under the impression that regex modifier '/x' ignores the white
> space.

It ignores white space in the regular expression, not in the text you
are matching.

For example, the following are equivalent:

    if($str =~/$str3/x){

    if($str =~/    $str3    /x){

To do what you want, you can use '\s*' in your regular expression
where ever white space that you want to ignore can be:

if ($str =~ /hello\s*world/) {

or, you can first remove all the white space from your string before
attempting a match like:

(my $tmp=$str) =~ s/\s*//g;  # assign $str3 to $tmp and then use s/
\s*//g to remove all white space from $tmp
if ($tmp =~ /helloworld/) { # now compare


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to