in reply to passing filename in subroutines

How can I pass filename to subroutine?

Either of your examples is potentially correct, though I suspect neigher is what you want.   my $filename = aa; will put a value into $filename if you've previously defined a suboutine "aa" that returns a value.   my $filename = <aa>; will read a line from a file that you've opened using the symbol "aa" to hold the file descriptor.

I suspect you want   my $filename = "foo"; In any case,   subroutine($filename); is the correct way to invoke a subroutine, passing whatever $filename holds as the single argument.