Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

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
[chacham]: i sent him a private message expressing my displeasure.
[1nickt]: chacham It was worse than 2-1 ! almost 4-1 !
[jdporter]: Dang. No good example of how to use IPC::Run's run() in its simplest mode?
[LanX]: him or her! ;)
[1nickt]: jdporter Maybe try IPC::Run3

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (15)
As of 2017-05-24 20:54 GMT
Find Nodes?
    Voting Booth?