how do I print the name and value of a scalar

C

Charlton Wilbur

cc> This didn't start out like this.

It never does!

cc> It started out as a quick and dirty little solution to a little
cc> problem. It was a database problem and the purpose was to clean
cc> up some data, and it was MY automation. When some other people
cc> saw what a good thing it was, they went to my supervisor, and my
cc> supervisor came to me, and over a period of time it just grew,
cc> without any thought given to design and with no planning
cc> whatsoever.

Exactly. And now you're dealing with the ramifications of that lack of
thought and lack of planning. But instead of taking what you know now
and cleaning up the code, you're just piling band-aids on it.

cc> Come talk to my boss, and his boss. I do my work on schedule and
cc> under budget.

No, you don't. The only reason you're on schedule and under budget is
because you're deferring a huge amount of maintenance. This is like
claiming you're living well within your means because you're charging
half your monthly expenses to a credit card. It works for a while, but
when you hit your credit limit, it all comes crashing down.

cc> If I were a prophet and could foretell the monster around the
cc> corner, I'd be all set. Do you have any advice on how to do
cc> this?

You don't know what the monster around the corner will be, but it's not
relevant. Whether it's a basilisk or a manticore, it will be easier to
deal with if your code base is clean.

Right now you *do* know that your code base has reached the point where
it's difficult to maintain. Why are you dicking around with band-aid
solutions on top of rickety data structures on top of bad design
decisions on top of a script that was quick-and-dirty in the first
place? Why are you wasting your time defending bad design decisions
when you could be fixing them?

You asked a question about how to solve a problem. No fewer than five
people told you the best, cleanest way to solve that problem. And then
you came back here and crowed about finding a solution that you were
explicitly told was a bad idea. Why do you come here for advice if
you're just going to ignore it? Why should anyone bother to answer your
questions if you're just going to ignore the answers?

Charlton
 
R

RedGrittyBrick

cartercc said:
I might add that in Lisp I can do this without a problem,

My advice (worth what you paid for it) is that it is better to write
Lisp in Lisp.
 
R

RedGrittyBrick

Frank said:
Why? Seems, that this is the thing the OP is looking for.

perldoc -q "variable name"

Others have already posted this, to this thread, but I think it bears
repeating.
 
F

Frank Seitz

RedGrittyBrick said:
perldoc -q "variable name"

Others have already posted this, to this thread, but I think it bears
repeating.

I want to know what is wrong with PadWalker as a debugging aid. I think
the OP wants to understand/debug his confusing code.

Frank
 
R

RedGrittyBrick

Frank said:
I want to know what is wrong with PadWalker as a debugging aid. I think
the OP wants to understand/debug his confusing code.

Ah, your "this" referred to the penultimate sentence you quoted and not
to the last sentence you quoted.

I think Frank was referring to the sentence you have now omitted, namely
"AFAIK it's not possible in Perl to get the name of a lexical (my)
variable."

It's the getting of the name of a lexical variable that nearly always
isn't a good idea.

I don't think Frank intended to suggest that there was anything wrong
with PadWalker as a debugging aid (though he didn't say the opposite
either.)
 
C

cartercc

That's a new definition of "bright guy"

   BugBear

Not really. My definition of 'bright guy' includes a lot of
imagination and creativity. You can always look stuff in a book if you
need to, like the parameters and return values of functions for
instance. It also includes a lot of patience and stick-to-it-ness.

Albert Einstein was 'slow.' I'm not in the same category, but I like
to think of thoroughness as the opposite of quick, and I'd rather be
thorough than quick.

Maybe I'm capitalizing on my deficiency! ;-)

CC
 
F

Frank Seitz

RedGrittyBrick said:
Ah, your "this" referred to the penultimate sentence you quoted and not
to the last sentence you quoted.
Yes.

I think Frank was referring to the sentence you have now omitted, namely
"AFAIK it's not possible in Perl to get the name of a lexical (my)
variable."

It's the getting of the name of a lexical variable that nearly always
isn't a good idea.

I don't think Frank intended to suggest that there was anything wrong
with PadWalker as a debugging aid (though he didn't say the opposite
either.)

s/Frank/Ben Morrow/g;

Thank you for the clarification. Apparently I misunderstood him because
I am not a native speaker of English.

Frank
 
J

Joost Diepenmaat

cartercc said:
I might add that in Lisp I can do this without a problem, by printing
the symbol and then the value of the symbol. I ought to be able to do
this easily in Perl, but I can't. I'm willing to take the hit for my
confusion, or my ignorance.

You can only do that in (Common Lisp) with special variables, not with
lexicals. You can do the same in perl if you're willing to use globals
instead of lexicals. The reasons for this and the associated problems
when using that approach are the same too.

(setq val 'special)
(let ((val 'lexical))
(symbol-value 'val))
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top