Rosetta Code/Run examples: Difference between revisions
→{{header|Perl 6}}: bug fixes and updates
Thundergnat (talk | contribs) (→{{header|Perl 6}}: More switches & updates, roughed in multi-language code, will now run Perl & Python as well as Perl6) |
Thundergnat (talk | contribs) (→{{header|Perl 6}}: bug fixes and updates) |
||
Line 286:
unit sub MAIN(
Str $run = '', # Task or file name
Str :$lang = 'perl6', # Language, default perl6 - should be same as in
Int :$skip = 0, # Skip # to continue partially into a list
Bool :f(:$force), # Override any task
Bool :l(:$local), # Only use
Bool :r(:$remote), # Only use code from remote server (refresh local cache)
Bool :q(:$quiet), # Less verbose, don't display source code
Bool :d(:$deps), # Load dependencies
Bool :p(:$pause), # pause after each task
Bool :b(:$broken), # pause after each task marked broken
);
Line 310 ⟶ 311:
my $view = 'xdg-open'; # image viewer, this will open default under Linux
my %l = load-lang($lang); # load languge
my %resource = load-resources($lang);
my $get-tasks = True;
Line 317 ⟶ 318:
run('clear');
note 'Retrieving tasks';▼
if $run {
Line 325 ⟶ 326:
@tasks = ($run); # treat it so
}
$get-tasks = False; # don't need to
}
if $get-tasks { # load tasks from web if
if !"%l<
@tasks = mediawiki-query( # get tasks from web
$url, 'pages',
Line 338 ⟶ 340:
:prop<title>
)»<title>.grep( * !~~ /^'Category:'/ ).sort;
"%l<
} else {
note 'Using cached task list.';
@tasks = "%l<
}
}
Line 354 ⟶ 357:
my $taskdir = "./rc/%l<dir>/$name";
my $modified = "$taskdir/$name.txt".IO.e ?? "$taskdir/$name.txt".IO.modified !! 0;
my $entry;
if $remote or !"$taskdir/$name.txt".IO.e or (($modified - now) > 86400 * 7) {
my $page = $client.get("{ $url }/index.php?title={ uri-escape $title }&action=raw").content;
Line 397 ⟶ 400:
if %resource{"$name$n"}<skip> ~~ /'broken'/ {
uh-oh(%resource{"$name$n"}<skip>);
pause if $broken;
} else {
say "Skipping $name$n: ", %resource{"$name$n"}<skip>, "\n";
}
next;
Line 407 ⟶ 411:
say %c<delim>, '=' x 79, %c<clr>;
pause if $pause;
}
Line 440 ⟶ 445:
sub pause {
prompt "Press enter to procede:
# or
# sleep 5;
|