davidj has asked for the wisdom of the Perl Monks concerning the following question:
Fellow monks,
I have been scratching my head over this trying to figure out what I am doing wrong. For the life of me, I am not seeing it. I am using grep to test the value of a query paramater. The value IS in the list, but grep is not finding it. I hope I have included all the relevant information below.
The form part looks like this:
If I understand grep correctly, I should be getting:
As always your assistance is much appreciated.
davidj
I have been scratching my head over this trying to figure out what I am doing wrong. For the life of me, I am not seeing it. I am using grep to test the value of a query paramater. The value IS in the list, but grep is not finding it. I hope I have included all the relevant information below.
The form part looks like this:
After selecting any of the option (in this case sender), I do the following in the cgi script:<select name="report_type" > <option value="case_id">case_id</option> <option value="hosp_alias">hosp_alias</option> <option selected="selected" value="sender">sender</option> <option value="receiver">receiver</option> <option value="date">date</option> </select>
The output I get is this:print "param=" . $q->param('report_type') . "<BR>"; if( grep { /$q->param('report_type')/ } (qw/case_id hosp_alias sender +receiver/) ) { print "we are getting the list<BR>"; } else { print "we are NOT getting the list<BR>"; }
At this point I am not modifying in any way the query parameters after they are sent to the script.param=sender we are NOT getting the list
If I understand grep correctly, I should be getting:
If I take this part and put it in a simple script, I works correctly:param=sender we are getting the list
output:#!/usr/bin/perl $p = 'sender'; if( grep { /$p/ } (qw/case_id hosp_alias sender receiver/) ) { print "getting the list\n"; } else { print "not getting the list\n"; }
Why am I not getting what is expected? The value is verifiably in the list. The grep syntax is correct.getting the list
As always your assistance is much appreciated.
davidj
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: grep not working as expected
by imp (Priest) on Oct 17, 2006 at 22:31 UTC | |
Re: grep not working as expected
by chargrill (Parson) on Oct 17, 2006 at 22:31 UTC | |
Re: grep not working as expected
by davidj (Priest) on Oct 17, 2006 at 22:41 UTC | |
Re: grep not working as expected
by ammon (Sexton) on Oct 17, 2006 at 22:33 UTC | |
Re: grep not working as expected
by GrandFather (Saint) on Oct 17, 2006 at 22:34 UTC |
Back to
Seekers of Perl Wisdom