Hello.
I'm new to Perl and I am not sure how to interpret command line arguments in the program. I am writing a program similar to the Unix utility 'tail' and need to check if first argument is '-1' ([dash]1) or any arbitrary number of lines to output. How would I write an 'if' statement to check for the dash (-) and a number? Checking for the dash is trivial below.
Code:
if ($ARGV[0] eq "-")
{
print "I think it works\n";
}
How can I parse the dash with a number attached? Any numerical value?
Sample program run below:
File 'samp.txt' contains:
Hello World
This
Is
A
Test
Hi List,
Is it possible to pass one argument to a shell program
eg) there is a shell program abc which takes one arguments
abc one
Due to some reasons I pass
abc one two
Now one,two must be considered as "one" argument to the shell programs. Any suggestions,hints are welcome.
... (3 Replies)
Can someone help me to understand this part of code?
/bin/nawk -f awkfile file1 file2
I know awkfile is the one with awk script.
file1 is source file that needs to be processed.
What is file2 two?
Thanks for your help! (4 Replies)
In DDD debugger, where to set the the arguments for main program?
For example: ./myExe "argv1" "argv2" -> where to set "argv1" & "argv2" ?
Thanks! (2 Replies)
I have a shell script that is attempting to call a c program.
I call the c program with ./dictool
dictool accepts arguments at runtime. It works by prompting the user for various commands, acting on those commands, spitting out an output, and then prompting for more commands.
My question is,... (1 Reply)
I have the following piece of code. Currently the command line arguments are passed as shown below using the "= "sign. I capture the name of the argument, for example vmod and it's corresponding user parameter which is jcdint-z30.cmd.
./raytrac vmod=jcdint-z30.cmd srFile=jcdint.sr
Now I want... (12 Replies)
Hello,
The arguments are strings. In my code I need them to be a different type, I do the cast but it is not feasible ...
Have you any idea?
Thank you (8 Replies)
I want to write a C++ program that uses a class to do some calculations.
I pass arguments to the program, some of which are used to set up class members. A class function will then perform the necessary calculations.
I am wondering how I should pass the arguments from the program to set the... (2 Replies)
Dear Users,
I have installed a standalone program to do multiple sequence alignment which takes user parameters to run the program. I have multiple sequence files and want to automate this process through a bash script. I have tried to write a small bash code but its throwing errors.
Kindly... (13 Replies)
#!/bin/awk -f
BEGIN {
FS=":";
}
{
if ( $7 == "" ) {
print $1 ": no password!";
}
}
I want to execute this program for a particular user to check for his password from the file /etc/passwd (as the input file) and the user details to be given... (1 Reply)
Perl::Critic::Policy::Subroutines::ProhibitManyArgs(3pm)User Contributed Perl DocumentatioPerl::Critic::Policy::Subroutines::ProhibitManyArgs(3pm)NAME
Perl::Critic::Policy::Subroutines::ProhibitManyArgs - Too many arguments.
AFFILIATION
This Policy is part of the core Perl::Critic distribution.
DESCRIPTION
Subroutines that expect large numbers of arguments are hard to use because programmers routinely have to look at documentation to remember
the order of those arguments. Many arguments is often a sign that a subroutine should be refactored or that an object should be passed to
the routine.
CONFIGURATION
By default, this policy allows up to 5 arguments without warning. To change this threshold, put entries in a .perlcriticrc file like this:
[Subroutines::ProhibitManyArgs]
max_arguments = 6
CAVEATS
PPI doesn't currently detect anonymous subroutines, so we don't check those. This should just work when PPI gains that feature.
We don't check for @ARG, the alias for @_ from English.pm. That's deprecated anyway.
TO DO
Don't include $self and $class in the count.
CREDITS
Initial development of this policy was supported by a grant from the Perl Foundation.
AUTHOR
Chris Dolan <cdolan@cpan.org>
COPYRIGHT
Copyright (c) 2007-2011 Chris Dolan. Many rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license
can be found in the LICENSE file included with this module
perl v5.14.2 2012-06-07 Perl::Critic::Policy::Subroutines::ProhibitManyArgs(3pm)