Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

obj dump

by Anonymous Monk
on Sep 24, 2001 at 14:18 UTC ( #114272=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

#!/usr/bin/perl -s while(<STDIN>) { foreach $a (@ARGV) { if (/<$a>/) { $y = 1; print "\n" if $r; print "char ${a}[] =\n" if !$d && !$g; print "#define $a \\\n" if $d && !$g; undef $r; } } if ((!/:/ && !$p) || (!/<$a.*>/ && $p)) { if ($y && $r) { $r =~ s/(.*)\\$/$1/ if $d && !$g; $r =~ s/(\t*"[^"]*")(.*)/$1;$2/ if !$d && !$g; print $r; } $y = 0; } if ($y) { print $r; s#$matchstr# $c = $1; $o = $3; $b = $2; $o =~ s/\s*(.*?)\s*/$1/; $b =~ s/([\da-f]{2})\s/\\x$1/g; $b = "\"$b\"" if $b; sprintf("\t%s%s\t/* %s %s%s\t*/%s", $b, "\t" x (3-int(leng +th($b)/8)), $c, $o, "\t" x (4-int((length($o.$c)+4)/8)), $d ? "\\" : +"");#e if !$g; $r = $_; } }
Can anyone comment on this?

Replies are listed 'Best First'.
Re: obj dump
by davorg (Chancellor) on Sep 24, 2001 at 14:21 UTC

    It's horrible :)


    "The first rule of Perl club is you don't talk about Perl club."

      can anyone elaborate?
        Its tough write an elaborate answer to such a minimal question. We don't even know what that code is supposed to do. Try framing the code with how you are using it, what the interesting parts are, what problems you're having with it, etc.

        Time spent asking a good question will be rewarded with meaningful answers. Read dominus's comments on how to ask a good question. After all, if you aren't willing to invest more than five words, why should we?


        OK. Did you really mean to use -s¹ in the shebang line, or did you mean -w? There are a lot of regular expressions in your program, but no comments and every single variable name is composed of a single character. It looks like it fell out of a 1970s Fortran/Basic timewarp. The indenting is reasonable. Marks out of 10: 3 (provisional, based on the assumption that you meant to run with warnings enabled).

        ¹From the Perl 5 Pocket Reference:

        -s   Interprets -xxx on the command line as a switch and sets the corresponding variable $xxx in the script to 1. If the switch is of the form -xxx=yyy the $xxx variable is set to yyy.
Re: obj dump
by davorg (Chancellor) on Sep 24, 2001 at 18:04 UTC

    OK, in order to even attempt a sensible answer to the question, we'll need more information.

    1. Given the presence of the -s we'll need to know the command line that you use to run the script so we can know valid values for $matchstr, $g, $r and $y.
    2. The script seems to closely tied to the syntax of the input file, so it would be helpful to see some sample data.

    Is that more helpful?

    p.s. I still think it's a horrible script :)


    "The first rule of Perl club is you don't talk about Perl club."

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://114272]
Approved by root
[Discipulus]: i propend for removing: why? because we are so few that we must find i minimal common divisor, this is certainly Perl not our (anyway private) thougths. And i say this still wondering because i love a lot freedom of expression. And i say this not for roho
[1nickt]: Discipulus that was the point of my story of taking the sticker off my truck. I know there are lots of people in the world who if I knw their private beliefs I might want to argue with them. And they with me. But life cannot all be arguments!
[1nickt]: This is less than perfect ... but demanding perfection (from people or from life) is a sure way to unhappiness.
[Discipulus]: and anyway we have CB where every (democratic) opinion can be expressed
erix eat the rich!
[1nickt]: I do think it is sad that roho has received 3 downvotes for his polite request, as did I when I objected to the profanity in stonecolddevin's sig. I upvoted both him and Karl for the discussion. Way too much downvoting for inappropriate reasons here!
Discipulus learn that 'argue' has a little negative sense, he thought was a neutral sense, 'vox media'
[1nickt]: argue == discuss && argue == be contentious
[Discipulus]: you are right 1nickt i didnt voted nor downvoted; I just upvote perl content i like
[1nickt]: In Spanish, to argue (like a fight) is discutir -- does not mean to discuss !

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2017-06-22 12:18 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (519 votes). Check out past polls.