rithu wrote:
Hi,

Hello,

I'm an oracle user. One of my implementation needs a little bit of
perl usage.

i've an array(@hexa_tableau) which contains restricted hexadecimal
characters and a string which is converted into hexadecimal.

 while ((@carac) = $sel->fetchrow_array) {
        push(@hexa_tableau, $carac[0]);
    }

Since you are not using $carac[1] through $carac[$#carac] there is no need to capture them as well. Just use a list with a single scalar:

while ( my ( $carac ) = $sel->fetchrow_array ) {
        push @hexa_tableau, $carac;
    }


my (@chars) = unpack("H*" => $line);
my (@hexed) = map {$_} @chars;

That is the same as saying:

my @hexed = @chars;

What were you intending to use the map() for?


my $hexed   = uc join(' ' => @hexed);

I just wanted to check that any of the hexadecimal code present in
array (@hexa_tableau) appears in the string($hexed)

For example if my @hexa_tableau = ("00","01","02");
and $hexed = '6100636465414353206664736161647361640A'

You are using join() with a space character but there are no spaces in that string. Does @hexed only contain one element?


 if (check the presence here)
{
print "exists";
}

my $string  = pack 'H*', $hexed;
my $pattern = '[' . join( '', map chr hex, @hexa_tableau ) . ']';

if ( $string =~ /$pattern/ )
{
print "exists\n";
}




John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.               -- Damian Conway

--
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