perl: run another script without exec/system

Is it possible to include/source another perl script, or launch it as a "sub"? This works, but looks ugly:

print "I'm in; args: @ARGV\n";


use File::Temp qw/tempdir/;
use File::Copy qw/copy/;

my $tmplib;

use lib ($tmplib = tempdir()) . (
  copy("./", "$tmplib/") ? "" : (die "$!")

use test2;


$ ./ a b c
I'm in; args: a b c


It sounds like you want the do operator, although it also sounds like very bad design.

This is what the documentation says.

do EXPR Uses the value of EXPR as a filename and executes the contents
        of the file as a Perl script.
            do '';

        is just like

            eval `cat`;

Need Your Help

Determine dates of DST switch (both forwards and backwards) for a timezone in Java?

java datetime date dst

I realize that you can check if a Date is inDaylightTime, but how can I determine when (or if) that Date switches to and from DST? I can iterate over every day and check if it's inDaylightTime, but...

Replace character in all database fields

sql-server quotes double-quotes

We received an MSSQL database with many tables and fields which we need to clean. One of the things we need to do is remove all quotes (chr(34) and chr(39)) from any text fields.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.