awk: getline NOM < "-" script does not stop

Well , i have:

$ cat example.dat
1
2
3
4
5
$ cat getline3.awk 
function getName (NOM)
{
printf "Enter a filename: "
getline NOM < "-" # get response
return NOM
}

BEGIN {
printf ("\nREP: %s\n",getName(N)) 
} 
{print}

This example works fine:

$ awk -f getline3.awk example.dat
Enter a filename: EXAMPLE

REP: EXAMPLE
1
2
3
4
5

But this one fails because the script does not stop to get the filename (it took the first line of the example.dat file)

$ awk -f getline3.awk <example.dat
Enter a filename: 
REP: 1
2
3
4
5

Any ideas to solve the problem??

Thx in advance

Try this :

function getName (  NOM)
{
   printf "Enter a filename: "
   "head -1 < /dev/tty" | getline NOM
   close("head -1 </dev/tty");
   return NOM
}

BEGIN {
printf ("\nREP: %s\n",getName()) 
} 
{print}

Hey , you drove me to it (i did a minor modification)

Final code:
function getName (NOM)
{
printf "Enter a filename: "
getline NOM < "/dev/tty"
close("/dev/tty")
return NOM
}

BEGIN {
printf ("\nREP: %s\n",getName(N))
}
{print}

Thx dude