X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=utils%2Fparallel%2Fpar-aux.pl;fp=utils%2Fparallel%2Fpar-aux.pl;h=8484057aab44efb517deb0955ebaeb3b69143193;hb=0065d5ab628975892cea1ec7303f968c3338cbe1;hp=0000000000000000000000000000000000000000;hpb=28a464a75e14cece5db40f2765a29348273ff2d2;p=ghc-hetmet.git diff --git a/utils/parallel/par-aux.pl b/utils/parallel/par-aux.pl new file mode 100644 index 0000000..8484057 --- /dev/null +++ b/utils/parallel/par-aux.pl @@ -0,0 +1,89 @@ +#!/usr/local/bin/perl +############################################################################## +# Time-stamp: +# +# Usage: do ... +# +# Various auxiliary Perl subroutines that are mainly used in gran-extr and +# RTS2gran. +# This module contains the following `exported' routines: +# - mk_global_local_names +# - dat2ps_name +# The following routines should be local: +# - basename +# - dirname +# +############################################################################## + +# ---------------------------------------------------------------------------- +# Usage: do mk_global_local_names (); +# Returns: (,, ) +# +# Take a filename and create names for local and global variants. +# E.g.: foo.dat -> foo-local.dat and foo-global.dat +# ---------------------------------------------------------------------------- + +sub mk_global_local_names { + local ($file_name) = @_; + + $file_name .= ".dat" unless $file_name =~ /\.dat$/; + $global_file_name = $file_name; + $global_file_name =~ s/\.dat/\-global\.dat/ ; + $local_file_name = $file_name; + $local_file_name =~ s/\.dat/\-local\.dat/ ; + + return ( ($file_name, $global_file_name, $local_file_name) ); +} + + +# ---------------------------------------------------------------------------- +# Usage: do dat2ps(); +# Returns: (); +# ---------------------------------------------------------------------------- + +sub dat2ps_name { + local ($dat_name) = @_; + + $dat_name =~ s/\.dat$/\.ps/; + return ($dat_name); +} + +# ---------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- + +sub basename { + local ($in_str) = @_; + local ($str,$i) ; + + $i = rindex($in_str,"/"); + if ($i == -1) { + $str = $in_str; + } else { + $str = substr($in_str,$i+1) ; + } + + return $str; +} + +# ---------------------------------------------------------------------------- + +sub dirname { + local ($in_str) = @_; + local ($str,$i) ; + + $i = rindex($in_str,"/"); + if ($i == -1) { + $str = ""; + } else { + $str = substr($in_str,0,$i+1) ; + } + + return $str; +} + +# ---------------------------------------------------------------------------- + + +# ---------------------------------------------------------------------------- + +1;