Socrates440 has asked for the wisdom of the Perl Monks concerning the following question:
I am working my way through a beginning perl text book in my free time and I am currently reading the chapter on regular expressions. Anyways, I am confused by a piece of this code:
I get that it is storing the string \box\ in the varriable $what. If I understand it right, the foreach statement parses each of the strings in the parenthesies looking for the string \box\. What is the "qw" in the line "(qw(in\box\ out\box\ white\sox\))" though? I have no idea what that is. Sorry about the words box and sox being highlighted in red. I don't know how to stop this site from interpolating (correct word?) the brackets.$what = "[box]"; foreach (qw(in[box] out[box] white[sox])) { if (/\Q$what\E/) { print "$_ matched!\n"; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: I don't understand a piece of this code
by bitingduck (Chaplain) on Jun 18, 2012 at 03:07 UTC | |
Re: I don't understand a piece of this code
by Albannach (Monsignor) on Jun 18, 2012 at 03:40 UTC | |
by bitingduck (Chaplain) on Jun 18, 2012 at 03:49 UTC | |
Re: I don't understand a piece of this code
by cheekuperl (Monk) on Jun 18, 2012 at 03:25 UTC | |
Re: I don't understand a piece of this code (What is qw()? How does qw() work?)
by Anonymous Monk on Jun 18, 2012 at 03:30 UTC | |
Re: I don't understand a piece of this code
by jamesbutler (Initiate) on Jun 18, 2012 at 04:07 UTC |
Back to
Seekers of Perl Wisdom