cch has asked for the wisdom of the Perl Monks concerning the following question:

how does perl treat "=" in argument? when I pass "v=33" as argument "=" disappears.

Replies are listed 'Best First'.
Re: how is = treated in argument?
by stevieb (Canon) on Nov 26, 2014 at 18:57 UTC

    You need to give an actual example of what you're trying to do, that can reproduce the result you're seeing.

    For example, when you say "pass", are you referring to passing that string as an argument to a subroutine, are you trying to assign 33 to v? We need more info.

    -Steve
Re: how is = treated in argument?
by AnomalousMonk (Archbishop) on Nov 26, 2014 at 18:57 UTC

    Just how are you 'passing'  "v=33" as an argument? To what are you passing it? Can you show an example of  "=" disappearing? Otherwise, an expression like  $v = 33 behaves as expected: an assignment to a variable, which yields the value of the assignment.

    c:\@Work\Perl>perl -wMstrict -le "sub S { print qq{S got $_[0]}; } ;; my $v = 0; print qq{\$v starts as $v}; ;; S($v = 33); print qq{\$v now $v}; " $v starts as 0 S got 33 $v now 33

Re: how is = treated in argument?
by ww (Archbishop) on Nov 26, 2014 at 19:51 UTC

    Could this be a quoting problem? What OS?, etc, as above

    You need to provide better specs on your problem or you'll be fortunate to get anything more helpful than wild guesses ( except, of course, advice to be more specific :-) )...
    like this:

    C:\>perl -E "my $foo = 'v=8'; say $foo;" v=8

    So, drink your veggies and be concisely comprehensive: that is, provide code and warning or error messages, if any, and explain what you're trying to do.


    ++$anecdote ne $data


Re: how is = treated in argument?
by Anonymous Monk on Nov 26, 2014 at 18:50 UTC

    how does perl treat "=" in argument? when I pass "v=33" as argument "=" disappears.

    What does that mean?

    $ perl -e " use Data::Dump; dd( \@ARGV ); " on=om at=op ei=a ["on=om", "at=op", "ei=a"]
Re: how is = treated in argument?
by karlgoethebier (Abbot) on Nov 26, 2014 at 21:10 UTC

    In the advice you've already been given a major issue was to figure out what you really want to do.

    I guess. Perhaps you want actually something like this?

    Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

Re: how is = treated in argument?
by Laurent_R (Canon) on Nov 26, 2014 at 19:58 UTC
    Argument to what? To a function ? To a Perl operator? To your script? To something else? Sorry, I don't understand your question. Please explain, be more specific, show in which context the '=' character disappear.
Re: how is = treated in argument?
by karlgoethebier (Abbot) on Nov 27, 2014 at 09:56 UTC

    Just some more general thoughts about your slightly vague question:

    You got six replies:

    1. "What does that mean?" (Anonymous Monk)
    2. "You need to give an actual example..." (stevieb)
    3. "Just how are you 'passing' "v=33" as an argument?..." (AnomalousMonk)
    4. "Could this be a quoting problem?" (ww)
    5. "Argument to what?... " (Laurent_R)
    6. "...you want actually something like this?..." (karlgoethebier)

    It is considered as good practice in such a case to give some feedback, like answering the questions, updating your OP with a more precise question etc.

    Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»