Missing Something.

Nic Gibson nicg at noslogan.org
Mon Oct 1 16:01:53 BST 2007


Hi David.

On 01/10/2007, Clooney, David <david.clooney at bankofamerica.com> wrote:
> On no a perl question!
>

It happens :


>
>
> Can someone point out if I am missing something, I don't seem to be able
> to match a  variable with an element of an array, the list will most
> probably spot it straight away, I however am an amateur.
>
> Using CGI.pm
>
>
>
>
>
>     open(EMACRXFNP02,
> "<content_data/spdm828a/emacrxfnp02.emea.bankofamerica.com");
>
>     @crxfnp02_users = <EMACRXFNP02>;
>
>     close(EMACRXFNP02);
>
>
>
>     $chester_userid = (param('chester_userid'));
>
>     chomp $chester_userid;
>
>
>
>     if         ($crxfnp02_users =~ m/$chester_userid /i ) {
>
>                 $client = 'servername.com';
>
>                  print $crxfnp02_users;
>
>                 }
>

So, if I have that straight, you are tying to find $chester_userid in the array
@crxfnp02_users? If so, you have one or two problems. Firstly, you are
trying to look for
$chester_userid in a string calls $crxfnp02_users not your array. In
order to match
within that array you want something like:

           if (grep { m/$chester_userid /i} @crxfnp02_users)
           { ... }

Secondly, do you really want a space after that match?

If you're looking for the string anywhere in the file, you might find
it more efficient to do something like the below because I don't think
you actually need to split up that file:


       ...
       local $/ = undef;
      $crxfnp02_users = <EMACRXFNP02>;
       close(EMACRXFNP02);

     ....

     if ($crxfnp02_users =~ m/$chester_userid /)
    { ... }

I'd suggest that putting 'use strict' at the start of your script
would help too.

hth

nic




> Cheers
>
>
>
> Dave
>
>
>
>
> Notice to recipient:
> The information in this internet e-mail and any attachments is confidential and may be privileged. It is intended solely for the addressee. If you are not the intended addressee please notify the sender immediately by telephone. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.
>
> When addressed to external clients any opinions or advice contained in this internet e-mail are subject to the terms and conditions expressed in any applicable governing terms of business or client engagement letter issued by the pertinent Bank of America group entity.
>
> If this email originates from the U.K. please note that Bank of America, N.A., London Branch and Banc of America Securities Limited are authorised and regulated by the Financial Services Authority.
>


-- 
Nic Gibson
Director, Corbas Consulting
Editorial and Technical Consultancy
http://www.corbas.co.uk/


More information about the london.pm mailing list