I used the ARGV earlier, but received errors. So this is how the script looks now:
#! /usr/local/bin/perl -w
use strict;
#
#
#

$/ = "\n%\n";

while (<>) {
my $random = rand(@ARGV);
my $question = $ARGV[$random];
chomp $question;
print $question;

This is the error I am getting back:

Use of uninitialized value at /home/mcorgan/bin/flash line 12, <> chunk 1.
Use of uninitialized value at /home/mcorgan/bin/flash line 13, <> chunk 1.
Use of uninitialized value at /home/mcorgan/bin/flash line 12, <> chunk 2.
Use of uninitialized value at /home/mcorgan/bin/flash line 13, <> chunk 2.

Aren't I initializing the values with the "my" before the scalar variables?




From: "Wagner, David --- Senior Programmer Analyst --- WGO" <[EMAIL PROTECTED]>
To: 'Michael Corgan' <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
Subject: RE: How to name STDIN from the command line
Date: Thu, 23 Jan 2003 14:18:24 -0600

Michael Corgan wrote:
> How do I name the STDIN from the command line. I'm trying to write a
> simple script to randomly pick a file from a file name I enter on the
> command line. This is what I have:
>
> my @cards = (<>); #set stdin to @cards
> while (<>) {
> my $random = rand(@cards);
> my $question = $cards[$random];
> chomp $question;
> print $question;
> }
>
@ARGV holds the params passed to the script, so you can use @ARGV or
transfer the info to your array.

Wags ;)


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to