>   I am quite puzzled with the usage of the word "only".
>   There are several sentences with the word "only".
>
>           Only I saw Mary in this room.
>           I only saw Mary in this room.
>           I saw only Mary in this room.
>           I saw Mary only in this room.
>           I saw Mary in this room only.
>
>   Can anyone tell me the difference of the above sentences?

"Only" is another of those floating quantifiers.  It doesn't
have just one place in the sentence; therefore, in writing,
particularly when one hasn't heard the language all one's life,
it's hard to figure out just where it ought to go.  In speech,
though, people float it all over the place with no ill consequences.

The reason is that the rule that governs its interpretation depends
on the conventions of spoken (i.e, real) language rather than the 
technological ones of written language.

Here's what David Crystal says about 'only' in this context in
The Cambridge Encyclopedia of the English Language (1995:194):

"It is wise to be careful in writing, where ambiguity can arise;
 but spoken usage is hardly ever ambiguous, because 'only' is
 always linked with the next word that carries a strong stress.
 Note the difference between 

     I only saw JANE (and no one else)
 and
     I only SAW Jane (I didn't talk to her)"

In writing, a safe rule would be to use it immediately before
the phrase you wish to modify with it.  That would give you

     I saw only Jane

for a different way to represent unambiguously the 1st of Crystal's
examples.  However, if you *do* want to use it in writing as a verb
phrase modifier, like the 2nd of Crystal's examples, you'll just have
to run the risk of being ambiguous, because a lot of people will
interpret the written sentence

     I only saw Jane.

(without qualification) as sounding like the 1st rather than
the 2nd example.  That's why people add disambiguating
qualifiers, as he did in showing what his examples meant.
If he hadn't capitalized the stressed words, we'd still
have understood what they meant from the qualifications.

That's an example of the way writing adopts and adapts its
own conventions to make up for the fact that most of the
information in the speech channel (intonation, facial expression,
gestures, eye dance, rhythm, et cetera) can't really be
carried in the very narrow written bandwidth.

So, as for your original question, the differences among (not "of")
the sentences above (not "the above sentences", which is only for
legal documents) depend on how you would pronounce them, if you're
writing, and on how your reader imagines you might have intended to
pronounce them.  Anything you can do, like punctuation, syntactic
recasting, qualifiers, etc. that serves to make this clear (much in
the same way a raised eyebrow disambiguates spoken intentions
sometimes) will have the effect of lessening the effort your readers
have to put in, and therefore making this newfangled "literacy"
technology work a lot better.

Yours for technological advancement,

  --------------------------------------------
 -John Lawler                     More grammar
  Linguistics Program   University of Michigan
 "..and, who knows? Maybe the horse will sing."