Attack animation help

Hey I have been asking alot of questions lately and I have another I am currently working on my third person platformer and I am wanting to make my charachter play an animation of him punching. I have gotten him to play the animation when I hold down my mouse button but I want it to play once instead of looping and I want it to play when I click not when I hold it down. Can anyone point me in the right direction on how to do this. What I have so far is:

`function Update()
{
    if (Input.GetMouseButton(0))
`    animation.Play("punch");
}

So I really need help. I am using java but am open to c sharp if its the only thing that can do it. All help will be apreciated.

Here what I am using in my game:

I found it somewhere:

function Start ()
{
   // Set all animations to loop
   animation.wrapMode = WrapMode.Loop;
   // except shooting
   animation["shoot"].wrapMode = WrapMode.Once;

   // Put idle and walk into lower layers (The default layer is always 0)
   // This will do two things
   // - Since shoot and idle/walk are in different layers they will not affect
   //   each other's playback when calling CrossFade.
   // - Since shoot is in a higher layer, the animation will replace idle/walk
   //   animations when faded in.
   animation["shoot"].layer = 1;

   // Stop animations that are already playing
   //(In case user forgot to disable play automatically)
   animation.Stop();
}

function Update () {
   // Based on the key that is pressed,
   // play the walk animation or the idle animation
   if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1){
      animation.CrossFade("walk");
      }

       else if (Mathf.Abs(Input.GetAxis("Horizontal")) > 0.1){
      animation.CrossFade("walk");
      }

   else
      animation.CrossFade("idle");

   // Shoot
   if (Input.GetButtonDown ("Jump"))
   // animation.CrossFade("walk");
      animation.Play("jumping");
} 

For your request to play something once: pay attention to the line below

animation["shoot"].wrapMode = WrapMode.Once;

I hope this helps and thanks to the original writer of the script NOT me