Skip to content

Instantly share code, notes, and snippets.

@tene
Created July 21, 2010 20:46
Show Gist options
  • Select an option

  • Save tene/485105 to your computer and use it in GitHub Desktop.

Select an option

Save tene/485105 to your computer and use it in GitHub Desktop.
multi sub do-stuff(Str $fn where { $fn.IO ~~ :f }) {
say "file: $fn";
}
multi sub do-stuff(Str $fn where { $fn.IO ~~ :d }) {
say "dir: $fn";
}
multi sub do-stuff(Str $fn where { $fn.IO !~~ :e }) {
say "No such file: $fn";
}
sub MAIN(Str $filename) {
do-stuff($filename);
}
[sweeks@sweeks-laptop ~]$ perl6 /tmp/sig.pl
Usage:
/tmp/sig.pl filename
[sweeks@sweeks-laptop ~]$ perl6 /tmp/sig.pl /etc/passwd
file: /etc/passwd
[sweeks@sweeks-laptop ~]$ perl6 /tmp/sig.pl /tmp
dir: /tmp
[sweeks@sweeks-laptop ~]$ perl6 /tmp/sig.pl /xlsqbq
No such file: /xlsqbq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment