in reply to Running a module?
Whether you have been called as a script or included as a module can be checked by taking a look at caller.
A small example:
When called as perl mymodule.pm this outputs#!/usr/bin/perl package mymodule; use Data::Dumper; my @caller = caller; print Dumper ( @caller ); print "Execute this\n" unless caller; 1;
Execute thiswhile when called as perl -Mmymodule -e '' it outputs
$VAR1 = 'main'; $VAR2 = '-e'; $VAR3 = 0;Cheers
|
|---|