develooper Front page | perl.perl5.porters | Postings from April 2000

Is this desirable?

Tom Christiansen
April 4, 2000 08:50
Is this desirable?
Message ID:
I notice that the "existing blah through next/last" is warned of
even though the label should be in one's lexical scope.  Isn't it
the dynamic scope jump that's the scary one?  Or are they
both too scary to live?


        local *confirm = sub () { 
            next PATHNAME unless accesstty();
            print TTYOUT $renaming 
                    ? "rename $oldname to $newname? "
                    : "symlink $oldslink to point to $newname? ";
            my $answer = <TTYIN>;
>>>>        no warnings 'exiting';  # hush you! it's in my lexical scope!
            last PATHNAME  unless defined $answer;  # exit?
            chomp $answer;
            last PATHNAME  if     "QUIT" =~ /^\Q$answer/i;
            next PATHNAME  unless "YES"  =~ /^\Q$answer/i;

        confirm() if $inspect;

        #  "I'd like to teach 
        #       The world to race 
        #           In perfect hackery!"
        my $was_there = do { 
            no warnings 'newline';
            -e $newname;

        if ($renaming) {

            if ($was_there && !$inspect && $careful) {
                confirm() unless $force || $quiet;
                next PATHNAME if $quiet;  

            unless (vrename($oldname, $newname)) {
                warn "$0: can't rename $oldname to $newname: $!\n";
                next PATHNAME;

        } Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About