Dup Goto 📝

Which1

PT2/lang/perl/toy-examples 07-31 13:46:47
To Pop
16 lines, 37 words, 218 chars Monday 2023-07-31 13:46:47

A simple which clone:

#!/usr/bin/env perl

$target = $ARGV[0];
$path = $ENV{PATH};
@path = split ":", $path;
for(@path) {
  $b = "$_/$target";
  if( -x "$b" ) {
    print "$b\n";
    exit 0;
  }
}
exit 1;