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
In reply to Re: Running a module?
by abell
in thread Running a module?
by bschmer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |