Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Does Perl 5 (or 6?) need another built-in variable for the -F switch?

by Hofmator (Curate)
on Nov 03, 2006 at 09:33 UTC ( #582037=note: print w/ replies, xml ) Need Help??


in reply to Re: Does Perl 5 (or 6?) need another built-in variable for the -F switch?
in thread Does Perl 5 (or 6?) need another built-in variable for the -F switch?

I like davido's suggestion of a %^C hash with the command line parameters that are used to invoke perl. This allows the programmer to use the value of F (or anything else defined on the commandline) for a join IF he/she knows that it is safe to do so - i.e. if it is not a pattern but a simple string, see duff's post in this thread.

-- Hofmator

Code written by Hofmator and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.


Comment on Re^2: Does Perl 5 (or 6?) need another built-in variable for the -F switch?
Re^3: Does Perl 5 (or 6?) need another built-in variable for the -F switch?
by Anonymous Monk on Nov 03, 2006 at 09:56 UTC
    On Linux with a mounted /proc file system, you can find the command line parameters from /proc/$$/cmdline.

    But this (and the proposed %^C) would be tricky. Command line parameters maybe clustered. Searching for just '-F' won't do, the parameter may be passed as '-wF:', which sets the split pattern to :. However, a parameter '-iF:' won't.

    And then there is PERL5OPT.

      Well, at least perl should know which command line parameters where used when it was invoked :) and as the proposed hash %^C was supposed to be populated by perl itself, this should work out fine. This hash should then, IMO, include the command line parameters set via PERL5OPT.

      Mind you, I have no idea how difficult it would be to patch that into perl, I just said I liked the idea.

      -- Hofmator

      Code written by Hofmator and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

        In that case, you rather want an array of pairs instead of a hash. There are switches that can be used multiple times (-M, among others), and some switches interact and their order is relevant (-l and -0 for instance).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://582037]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2014-09-17 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (70 votes), past polls