Sponsored Content
Top Forums Shell Programming and Scripting Perl Getopt::Long question - stopping multiple args Post 302395969 by rethink on Wednesday 17th of February 2010 11:12:10 AM
Old 02-17-2010
Sorry Pludi, i think you may have misunderstood my problem, issuing multiple --surnames is not really the problem, its when they issue multiple arguments to the same --surname option

using the exact script you posted above, i issued

Code:
 # ./name.pl --firstname john --surname smith jones
firstname is set to  - john
surname is set to  - smith

wjen we print the array at the bottom of the script, the second argument is not printed
 

10 More Discussions You Might Find Interesting

1. Programming

question about getopt()

I'm using getopt() to get command line options.One the optons accepts and argument.The argument is and offset.I was wondering how can I scecify that it's argument is of the type off_t.I've something like this "offset=(off_t)optarg" and it don't work. (1 Reply)
Discussion started by: angelfly
1 Replies

2. AIX

Stopping multiple process on AIX

I'm trying to update a shared library (*.so) in our AIX machine. However, when I tried to delete the old *.so file, I get this error -> Cannot open or remove a file containing a running program. Based on the information I gather from the net, shared libraries are not unloaded (the file remains... (3 Replies)
Discussion started by: soulfactory2002
3 Replies

3. Shell Programming and Scripting

getopt in perl

Hi, I have a perl script with two functions say func a and func b. sub a { ----------- --------- } sub b { --------- --------- } I want to use this function on command line as we can do in shell script using getopt. My motto here is to run the script like this ... (7 Replies)
Discussion started by: namishtiwari
7 Replies

4. Shell Programming and Scripting

using getopt for both short and long options

Hi , I am using getopt for both short and long options as below SHORTOPTS="a:c" LONGOPTS="alpha:,charlie" OPTS=$(getopt -o $SHORTOPTS --longoptions $LONGOPTS -n "$progname" -- "$@") eval set -- "$OPTS" while ; do case $1 in -a|--alpha) echo "-a or --alpha... (0 Replies)
Discussion started by: padmisri
0 Replies

5. Shell Programming and Scripting

using getopt for both short and long options

Hi , I am using getopt for both short and long options as below SHORTOPTS="a:c" LONGOPTS="alpha:,charlie" OPTS=$(getopt -o $SHORTOPTS --longoptions $LONGOPTS -n "$progname" -- "$@") eval set -- "$OPTS" while ; do case $1 in -a|--alpha) echo "-a or --alpha... (1 Reply)
Discussion started by: padmisri
1 Replies

6. Shell Programming and Scripting

using getopt for both short and long options

Hi , I am using getopt for both short and long options as below SHORTOPTS="a:c" LONGOPTS="alpha:,charlie" OPTS=$(getopt -o $SHORTOPTS --longoptions $LONGOPTS -n "$progname" -- "$@") eval set -- "$OPTS" while ; do case $1 in -a|--alpha) echo "-a or --alpha... (1 Reply)
Discussion started by: padmisri
1 Replies

7. Programming

Perl Getopt::Long

Hi All I am using Getopt::Long in perl and i am trying to have it so if i dont supply a switch after the progname is will do a defult option i have the following GetOptions($OPT, 'debug|d', 'mail|m', ) or info(); i want it run the debug if it is not given a switch ... (1 Reply)
Discussion started by: ab52
1 Replies

8. Shell Programming and Scripting

Perl :: Getopt::Long in the program

While going through some of the perl script... I had found the below line.. use Getopt::Long; my $GetOptionsReturnCode = GetOptions ( '<>' => sub { push(@unknownArg, @_); }, 'h|help' => sub { &helpMessage(); exit 0; }, ); Could anyone please explain the above one ... (1 Reply)
Discussion started by: scriptscript
1 Replies

9. Shell Programming and Scripting

Store args passed in array but not the first 2 args

Store args passed in array but not the first 2 args. # bash declare -a arr=("$@") s=$(IFS=, eval 'echo "${arr}"') echo "$s" output: sh array.sh 1 2 3 4 5 6 1,2,3,4,5,6 Desired output: sh array.sh 1 2 3 4 5 6 3,4,5,6 (2 Replies)
Discussion started by: iaav
2 Replies

10. UNIX for Beginners Questions & Answers

Question about getopts optional argument [args...]

There are many places where I can see the syntax description for optargs, which, usually boils down to this: getopts OPTSTRING VARNAME where: OPTSTRING tells getopts which options to expect and where to expect arguments VARNAME tells getopts which shell-variable to use for option reporting... (2 Replies)
Discussion started by: sharkura
2 Replies
FILTER_VAR(3)								 1							     FILTER_VAR(3)

filter_var - Filters a variable with a specified filter

SYNOPSIS
mixed filter_var (mixed $variable, [int $filter = FILTER_DEFAULT], [mixed $options]) DESCRIPTION
PARAMETERS
o $variable - Value to filter. o $filter - The ID of the filter to apply. The "Types of filters" manual page lists the available filters. If omitted, FILTER_DEFAULT will be used, which is equivalent to FILTER_UNSAFE_RAW. This will result in no filtering taking place by default. o $options - Associative array of options or bitwise disjunction of flags. If filter accepts options, flags can be provided in "flags" field of array. For the "callback" filter, callable type should be passed. The callback must accept one argument, the value to be fil- tered, and return the value after filtering/sanitizing it. <?php // for filters that accept options, use this format $options = array( 'options' => array( 'default' => 3, // value to return if the filter fails // other options here 'min_range' => 0 ), 'flags' => FILTER_FLAG_ALLOW_OCTAL, ); $var = filter_var('0755', FILTER_VALIDATE_INT, $options); // for filter that only accept flags, you can pass them directly $var = filter_var('oops', FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); // for filter that only accept flags, you can also pass as an array $var = filter_var('oops', FILTER_VALIDATE_BOOLEAN, array('flags' => FILTER_NULL_ON_FAILURE)); // callback validate filter function foo($value) { // Expected format: Surname, GivenNames if (strpos($value, ", ") === false) return false; list($surname, $givennames) = explode(", ", $value, 2); $empty = (empty($surname) || empty($givennames)); $notstrings = (!is_string($surname) || !is_string($givennames)); if ($empty || $notstrings) { return false; } else { return $value; } } $var = filter_var('Doe, Jane Sue', FILTER_CALLBACK, array('options' => 'foo')); ?> RETURN VALUES
Returns the filtered data, or FALSE if the filter fails. EXAMPLES
Example #1 A filter_var(3) example <?php var_dump(filter_var('bob@example.com', FILTER_VALIDATE_EMAIL)); var_dump(filter_var('http://example.com', FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)); ?> The above example will output: string(15) "bob@example.com" bool(false) SEE ALSO
filter_var_array(3), filter_input(3), filter_input_array(3), "Types of filters", information about the callback type. PHP Documentation Group FILTER_VAR(3)
All times are GMT -4. The time now is 04:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy