Skip to content

Commit

Permalink
Use $*SPEC.catdir for platform independent path names
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Cochrane committed May 18, 2015
1 parent c71e660 commit 4b9b8c2
Show file tree
Hide file tree
Showing 20 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion categories/euler/prob022-grondilu.pl
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion categories/euler/prob047-gerdr.pl
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion categories/euler/prob054-andreoss.pl
Expand Up @@ -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 ;
Expand Down
2 changes: 1 addition & 1 deletion categories/euler/prob059-andreoss.pl
Expand Up @@ -86,7 +86,7 @@ sub infix:<XOR>(@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 ;
Expand Down
2 changes: 1 addition & 1 deletion categories/euler/prob067-felher.pl
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion categories/euler/prob081-moritz.pl
Expand Up @@ -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+/) ];
Expand Down
3 changes: 1 addition & 2 deletions categories/rosalind/dbpr-grondilu.pl
Expand Up @@ -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});
Expand Down
2 changes: 1 addition & 1 deletion categories/rosalind/lcsq-grondilu.pl
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion categories/rosalind/mprt-grondilu.pl
Expand Up @@ -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"};
Expand Down
6 changes: 4 additions & 2 deletions categories/rosalind/sgra-grondilu.pl
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion categories/shootout/k-nucleotide.p6
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion categories/shootout/regex-dna.p6
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion categories/shootout/revcomp-v2.p6
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion categories/shootout/revcomp.p6
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion categories/wsg/advanced-2008/event001-eric256.pl
Expand Up @@ -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 = (
Expand Down
2 changes: 1 addition & 1 deletion categories/wsg/advanced-2008/event002-eric256.pl
Expand Up @@ -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 ;
Expand Down
2 changes: 1 addition & 1 deletion categories/wsg/advanced-2008/event005-eric256.pl
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion categories/wsg/beginner-2008/event003-unobe.pl
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion categories/wsg/beginner-2008/event006-eric256.pl
Expand Up @@ -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/) {
Expand Down
2 changes: 1 addition & 1 deletion categories/wsg/beginner-2008/event006-j1n3l0.pl
Expand Up @@ -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;

Expand Down

0 comments on commit 4b9b8c2

Please sign in to comment.