I think davido said it all in Re: declaration of variables, but he failed to comment on the last possibility that you mentioned.
m ($var) = "";
I have no idea where you got that from. The simplest explanation would be that it is a typo and that you in fact meant:
my ($var) = "";
If that is what you meant, read no further.















You're reading further. Ok, what you wrote almost has meaning. But should probably only be used in obfuscations, never in real code.
m ($var) = "";
is basically equivalent with:
$_ =~ m/$var/ = "";
which of course is an error, namely:
Can't modify pattern match (m//) in scalar assignment
But had your example shown just:
m ($var);
that code would have compiled to:
$_ =~ m/$var/;
if you don't use use strict; (which you don't in your example). A scary thought.

Therefore, once again, always use strict; (and use warnings; if you're using Perl 5.6.0 or later).

Liz

Update:
Made a little clearer with what I meant with "It".


In reply to Re: declaration of variables by liz
in thread declaration of variables by Murcia

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.