in reply to Re^2: Command line question
in thread Command line question

Ordinarily, I'd agree with you, but I get the impression that the OP's code works as-is, and he's just trying to figure out what it does and how. My guess is that the whole thing is in double quotes, and what perl actually sees is:

BEGIN { $^I = ""; } LINE: while (defined($_ = <ARGV>)) { s[value-of-SOURCE/value-of-SAMS/][]g; s[value-of-SOURCE/value-of-SAMLIB/][]g; s[value-of-SOURCE/value-of-SMCLIB/][value-of-SOURCE/value-of-KENO/ +]g; if (not m[^value-of-SOURCE/]) { s[value-of-SOURCE/][$${OBJECT}/]g; print $_; } }

That $${OBJECT} in there still seems wrong, though, and the OP is ambiguous about whether this is working code or not, so I'm pretty far from sure about this.

Replies are listed 'Best First'.
Re^4: Command line question
by igotlongestname (Acolyte) on Jun 19, 2008 at 17:31 UTC
    Yeah, you're dead on. This line is from a Makefile from an old code. This line has been stumping us a bit, and I'm the only one that knows Perl (and I don't know it that well), so I got lost trying to search this through as so many of the delimiters were odd to me (the s+ and ++g etc...).

    So this is working code that does what it's supposed to, but I'm having trouble totally seeing what it does. I'd like to actually get the .depend file before the Perl script, then again after it to compare ... it may shed some light for me.

    So what you're thinking is that each instance of ${something} is actually some value, stored in ${something} being passed in to the Perl script? Is that roughly correct?

    Finally, could the $${OBJECT} be right? Could it be substituting the value of ${OBJECT}, with a preceding "$" sign into the code, to be read and interpreted by the shell?

    I may be way off and talking over my head too, if it doesn't make sense, don't try to make it as it's probably wrong.

    Thanks!

    ~Jack

      I'd like to actually get the .depend file before the Perl script, then again after it to compare

      No problem! Change "perl -ni -e" to "perl -ni.bak -e", and you'll find a ".depend.bak" file that has its contents before perl got a hold of it. If there's already a .bak file being produced, you can use "perl -ni.before.tha.mangalang -e" or whatever.

      So what you're thinking is that each instance of ${something} is actually some value, stored in ${something} being passed in to the Perl script? Is that roughly correct?

      That's roughly correct, yes. Perl actually never sees them as variables. The interpolation is done by the shell (or make) before Perl comes into it. From its point of view, they're literal strings.

      Finally, could the $${OBJECT} be right?

      I don't think so. If that's really what perl sees, it's going to come out as an empty string because within the context of the Perl that's running, there is no $OBJECT variable with a value. I think that it's actually coming out as "\${OBJECT}", and winds up in the .depend file that way. This is one part of this whole thing I'm really not sure about, so take my words with salt, please.