Help for this page

Select Code to Download


  1. or download this
    @list = <>;
    ...
    $number = <>;  <strike># this will never be reached (or won't read any
    +thing)</strike>
    
  2. or download this
    open(LIST, "<$ARGV[0]");
    @list = <LIST>;
    close LIST;
    
  3. or download this
    print "Pick a number between 1 and ",scalar @list,": ";
    $line_no = <STDIN>;
    chomp $line_no;
    print "Contents of line # $line_no in $ARGV[0]:\n$list[$line_no-1]\n";