From 4b9b8c28fd4ec118468503da3017ec0085d4177b Mon Sep 17 00:00:00 2001 From: Paul Cochrane Date: Mon, 18 May 2015 21:48:11 +0200 Subject: [PATCH] Use $*SPEC.catdir for platform independent path names --- categories/euler/prob022-grondilu.pl | 2 +- categories/euler/prob047-gerdr.pl | 2 +- categories/euler/prob054-andreoss.pl | 2 +- categories/euler/prob059-andreoss.pl | 2 +- categories/euler/prob067-felher.pl | 2 +- categories/euler/prob081-moritz.pl | 2 +- categories/rosalind/dbpr-grondilu.pl | 3 +-- categories/rosalind/lcsq-grondilu.pl | 2 +- categories/rosalind/mprt-grondilu.pl | 2 +- categories/rosalind/sgra-grondilu.pl | 6 ++++-- categories/shootout/k-nucleotide.p6 | 2 +- categories/shootout/regex-dna.p6 | 2 +- categories/shootout/revcomp-v2.p6 | 2 +- categories/shootout/revcomp.p6 | 2 +- categories/wsg/advanced-2008/event001-eric256.pl | 2 +- categories/wsg/advanced-2008/event002-eric256.pl | 2 +- categories/wsg/advanced-2008/event005-eric256.pl | 2 +- categories/wsg/beginner-2008/event003-unobe.pl | 2 +- categories/wsg/beginner-2008/event006-eric256.pl | 2 +- categories/wsg/beginner-2008/event006-j1n3l0.pl | 2 +- 20 files changed, 23 insertions(+), 22 deletions(-) diff --git a/categories/euler/prob022-grondilu.pl b/categories/euler/prob022-grondilu.pl index 0f1e34b..537e2f2 100644 --- a/categories/euler/prob022-grondilu.pl +++ b/categories/euler/prob022-grondilu.pl @@ -25,7 +25,7 @@ my $i = 1; constant A = 'A'.ord - 1; -my $names-file = $*PROGRAM_NAME.IO.dirname ~ "/names.txt"; +my $names-file = $*SPEC.catdir($*PROGRAM_NAME.IO.dirname, "names.txt"); my $data = slurp $names-file; my @names = sort $data.subst('"', '', :g).split(','); say [+] gather diff --git a/categories/euler/prob047-gerdr.pl b/categories/euler/prob047-gerdr.pl index 715b659..7d0acf0 100644 --- a/categories/euler/prob047-gerdr.pl +++ b/categories/euler/prob047-gerdr.pl @@ -42,7 +42,7 @@ use NativeCall; -sub factors(int $n) returns int is native($*PROGRAM_NAME.IO.dirname ~ '/prob047-gerdr') { * } +sub factors(int $n) returns int is native($*SPEC.catdir($*PROGRAM_NAME.IO.dirname, 'prob047-gerdr')) { * } sub MAIN(Int $N = 4) { my int $n = 2; diff --git a/categories/euler/prob054-andreoss.pl b/categories/euler/prob054-andreoss.pl index d52b464..8ddba01 100644 --- a/categories/euler/prob054-andreoss.pl +++ b/categories/euler/prob054-andreoss.pl @@ -228,7 +228,7 @@ sub MAIN(Bool :$verbose = False, Bool :$run-tests = False, - :$file = $*PROGRAM_NAME.IO.dirname ~ '/poker.txt', + :$file = $*SPEC.catdir($*PROGRAM_NAME.IO.dirname, 'poker.txt'), :$lines = Inf, # read only X lines from file ) { die "'$file' is missing" unless $file.IO.e ; diff --git a/categories/euler/prob059-andreoss.pl b/categories/euler/prob059-andreoss.pl index c457707..5372e06 100644 --- a/categories/euler/prob059-andreoss.pl +++ b/categories/euler/prob059-andreoss.pl @@ -86,7 +86,7 @@ sub infix:(@cipher, @password) { } sub MAIN(Bool :$verbose = False, - :$file = $*PROGRAM_NAME.IO.dirname ~ '/cipher.txt', + :$file = $*SPEC.catdir($*PROGRAM_NAME.IO.dirname, 'cipher.txt'), :$word = @common-words[0], :$pass is copy) { die "'$file' is missing" unless $file.IO.e ; diff --git a/categories/euler/prob067-felher.pl b/categories/euler/prob067-felher.pl index 1f4fc36..93d080d 100644 --- a/categories/euler/prob067-felher.pl +++ b/categories/euler/prob067-felher.pl @@ -34,7 +34,7 @@ =end pod -my $triangle = slurp($*PROGRAM_NAME.IO.dirname ~ '/triangle.txt'); +my $triangle = slurp($*SPEC.catdir($*PROGRAM_NAME.IO.dirname, '/triangle.txt')); my @lines = string-to-array($triangle).reverse; # reduce the triangle by adding up the lines until only one line with one diff --git a/categories/euler/prob081-moritz.pl b/categories/euler/prob081-moritz.pl index 3cf61da..20468ef 100644 --- a/categories/euler/prob081-moritz.pl +++ b/categories/euler/prob081-moritz.pl @@ -29,7 +29,7 @@ my @m; -my $matrix-file = $*PROGRAM_NAME.IO.dirname ~ '/matrix.txt'; +my $matrix-file = $*SPEC.catdir($*PROGRAM_NAME.IO.dirname, 'matrix.txt'); my $f = open $matrix-file or die "Can't open file for reading: $!"; for $f.lines { @m.push: [ .comb(/\d+/) ]; diff --git a/categories/rosalind/dbpr-grondilu.pl b/categories/rosalind/dbpr-grondilu.pl index 82f70b1..d183958 100644 --- a/categories/rosalind/dbpr-grondilu.pl +++ b/categories/rosalind/dbpr-grondilu.pl @@ -23,8 +23,7 @@ use LWP::Simple; sub MAIN(Str $id = "Q5SLP9") { - my $base-path = $*PROGRAM_NAME.IO.dirname; - my $id-fname = $base-path ~ "/$id.txt"; + my $id-fname = $*SPEC.catdir($*PROGRAM_NAME.IO.dirname, "$id.txt"); my $input = $id-fname.IO.e ?? $id-fname.IO.slurp !! LWP::Simple.get(qq{http://www.uniprot.org/uniprot/$id.txt}); diff --git a/categories/rosalind/lcsq-grondilu.pl b/categories/rosalind/lcsq-grondilu.pl index c11f6a7..f582f14 100644 --- a/categories/rosalind/lcsq-grondilu.pl +++ b/categories/rosalind/lcsq-grondilu.pl @@ -29,7 +29,7 @@ use NativeCall; -sub lcsq(Str $, Str $ --> Str) is native($*PROGRAM_NAME.IO.dirname ~ '/lcsq') {*} +sub lcsq(Str $, Str $ --> Str) is native($*SPEC.catdir($*PROGRAM_NAME.IO.dirname, 'lcsq')) {*} my $default-input = q:to/END/; >Rosalind_23 diff --git a/categories/rosalind/mprt-grondilu.pl b/categories/rosalind/mprt-grondilu.pl index 5bd1f86..dee9e45 100644 --- a/categories/rosalind/mprt-grondilu.pl +++ b/categories/rosalind/mprt-grondilu.pl @@ -38,7 +38,7 @@ ($input-file = Nil) my $N-glycosylation = rx / N <-[P]> <[ST]> <-[P]> /; my $base-path = $*PROGRAM_NAME.IO.dirname; for @input -> $id { - my $fasta-name = $base-path ~ "/$id.fasta"; + my $fasta-name = $*SPEC.catdir($base-path, "$id.fasta"); my $fasta = $fasta-name.IO.e ?? $fasta-name.IO.slurp !! qqx{wget -O - -q "http://www.uniprot.org/uniprot/$id.fasta"}; diff --git a/categories/rosalind/sgra-grondilu.pl b/categories/rosalind/sgra-grondilu.pl index d7b93ee..9a03c01 100644 --- a/categories/rosalind/sgra-grondilu.pl +++ b/categories/rosalind/sgra-grondilu.pl @@ -40,8 +40,10 @@ sub MAIN($input-file = Nil) { my $input = $input-file ?? $input-file.IO.slurp !! $default-input; - my $mass-table-path = $*PROGRAM_NAME.IO.dirname; - my %mass-table = slurp($mass-table-path ~ "/monoisotopic-mass-table.txt").words; + + my $mass-table-file = $*SPEC.catdir($*PROGRAM_NAME.IO.dirname, + "monoisotopic-mass-table.txt"); + my %mass-table = slurp($mass-table-file).words; my @L = sort $input.lines; my %invert-mass-table = %mass-table.invert.hash; diff --git a/categories/shootout/k-nucleotide.p6 b/categories/shootout/k-nucleotide.p6 index d3edd5b..8d00a4e 100644 --- a/categories/shootout/k-nucleotide.p6 +++ b/categories/shootout/k-nucleotide.p6 @@ -44,7 +44,7 @@ Expected output =end pod -sub MAIN($input-file = $*PROGRAM_NAME.IO.dirname ~ "/k-nucleotide.input") { +sub MAIN($input-file = $*SPEC.catdir($*PROGRAM_NAME.IO.dirname, "k-nucleotide.input")) { my $fh = open $input-file.IO; # Read FASTA file and extract DNA sequence THREE. diff --git a/categories/shootout/regex-dna.p6 b/categories/shootout/regex-dna.p6 index 7f7ffa5..faf5dc8 100644 --- a/categories/shootout/regex-dna.p6 +++ b/categories/shootout/regex-dna.p6 @@ -30,7 +30,7 @@ Expected output =end pod -sub MAIN($input-file = $*PROGRAM_NAME.IO.dirname ~ "/regex-dna.input") { +sub MAIN($input-file = $*SPEC.catdir($*PROGRAM_NAME.IO.dirname, "regex-dna.input")) { my $input = $input-file.IO.slurp; my $data = $input.lines.grep({ $_ !~~ /^ \>/}).join.lc; diff --git a/categories/shootout/revcomp-v2.p6 b/categories/shootout/revcomp-v2.p6 index 87b79b7..649a10e 100644 --- a/categories/shootout/revcomp-v2.p6 +++ b/categories/shootout/revcomp-v2.p6 @@ -187,7 +187,7 @@ Expected output my %trans = 'wsatugcyrkmbdhvnATUGCYRKMBDHVN'.comb Z=> 'WSTAACGRYMKVHDBNTAACGRYMKVHDBN'.comb; -sub MAIN($input-file = $*PROGRAM_NAME.IO.dirname ~ "/revcomp.input") { +sub MAIN($input-file = $*SPEC.catdir($*PROGRAM_NAME.IO.dirname, "revcomp.input")) { my ($desc, @seq); for $input-file.IO.lines { diff --git a/categories/shootout/revcomp.p6 b/categories/shootout/revcomp.p6 index 61b9954..04d46c1 100644 --- a/categories/shootout/revcomp.p6 +++ b/categories/shootout/revcomp.p6 @@ -188,7 +188,7 @@ Expected output =end pod -sub MAIN($input-file = $*PROGRAM_NAME.IO.dirname ~ "/revcomp.input") { +sub MAIN($input-file = $*SPEC.catdir($*PROGRAM_NAME.IO.dirname, "revcomp.input")) { my ($desc,$seq) = ('',''); my $input = open $input-file; while $input.get -> $line { diff --git a/categories/wsg/advanced-2008/event001-eric256.pl b/categories/wsg/advanced-2008/event001-eric256.pl index eab01d1..c7073dc 100644 --- a/categories/wsg/advanced-2008/event001-eric256.pl +++ b/categories/wsg/advanced-2008/event001-eric256.pl @@ -113,7 +113,7 @@ =end pod sub MAIN(Bool :$verbose = False) { - my $input-file = $*PROGRAM_NAME.IO.dirname ~ "/wordlist.txt"; + my $input-file = $*SPEC.catdir($*PROGRAM_NAME.IO.dirname, "wordlist.txt"); my %dict = ( ($input-file.IO.slurp.split("\n").grep: {.chars == 7}) X 1); my %digits = ( diff --git a/categories/wsg/advanced-2008/event002-eric256.pl b/categories/wsg/advanced-2008/event002-eric256.pl index a9de243..55eab49 100644 --- a/categories/wsg/advanced-2008/event002-eric256.pl +++ b/categories/wsg/advanced-2008/event002-eric256.pl @@ -65,7 +65,7 @@ =end pod -my $input-file = $*PROGRAM_NAME.IO.dirname ~ "/skaters.txt"; +my $input-file = $*SPEC.catdir($*PROGRAM_NAME.IO.dirname, "skaters.txt"); my @lines = slurp($input-file).split("\n"); my %skaters ; diff --git a/categories/wsg/advanced-2008/event005-eric256.pl b/categories/wsg/advanced-2008/event005-eric256.pl index 8b620fc..f046d1b 100644 --- a/categories/wsg/advanced-2008/event005-eric256.pl +++ b/categories/wsg/advanced-2008/event005-eric256.pl @@ -148,7 +148,7 @@ sub MAIN(Str :$pw = "", Bool :$verbose = False) { my $password = $pw || prompt("Enter password to test: "); - my $input-file = $*PROGRAM_NAME.IO.dirname ~ "/wordlist.txt"; + my $input-file = $*SPEC.catdir($*PROGRAM_NAME.IO.dirname, "wordlist.txt"); my %dict = ( ($input-file.IO.slurp.split("\n").grep: {.chars > 6}) X 1); say "Testing strength of password '$password'" if $verbose; diff --git a/categories/wsg/beginner-2008/event003-unobe.pl b/categories/wsg/beginner-2008/event003-unobe.pl index 06f23d4..2528657 100644 --- a/categories/wsg/beginner-2008/event003-unobe.pl +++ b/categories/wsg/beginner-2008/event003-unobe.pl @@ -37,7 +37,7 @@ my $run-dir = $*PROGRAM_NAME.IO.dirname; my @files = dir($run-dir).sort; -my $output = $run-dir ~ '/newfile.txt'; +my $output = $*SPEC.catdir($run-dir, 'newfile.txt'); $output.IO.unlink if $output.IO.e; # only select .txt files required for this event diff --git a/categories/wsg/beginner-2008/event006-eric256.pl b/categories/wsg/beginner-2008/event006-eric256.pl index 1a42202..7d63a6d 100644 --- a/categories/wsg/beginner-2008/event006-eric256.pl +++ b/categories/wsg/beginner-2008/event006-eric256.pl @@ -46,7 +46,7 @@ =end pod -my $coffee-list = $*PROGRAM_NAME.IO.dirname ~ '/coffee.txt'; +my $coffee-list = $*SPEC.catdir($*PROGRAM_NAME.IO.dirname, 'coffee.txt'); my $lines = slurp($coffee-list).chomp; my %order; for $lines.split(/\n/) { diff --git a/categories/wsg/beginner-2008/event006-j1n3l0.pl b/categories/wsg/beginner-2008/event006-j1n3l0.pl index d4312bd..304eedb 100644 --- a/categories/wsg/beginner-2008/event006-j1n3l0.pl +++ b/categories/wsg/beginner-2008/event006-j1n3l0.pl @@ -48,7 +48,7 @@ our %count_for; -sub MAIN(Str $orders = $*PROGRAM_NAME.IO.dirname ~ '/coffee.txt') { +sub MAIN(Str $orders = $*SPEC.catdir($*PROGRAM_NAME.IO.dirname, 'coffee.txt')) { # get the data my @contents = $orders.IO.lines;