David Mamanakis wrote:
> 
> sub validateCLSMSResponse
> {
>  my $self = shift;
>  my $Response = undef;
>  my $CheckString = shift;
>  my @Holder = shift;

the above could be bad. you only shift one element from @Junk into @Holder. 
If you have:

@Junk = ('hi','hello','whatever','another');
$TE->validateCLSMSresponse('whatever',@Junk);

@Holder will have only one element: 'hi'

you probably mean:

@Holder = @_;

> $Response = grep { /$CheckString/i } @Holder;

grep returns an array with all elements matching the reg. exp. you supply or 
() if nothing matches. you are using it in a scalar context which is fine 
for a boolean value such as when you use $Response in the 'if' statment. 
just make sure you don't really mean:

@Response = grep { /$CheckString/i } @Holder;

> 
> The problem I am having is that sometimes the information in the array may
> get truncated to 8 character slices.  This is expected.
> The information I am trying to compare to may be longer, so this fails. I

could the fail related to the above?


> need to truncate $CheckString to 8 characters (the first 8 characters) or
> only compare the first 8 characters of $CheckString to the contents of
> @Holder.
> 

to turncate a string to the first 8 characters:

substr($string,8) = '';

to compare just the first 8 characters:

if(substr($string,0,8) eq 'whatever'){
        print "match\n";
}else{
        print "not match\n";
}

or:

if(unpack('A8',$string) eq 'whatever'){
        print "match\n";
}else{
        print "not match\n";
}

the unpack() function could prove to be a bit faster.

david

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to