help - range passed via ARGV 
Author Message
 help - range passed via ARGV

I know this was posted about a month ago, could someone mail
me some of the replys.  Here is the question:

I need to expand a range that is passed via ARGV.  A simple
program that will do the following will give me the help
I need:
% myprog 1..3 7 10..12     <- command line
1 2 3 7 10 11 12           <- output
%

Thanks,
 - Charles
--
--------------------------------------------------------------

        The address is Intel's, the words are mine.
--------------------------------------------------------------



Tue, 14 Feb 1995 10:23:21 GMT  
 help - range passed via ARGV


| I know this was posted about a month ago, could someone mail
| me some of the replys.  Here is the question:
|
| I need to expand a range that is passed via ARGV.  A simple
| program that will do the following will give me the help
| I need:
| % myprog 1..3 7 10..12     <- command line
| 1 2 3 7 10 11 12           <- output
| %

My email bounced, so I will post this.  Hopefully the answer is more
correct than scalar (%array) which I gave out.  Mea cupla :-)

Try:




        $, = " ";
        $\ = "\n";

To explain it, lines 1-2 abort if any line is not a case range or
simple number (to prevent calling eval with something that you don't
expect).  Line 3 prevents an unused variable warning when using perl

that perl uses the syntax <value1>..<value2> to make an array of
ranges from value1 to value2.  The remaining lines just print out the
output.

If instead you wanted to take non numeric items as is without
aborting, you would use:



        $, = " ";
        $\ = "\n";

--

Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142

You are in a twisty little passage of standards, all conflicting.



Tue, 14 Feb 1995 23:05:08 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Perl drops first argv[0] parameter when being called via execv()

2. @ARGV vs. passing sub variable problem

3. How to pass perl script's STDIN to Korn shell's ARGV

4. How to pass file names to Perl for writing using $ARGV

5. CGI Script to Script Passing ARGV, Win32

6. C argv[0] vs Perl ARGV[0]

7. Difference @ARGV[0] and $filepath=@ARGV[0]

8. @ARGV and the $ARGV values seem to be returning null

9. associative array passing via @_

10. Fetch webpage via proxy passing Location header

11. Passing arbitray data between ro co-operating per scripts via a pipe

12. Passing Large Values via GET

 

 
Powered by phpBB® Forum Software