Rich Parker wrote:
> 
> Howdy,

Hello,

> I use many different languages here at work, from Assembly, Rexx, to
> other mainframe languages. One thing I find it difficult to do with Perl
> is the handling of Hex characters. This may seem like a very generalized
> question, forgive me for trying to find a "Better way to do it". Picture
> having a flat file, or an SQL table (Doesn't matter that much), I want
> to delimit a field within a field, like having options. I can't use the
> TAB (\t) character, because when I use the "foreach" the sub fields also
> get "Split", therefore loosing what I am attempting to do. So I wanted
> to use a hex character, let's say something simple, hex'01' for example.
> What do you guys use for saying something like:
> 
> $loc = index($rec, $HexValue);  OR
> @sub_field1 = split(/$HexValue/, $rec);
> 
> Where the $HexValue is either a variable that contains my hex'01' or the
> absolute value itself.
> 
> I've used 'sprintf' to limited success, but in other languages this is
> very simple. I'm looking for some different ways to do this, after all,
> that's what Perl is all about right? TIMTOWTDI...

Yes, that's right, there is more than one way to do it:

my $HexValue = "\01"; # or "\x1"

my $HexValue = chr 1;

my $HexValue = pack 'C', 1;

my $HexValue = sprintf '%c', 1;

vec( my $HexValue, 0, 8 ) = 1;


John
-- 
use Perl;
program
fulfillment

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

Reply via email to