This post is somewhat long, so I would like to start
by saying that this is very much relevant to PerlMonks
even though it is not about Perl or programming. It
is also very relevant to CPAN, perl, and the broader
open source community. This is about aspects of being
an employee which generally get ignored, and really,
really, really shouldn't be.

I will talk about New York State's laws, since that is
what I know best. However in discussions with legal
types it appears that New York's provisions are not
unusual, and therefore what I say is applicable in some
way to most of the US, and likely in many other countries
as well. I should also disclaim at this point that I am
not a lawyer, nor is this legal advice. But
the general outline of what I am saying has been verified
to me by both lawyers, and people who are merely
interested in the legal profession. I have also been
told that this is bound to become a huge issue for the
open source world.

Enough advertising.

In New York State there are three basic classes of
employee:

Hourly employee: If you show
up at work, punch a clock, and are paid overtime, then
you are an hourly employee. Factory workers are commonly
hourly employees. As an hourly employee the company owns
the hours you are at work, and has no other claim on you.
I believe it is uncommon for programmers to be hourly
employees.

Contract worker: In this case you are working
per defined contracts. The work you do on that contract
is (barring specific contract provisions saying otherwise)
owned by the company that has hired you. They have no
claim on your time or energy when you are not working on
the contract. Many programmers work this way. But if you
are (for instance) hired by a consulting company to work at
clients, then your employment with that consulting company
is not contract work, see the next option.

Professional employee: This is the rest of us.
Professional employees have employment that is not defined
by a clock or by a contract. In fact under the law their
productive output belongs to their employer, 24x7, 365 days
a year (366 on leap years). It is customary for these terms
to also be spelled out in employment contracts very clearly,
though truth be told most people read these, sign them, and
have never given the contents of those contracts much in the
way of thought.

This brings me to intellectual property law. Intellectual
property law in general assigns the rights to intellectual
property to the creator of an idea, work, or implementation.
That creator gains delimited control of their creation. In
theory the reason for this is to encourage potential
creators to create new things, and for them to pass into
the public domain. Or at least this was the reasoning that
Thomas Jefferson used (and he got it from French thought on
copyrights), though the reality in this century has not
matched theory very well.

But who is the creator?

One would think that the creator of a work is the author,
the person who actually produces it. But the realities of
life are not so simple. What if one person conceives of an
idea, and then gets multiple people to implement it? Is it
owned by the implementers, or the person who thought it
possible and paid for it to be done?

The legal resolution is the doctrine of a work for hire.
A work for hire is a work that you produced for someone else,
and they own all rights to any potential intellectual property
that might arise from that work. (Including, obviously, both
copyrights and patents.)

Now what happens if you combine these two legal areas?

The answer is unambiguous both in theory and practice. All
work covered under your employment terms belongs to your
employer. In the case of professional employees, this is
everything. If you go home and write something on the
weekend, you do not own it. You might be unaware of this
issue and naively put a copyright notice on it, then
distribute it. That was your mistake.

Now let me make this personal.

I am a professional employee. I signed a routine employment
contract while I was still pretty much of a novice as both a
programmer and an employee. As is common, 6 months later I
had completely forgotten about the terms of the contract and
was blissfully unaware of the laws I live under.

My bad.

Over the course of this job I have slowly become more and
more involved in open source work. I write software for fun
and release it. I have put code into posts here, released
stuff on CPAN, and even contributed a core perl module. All
of which I thought I had the right to do, but as it turns
out none of which I did. There isn't even a legal issue to
contest, I simply didn't know better.

My very bad.

As of today here is the status. This came up from an
incidental issue about a month ago. I have been told that
if I wish to continue being employed, I cannot post code.
If I continue being employed, then I will be admonished for
the code I have released so far. If I leave my employment
then the decision about what happens with any and all of the
code of mine that people here have seen is not mine.
(Stupid comment removed.)

I live in NYC. It seems likely that my wife is going to have
no option about moving any significant distance for at least
a year. I am carefully considering my employment options. I
have a likely job prospect near Philadelphia which
would allow me to work on open source stuff. That is farther
than I want to commute, and the pay cut would be painful,
plus it does not resolve the other issues. I have not
seriously searched for any potential jobs which are closer.

Now my food for thought for everyone is this. How many more
people are in the same position I am, and are not aware of it?
How much open source software has been put out there by
authors who thought they owned rights that they do not? If
you are an employee, are you one of them?

These are, as I have just learned, extremely non-hypothetical
questions.

UPDATE
There is, considering the circumstances, only one choice for
me to make which is not abysmally moronic. Do not expect to
hear much from me in the future.