If your Perl module is in one of the @INC
list of directories then you can write
perl -Mfile_name -e 'mySubRoutine(myArgument)'
if it is elsewhere then you need to add the path, like
perl -M/full_file_path/file_name -e 'mySubRoutine(myArgument)'
and, as ysth
points out, if the module file has a package MyPackage
at the start then you may need to add that to your call, like
perl -M/full_file_path/file_name -e 'MyPackage::mySubRoutine(myArgument)'
however in that case the file should be called MyPackage.pm
and the actual command would look something like below (notice that there is no .pm
appended to filename when used with -M
argument.
perl -M/full_file_path/MyPackage -e 'MyPackage::mySubRoutine(myArgument)'