in reply to Testing for one of three conditions

What about pushing them onto an array and then joining it. Join already has this logic for needing the | or not, and then you could put pages in the middle easily.

my @links = (); push @links, $firstlink if $. != 1; # push @links, pagelink($page) foreach my $page (@pages); push @links, $lastlink if $. != $total_number_of_lines; print join("|",@links);

Easy to ready and you can have some added functions (maybe, dunno how your code works.) (:


___________
Eric Hodges

Replies are listed 'Best First'.
Re: Re: Testing for one of three conditions
by Cody Pendant (Prior) on Apr 27, 2004 at 01:32 UTC

    Very neat, I didn't think of that.



    ($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss')
    =~y~b-v~a-z~s; print
Re: Re: Testing for one of three conditions
by halley (Prior) on Apr 27, 2004 at 13:10 UTC
    my @links = ( $firstlink, map { pagelink($_) } (@pages), $lastlink ); shift @links if $. == 1; pop @links if $. == $total_number_of_lines; print join('|', @links);

    --
    [ e d @ h a l l e y . c c ]