Help! with command line arguments 
Author Message
 Help! with command line arguments

Can anybody help me with this?

When a file, say fileA is to be executed and two parameters are to be passed
to it, say param1 and param2, we say:

        perl fileA param1 param2

on the command line.

Now, if i want to take input from STDIN, instead of from the fileA, how do i
pass the same parameters?

Thanx in advance,
Akila




Mon, 26 May 1997 02:35:04 GMT  
 Help! with command line arguments

Akhila> Can anybody help me with this?
Akhila> When a file, say fileA is to be executed and two parameters are to be passed
Akhila> to it, say param1 and param2, we say:

Akhila>      perl fileA param1 param2

Akhila> on the command line.

Akhila> Now, if i want to take input from STDIN, instead of from the fileA, how do i
Akhila> pass the same parameters?

I take it you have fallen into the habit of using <> when you mean <STDIN>.

Don't. :-)

<STDIN> always reads from standard input (unless you do something

I occasionally see my students write:

        print "what is the number? ";
        chop($n = <>);

And I cringe. :-)  That is why I teach <STDIN> *before* I get to <>.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)

--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying

Phrase: "Welcome to Portland, Oregon ... home of the California Raisins!"



Mon, 26 May 1997 00:53:07 GMT  
 Help! with command line arguments

Quote:

>    perl fileA param1 param2

>Now, if i want to take input from STDIN, instead of from the fileA, how do i
>pass the same parameters?

        perl - param1 param2

--
Rodger Anderson



Mon, 26 May 1997 07:14:28 GMT  
 Help! with command line arguments

   When a file, say fileA is to be executed and two parameters are to be passed
   to it, say param1 and param2, we say:

           perl fileA param1 param2

   on the command line.

   Now, if i want to take input from STDIN, instead of from the fileA, how do i
   pass the same parameters?


puts stdin first on input queue, then


passes off the rest to the other prog.



Mon, 26 May 1997 08:37:17 GMT  
 Help! with command line arguments

Quote:

>When a file, say fileA is to be executed and two parameters are to be passed
>to it, say param1 and param2, we say:
>    perl fileA param1 param2
>on the command line.

>Now, if i want to take input from STDIN, instead of from the fileA, how do i
>pass the same parameters?

I interpret this as meaning that you are supplying the PERL SCRIPT on
STDIN.  In this case, you can say:
    perl - param1 param2

and perl will take its command stream from STDIN and pass "param1" and
"param2" as $ARGV[0] and $ARGV[1] respectively.

        pete peterson

        (508)287-7478; Home: (508)256-5829 (Chelmsford, MA)



Mon, 26 May 1997 22:04:16 GMT  
 Help! with command line arguments
: When a file, say fileA is to be executed and two parameters are to be passed
: to it, say param1 and param2, we say:
:       perl fileA param1 param2
: on the command line.
: Now, if i want to take input from STDIN, instead of from the fileA, how do i
: pass the same parameters?

Can you recode it so it wants to run like "perl param1 param2 fileA"?
Then the "while (<>)" construct will handle it.

--
--
jan b schipmolder



Tue, 27 May 1997 08:01:52 GMT  
 Help! with command line arguments
: Can anybody help me with this?

: When a file, say fileA is to be executed and two parameters are to be passed
: to it, say param1 and param2, we say:

:       perl fileA param1 param2

: on the command line.

: Now, if i want to take input from STDIN, instead of from the fileA, how do i
: pass the same parameters?

I am assuming the fileA is the perl program.

There's more than one way..

one)


        # At this point there is NO elements (supposedly)
        # in ARGV.  Which tells perl to switch to stdin
        # for input.

two)

        while(<STDIN>) {
        }

three)
        # Assuming that the other params are files.


<chaim>

--
Chaim Frenkel                                                   On contract at:

Nonlinear Knowledge, Inc.                              Bear Stearns & Co., Inc.



Thu, 29 May 1997 12:47:29 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. How to insert images in a TDbRichEdit

2. Help passing argument to the command line

3. help w/command line argument

4. Command line argument help please

5. Need help with command line arguments

6. running perl at command line with arguments: script.cgi?text=text

7. Simple reordering of command line arguments.

8. Command line arguments.

9. Modification of command line arguments

10. Where are command line arguments described?

11. patch1 for wafeperl 0.2 to allow xt command line argument processing

12. Command line arguments?

 

 
Powered by phpBB® Forum Software