An import list describes which helpers a caller wants from a module.

import list An import list names the helpers that should be made available to the caller.

Import Lists

wanted
import_lists.pl
Replay: real traced execution (multi-file project)
use strict;
use warnings;

my $wanted = "trim";
my @imports = ("trim", "slug");
my $found = "no";

foreach my $name (@imports) {
    if ($name eq $wanted) {
        $found = "yes";
    }
}

print "wanted=$wanted\n";
print "found=$found\n";
use strict;
use warnings;

my $wanted = "slug";
my @imports = ("trim", "slug");
my $found = "no";

foreach my $name (@imports) {
    if ($name eq $wanted) {
        $found = "yes";
    }
}

print "wanted=$wanted\n";
print "found=$found\n";
use strict;
use warnings;

my $wanted = "escape";
my @imports = ("trim", "slug");
my $found = "no";

foreach my $name (@imports) {
    if ($name eq $wanted) {
        $found = "yes";
    }
}

print "wanted=$wanted\n";
print "found=$found\n";
  1. $wanted ← trim, @imports ← 2, $found ← no

    4my $wanted→ trim = "trim"; #@wanted="slug", "escape"5my @imports→ 2 = ("trim", "slug");6my $found→ no = "no";
  2. foreach my $name (@imports)

    pass 1 of 2
    8foreach my $nametrim (@imports2) {9    if ($name eq $wanted) {
  3. $found ← yes

    8foreach my $name (@imports) {9    if ($nametrim eq $wantedtrim) {10        $found→ yes = "yes";11    }
  4. foreach my $name (@imports)

    pass 2 of 2
    8foreach my $nameslug (@imports2) {9    if ($name eq $wanted) {
  5. print "wanted=$wanted ";

    14print "wanted=$wantedtrim\n";15print "found=$foundyes\n";
    outputwanted=trim
    found=yes
  1. $wanted ← slug, @imports ← 2, $found ← no

    4my $wanted→ slug = "slug";5my @imports→ 2 = ("trim", "slug");6my $found→ no = "no";
  2. foreach my $name (@imports)

    pass 1 of 2
    8foreach my $nametrim (@imports2) {9    if ($name eq $wanted) {
  3. foreach my $name (@imports)

    pass 2 of 2
    8foreach my $nameslug (@imports2) {9    if ($name eq $wanted) {
  4. $found ← yes

    8foreach my $name (@imports) {9    if ($nameslug eq $wantedslug) {10        $found→ yes = "yes";11    }
  5. print "wanted=$wanted ";

    14print "wanted=$wantedslug\n";15print "found=$foundyes\n";
    outputwanted=slug
    found=yes
  1. $wanted ← escape, @imports ← 2, $found ← no

    4my $wanted→ escape = "escape";5my @imports→ 2 = ("trim", "slug");6my $found→ no = "no";
  2. foreach my $name (@imports)

    pass 1 of 2
    8foreach my $nametrim (@imports2) {9    if ($name eq $wanted) {
  3. foreach my $name (@imports)

    pass 2 of 2
    8foreach my $nameslug (@imports2) {9    if ($name eq $wanted) {
  4. print "wanted=$wanted ";

    14print "wanted=$wantedescape\n";15print "found=$foundno\n";
    outputwanted=escape
    found=no