Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Keep It Simple, Stupid
 
PerlMonks  

Re: A thought about usability in Perl and Linux in general.

by zentara (Cardinal)
on May 18, 2005 at 07:46 UTC ( [id://458156]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to A thought about usability in Perl and Linux in general.

You can write scripts that do it both ways. Just check for @ARGV, if they exist, go on with the script. If they are not there, prompt the user for values.

Installing Perl from source is a good example of this. A minimal example is:

#!/usr/bin/perl use warnings; use strict; my $count = 0; if( $ARGV[0] ){ $count = $ARGV[0]; }else{ print "Enter integer to count to, and press return\n"; $count = <>; chomp $count; } for(0..$count){ print "$_\n"; }

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^2: A thought about usability in Perl and Linux in general.
by holli (Abbot) on May 18, 2005 at 08:37 UTC
    From the OP:
    but whenever I write a small command line script [...] I always have it prompt for input if none is specified.
    Period.


    holli, /regexed monk/
Re^2: A thought about usability in Perl and Linux in general.
by DrHyde (Prior) on May 19, 2005 at 05:58 UTC
    In the Unix world, invoking the command without parameters generally makes it choose a set of well-documented defaults.

    Prompting for parameters is also reasonable, but if you do that, please check that STDIN is a tty using the -t test.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://458156]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.