How do I interpret debugger text representation?

S

Sara

I have a scalar, which according to the debugger, has some weird stuff
in it:

DB<28> x $_
0 "\c@\[email protected]\cC\c@\c@T25\cH\c@\c@mm18-mn1\cC\c@\c@T2"

I'm not entire sure how this is delimited, but I tried a number of
ways to carve it up:

@v = split /\[A-Z]/
(didn't work)
@v = split /\\[A-Z]/
(didn't work)
@v = split /\\./
(didn't work)
@v = split /\./
(didn't work)

How can I split up this scalar on \c*anything* ? What IS \c*something*
anyhow? Control-*something* ?

Tanx
 
P

Peter Scott

I have a scalar, which according to the debugger, has some weird stuff
in it:

DB<28> x $_
0 "\c@\[email protected]\cC\c@\c@T25\cH\c@\c@mm18-mn1\cC\c@\c@T2"

I'm not entire sure how this is delimited, but I tried a number of
ways to carve it up:

@v = split /\[A-Z]/
(didn't work)
@v = split /\\[A-Z]/
(didn't work)
@v = split /\\./
(didn't work)
@v = split /\./
(didn't work)

How can I split up this scalar on \c*anything* ? What IS \c*something*
anyhow? Control-*something* ?

Yes.

@v = split /[[:cntrl:]]/

I don't see what splitting that string on control characters is going to
achieve. You need to know more about how it got created.
 
B

Bob Walton

Sara said:
I have a scalar, which according to the debugger, has some weird stuff
in it:

DB<28> x $_
0 "\c@\[email protected]\cC\c@\c@T25\cH\c@\c@mm18-mn1\cC\c@\c@T2"
....
How can I split up this scalar on \c*anything* ?


Well, what you probably want to do is to split it up by characters.
That can be done by splitting on the null pattern:

my @chars=split //,$scalar;

or to print it with decimal character codes:

print join ':',map {ord} split //,$a;

What IS \c*something*
anyhow? Control-*something* ?


Yep. \c@ is chr(0), \cA is chr(1), etc. The debugger outputs the
string that way so you can tell what is in it -- if it put the control
characters straight to your console terminal, you'd get all sorts of odd
stuff.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top