Changeset 17701 for examples

Show
Ignore:
Timestamp:
09/06/07 19:43:34 (16 months ago)
Author:
lwall
Message:

s:g/err/orelse/

Location:
examples
Files:
20 modified

Legend:

Unmodified
Added
Removed
  • examples/advocacy/motd-i.pl

    r15167 r17701  
    1414my $dict = canonpath("$progdir/pugspraise"); 
    1515 
    16 my $fh = open($dict) err die $!; 
     16my $fh = open($dict) orelse die $!; 
    1717 
    1818for =$fh->$line { 
  • examples/advocacy/motd.pl

    r11293 r17701  
    1212my $limit     = @*ARGS[0] // '2'; 
    1313my $dict      = canonpath("$progdir/pugspraise"); 
    14 my $fh        = open $dict err die $!; 
     14my $fh        = open $dict orelse die $!; 
    1515my @list      = =$fh; 
    1616 
  • examples/cookbook/07file-access/07-01opening_file.pl

    r11293 r17701  
    1010 
    1111my $input = open($path, :r) 
    12     err die "Could not open $path for reading $!\n"; 
     12    orelse die "Could not open $path for reading $!\n"; 
    1313 
    1414my $filename = "test_file"; 
    1515my $output = open($filename, :w)  
    16     err die "Could not open $filename for writing $!\n"; 
     16    orelse die "Could not open $filename for writing $!\n"; 
    1717 
    1818 
     
    2929 
    3030# Closing the file 
    31 # $input.close err die $!; 
     31# $input.close orelse die $!; 
    3232# close($input); 
    3333 
  • examples/cookbook/07file-access/07-04making_perl_report_filenames_in_error_messages.pl

    r11293 r17701  
    99 
    1010#my $fh = open($path) 
    11 #    err die "Could not open '$path' for reading: $!\n"; 
     11#    orelse die "Could not open '$path' for reading: $!\n"; 
    1212  
  • examples/games/hangman.pl

    r12799 r17701  
    1818sub get_committer_list (Str $dict_file) returns List { 
    1919    my @committers; 
    20     my $dict = open($dict_file) err die "Couldn't open the AUTHORS file.\nYou must run this script from within the main pugs\ndirectory or within the examples/ sub-directory."; 
     20    my $dict = open($dict_file) orelse die "Couldn't open the AUTHORS file.\nYou must run this script from within the main pugs\ndirectory or within the examples/ sub-directory."; 
    2121 
    2222    # Skip the intro text 
  • examples/games/hangman.pod

    r6851 r17701  
    1111=head1 sub get_committer_list 
    1212 
    13 C<err> is the low precedence form of C<//> (S03). C<//> is especially useful 
     13C<orelse> is the low precedence form of C<//> (S03). C<//> is especially useful 
    1414in its assignment form: 
    1515 
    1616    $x //= $y; 
    1717 
    18 To summarize, C<||> and C<or> relate to truth, while C<//> and C<err> relate 
     18To summarize, C<||> and C<or> relate to truth, while C<//> and C<orelse> relate 
    1919to definedness. 
    2020 
  • examples/golf/tsanta.pl

    r15167 r17701  
    2424 
    2525sub golf_score (Str $script) returns Int { 
    26     my $fh = open($script) err die("open '$script' failed: $!"); 
     26    my $fh = open($script) orelse die("open '$script' failed: $!"); 
    2727    my $golf = 0; 
    2828    my $dollar_dot = 0;    # Note: $. aka $fh.linenum() not implemented yet 
     
    3232            unless $dollar_dot==1 && $line.index("#!") == 0; 
    3333    } 
    34     $fh.close() err die("close '$script' failed: $!"); 
     34    $fh.close() orelse die("close '$script' failed: $!"); 
    3535    return $golf; 
    3636} 
     
    4343 
    4444sub build_file (Str $fname, Str $data) { 
    45     my $fh = open($fname, :w) err die("open '$fname' failed: $!"); 
    46     $fh.print($data) err die("print '$fname' failed: $!"); 
    47     $fh.close() err die("close '$fname' failed: $!"); 
     45    my $fh = open($fname, :w) orelse die("open '$fname' failed: $!"); 
     46    $fh.print($data) orelse die("print '$fname' failed: $!"); 
     47    $fh.close() orelse die("close '$fname' failed: $!"); 
    4848} 
    4949 
     
    5353    print("$label: running: '$cmd'..."); 
    5454    # my $out = `$cmd`; 
    55     system($cmd) err die("system '$cmd' failed: $!"); 
     55    system($cmd) orelse die("system '$cmd' failed: $!"); 
    5656    # XXX: get return code. how? $!? (I think $? is obsolete in p6). 
    5757    my $rc = 0; 
    58     my $out = slurp($outtmp) err die("slurp '$outtmp' failed: $!"); 
     58    my $out = slurp($outtmp) orelse die("slurp '$outtmp' failed: $!"); 
    5959    # my $rc = $? >> 8; 
    6060    say("done (rc=$rc)"); 
  • examples/irclog2html.pl

    r13342 r17701  
    7272 
    7373# Pass I 
    74 my $fh = open @*ARGS[0] err die "Couldn't open \"@*ARGS[0]\": $!\n"; 
     74my $fh = open @*ARGS[0] orelse die "Couldn't open \"@*ARGS[0]\": $!\n"; 
    7575my $total = 0; 
    7676 
     
    9999 
    100100# Pass I 
    101 $fh = open @*ARGS[0] err die "Couldn't open \"@*ARGS[0]\": $!\n"; 
     101$fh = open @*ARGS[0] orelse die "Couldn't open \"@*ARGS[0]\": $!\n"; 
    102102 
    103103# This is the main coderef which processes a logline and returns HTML. 
  • examples/matrix.pl

    r16636 r17701  
    6969 
    7070gather { 
    71     for slurp '/usr/share/dict/words' :chomp err die { 
     71    for slurp '/usr/share/dict/words' :chomp orelse die { 
    7272        next if /<-[a-z]>/; 
    7373        /$re/ and take { word => $_, score => %scores{ .letters }.sum }; 
  • examples/naive_bayesian/naive_bayesian.pl

    r15167 r17701  
    55sub load_db returns Void { 
    66    return() unless "words.db.pl" ~~ :e; 
    7     my $db = open("words.db.pl") err die "Cannot open the words.db.pl file: $!"; 
     7    my $db = open("words.db.pl") orelse die "Cannot open the words.db.pl file: $!"; 
    88    for (=$db) -> $_line { 
    99        my $line = $_line; 
     
    1515 
    1616sub save_db returns Void { 
    17     my $db = open("words.db.pl", :w) err die "Cannot open the words.db.pl file: $!"; 
     17    my $db = open("words.db.pl", :w) orelse die "Cannot open the words.db.pl file: $!"; 
    1818    for (%words.kv) -> $key, $value { 
    1919        $db.say($key ~ "\t" ~ $value); 
     
    2424sub parse_file (Str $file) returns Hash { 
    2525    my %words_in_file;     
    26     my $fh = open("$file") err die "Cannot open the '$file' file: $!"; 
     26    my $fh = open("$file") orelse die "Cannot open the '$file' file: $!"; 
    2727    for (=$fh) -> $_line { 
    2828        my $line = $_line;        
  • examples/network/hangmanbot.pl

    r12807 r17701  
    2020sub get_committer_list(Str $dict_file) returns List { 
    2121  my @committers; 
    22   my $dict = open($dict_file) err 
     22  my $dict = open($dict_file) orelse 
    2323    die "Couldn't open \"$dict_file\": $!\n"; 
    2424 
  • examples/p6explain/p6explain

    r11293 r17701  
    66 
    77# Parsing the dat 
    8 my $fh = open $dat err die "Couldn't open \"$dat\" for reading: $!\n"; 
     8my $fh = open $dat orelse die "Couldn't open \"$dat\" for reading: $!\n"; 
    99for =$fh { 
    1010  state $cur_entry; 
  • examples/password-manager.p6

    r16177 r17701  
    9090 
    9191sub xclip(Str $s -->) { 
    92         my IO $xclip = Pipe.to: 'xclip' err abort 'No xclip - use .p'; 
     92        my IO $xclip = Pipe.to: 'xclip' orelse abort 'No xclip - use .p'; 
    9393        $xclip.print: $s; 
    9494        $xclip.close; 
     
    9898        my Str $pw = %pw{$s}<pass> // 
    9999                first Str, (%pw{$_}<pass> if /$s/ for %pw.keys) 
    100                 err abort "Couldn't find account $s"; 
     100                orelse abort "Couldn't find account $s"; 
    101101        xclip $pw; 
    102102        cmt if $changed; 
     
    117117 
    118118sub cmt(-->) { 
    119         unlink 'pwd.gpg.old' err abort "Couldn't unlink: $!"; 
    120         rename 'pwd.gpg', 'pwd.gpg.old' err abort "Couldn't rename: $!"; 
     119        unlink 'pwd.gpg.old' orelse abort "Couldn't unlink: $!"; 
     120        rename 'pwd.gpg', 'pwd.gpg.old' orelse abort "Couldn't rename: $!"; 
    121121        my IO $pwd = Pipe.to: 'gpg --symmetric --force-mdc --cipher-algo AES256 --output pwd.gpg' 
    122                 err abort "Couldn't encrypt: $!"; 
     122                orelse abort "Couldn't encrypt: $!"; 
    123123        for %pw.keys -> $k { $pwd.say: $k, "\t", %pw{$k}<pass user>.join("\t") } 
    124124        if $pwd.close { 
     
    168168%*ENV<PATH> = '/bin:/usr/bin:/usr/bin/X11'; 
    169169umask 0o77; 
    170 chdir "$+HOME/pw" err die "Couldn't cd: $!"; 
    171 my IO $pwd = Pipe.from: 'gpg --output - --decrypt pwd.gpg' err die "Couldn't decrypt: $!"; 
     170chdir "$+HOME/pw" orelse die "Couldn't cd: $!"; 
     171my IO $pwd = Pipe.from: 'gpg --output - --decrypt pwd.gpg' orelse die "Couldn't decrypt: $!"; 
    172172for =$pwd { 
    173173        /<pwent>/ or die 'Malformed line ', $pwd.linenum, ": $_\n"; 
  • examples/perl5/cpan-upload.pl

    r15167 r17701  
    230230    #------------------------------------------------------------------- 
    231231    _debug("  creating instance of LWP::UserAgent\n"); 
    232     $agent = LWP::UserAgent.new() err die "Failed to create UserAgent: $!\n"; 
     232    $agent = LWP::UserAgent.new() orelse die "Failed to create UserAgent: $!\n"; 
    233233    $agent.agent("$PROGRAM/$VERSION"); 
    234234    $agent.from($config.mailto); 
  • examples/perldoc.pl

    r15167 r17701  
    4646sub display_pod { 
    4747    my ($podfile) = @_; 
    48     my $fh = open $podfile err die "Could not open '$podfile'\n"; 
     48    my $fh = open $podfile orelse die "Could not open '$podfile'\n"; 
    4949    for =$fh -> $line { 
    5050        say $line; 
     
    6262    for list_files(dirname($PROGRAM_NAME)) -> $podfile { 
    6363        say "Processing '$podfile'"; 
    64         my $fh = open $podfile err die "Could not open '$podfile'\n"; 
     64        my $fh = open $podfile orelse die "Could not open '$podfile'\n"; 
    6565        my $row = 0; 
    6666        my $section; 
     
    8686sub list_files ($dir, $full) { 
    8787    #say "opening $dir"; 
    88     my $dh = opendir $dir err die "Could not open $dir"; 
     88    my $dh = opendir $dir orelse die "Could not open $dir"; 
    8989    my @entries; 
    9090    for $dh.readdir -> $entry { 
     
    111111            my ($row, $file) = split /\./, $entry, 2; 
    112112            say "here: $file  $row"; 
    113             my $fh = open $file err die "Could not open $file"; 
     113            my $fh = open $file orelse die "Could not open $file"; 
    114114            for (0..$row) { 
    115115                =$fh; 
  • examples/qotw/019r/qotw-regular-19.pl

    r15167 r17701  
    99$scale //= 100; 
    1010 
    11 my $FH = open $file err die "Could't open \"$file\"!\n"; 
     11my $FH = open $file orelse die "Could't open \"$file\"!\n"; 
    1212 
    1313for =$FH -> $line { 
  • examples/qotw/024r/qotw-regular-24.pl

    r11275 r17701  
    22# http://perl.plover.com/qotw/r/solution/024. 
    33 
    4 my $transition_file = @*ARGS[0] err 
     4my $transition_file = @*ARGS[0] orelse 
    55  die "Usage: $*PROGRAM_NAME transition_file [initial_tape]\n"; 
    66 
     
    1515my $tape_loc = 0; 
    1616 
    17 my $trans = open $transition_file err 
     17my $trans = open $transition_file orelse 
    1818  die "Can't open \"$transition_file\" for reading!\n"; 
    1919 
  • examples/rpn/p6/Rpn.pm

    r8662 r17701  
    1717            next; 
    1818        } 
    19         my $x = @stack.pop() err die "Stack underflow\n"; 
    20         my $y = @stack.pop() err die "Stack underflow\n"; 
     19        my $x = @stack.pop() orelse die "Stack underflow\n"; 
     20        my $y = @stack.pop() orelse die "Stack underflow\n"; 
    2121 
    2222        # given/when is a sexy new P6 construct that can avoid 
  • examples/rules/rpn_calc.pl

    r12581 r17701  
    5050            next; 
    5151        } 
    52         my $x = @stack.pop() err die "Stack underflow\n"; 
    53         my $y = @stack.pop() err die "Stack underflow\n"; 
     52        my $x = @stack.pop() orelse die "Stack underflow\n"; 
     53        my $y = @stack.pop() orelse die "Stack underflow\n"; 
    5454 
    5555        # given/when is a sexy new P6 construct that can avoid 
  • examples/rules/unitsdat-grammar.pm

    r16652 r17701  
    732732        # NumUnit handles most of the traditional unit stuff via units.dat. 
    733733        my $unitsdat = open "/usr/share/misc/units.dat" 
    734             err die "You don't have a readable /usr/share/misc/units.dat: $!"; 
     734            orelse die "You don't have a readable /usr/share/misc/units.dat: $!"; 
    735735        cat =$unitsdat ~~ /<UnitsDat>/; 
    736736        $unitsdat.close;