logo
down
shadow

Passing multiple values to a Perl program in a single command line argument


Passing multiple values to a Perl program in a single command line argument

By : gayathri
Date : November 19 2020, 01:01 AM
To fix the issue you can do In the absence of any other solutions I am posting some code that I have been messing with. It works with your command line as you have described it by concatenating all of the fields after the first and removing all spaces and tabs.
The column set is converted to a list of integers using eval, after first making sure that it consists of a comma-separated list of either single integers or start-end ranges separated by two or three full stops.
code :
use strict;
use warnings;
use 5.014;    # For non-destructive substitution and \h regex item

my $file = shift || "FILE";
my $rn   = shift || 0;
my $cols = join('', @ARGV) =~ s/\h+//gr;

my $item_re = qr/ \d+ (?: \.\.\.? \d+)? /ax;
my $set_re  = qr/ $item_re (?: , $item_re )* /x;
die qq{Invalid column set "$cols"} unless $cols =~ / \A $set_re \z /x;
my @cols = eval $cols;

open my $fh, '<', $file or die qq{Couldn't open "$file": $!};

while (<$fh>) {

    next if $. <= $rn;

    my @fields = split /\t/;
    print "@fields[@cols]\n";
}


Share : facebook icon twitter icon
Using command-line argument for passing files to a program

Using command-line argument for passing files to a program


By : michael abid
Date : March 29 2020, 07:55 AM
will help you Just the path of the file is passed, inside your program use the Java File class to handle it
This takes the first parameter as the file path:
code :
import java.io.File;

public class SomeProgram {
    public static void main(String[] args) {
        if(args.length > 0) {
            File file = new File(args[0]);

            // Work with your 'file' object here
        }
    }
}
Passing command line arguments to a Perl program run using Padre

Passing command line arguments to a Perl program run using Padre


By : cyndrillasiri
Date : March 29 2020, 07:55 AM
I wish this helpful for you Under Tools->Preferences->"Language - Perl5", set "Script arguments" and save.
Or under Tools->Preferences->Advanced, see "run_script_args_default". Set a value, and save.
python passing command line argument with-in program

python passing command line argument with-in program


By : amaric
Date : March 29 2020, 07:55 AM
Hope this helps Your index is wrong sys.argv[0] will be the path of the python script. What you want is:
code :
if __name__ == '__main__':
    if len(sys.argv) == 1:
        sys.argv.append("apple")
    select()
choice=['orange','apple', 'grapes', 'banna']

def select():
    parser = argparse.ArgumentParser(prog='one', description='name test')
    parser.add_argument(
        'fname',
        nargs='?',
        default='apple',
        action="store",
        type=str,
        choices=choice,
        help="furits name")

    args = parser.parse_args(sys.argv[1:2])

    print 'selected name {0}\n'.format(args.fname)

if __name__ == '__main__':
    select()
Multiple command line arguments in perl when one argument mistakenly takes other argument as its value

Multiple command line arguments in perl when one argument mistakenly takes other argument as its value


By : Zenghui.K
Date : March 29 2020, 07:55 AM
wish helps you You should use : instead of =.
You should check "Summary of Option Specifications" in Getopt::Long. This is from GetOptions.
Sending a hash of hashes from a Perl CGI program to another Perl script via a command-line argument

Sending a hash of hashes from a Perl CGI program to another Perl script via a command-line argument


By : Irokin
Date : March 29 2020, 07:55 AM
will be helpful for those in need You should send the data as JSON. IPC::Open3 might be a good choice:
Related Posts Related Posts :
  • perl script using XML parser to read values in text file and replace it xml file
  • Using Perl Redis::Client::Hash can't locate object method "TIEHASH"
  • How do I replace a random line in a file without copying it into another file using Perl
  • Example curses/ncurses Perl widget?
  • Perl printing binary to files - cr lf
  • Linux, Backtrack, Perl, Bluesniff
  • perl cgi print header charset not work
  • Any way to set keepalive in DBI connect method in Perl
  • Perl script does not recognize paths which contains environment variables
  • How to stop Runaway Perl Process
  • Scoping variables in a Perl Test::More .t file
  • Perl Sort Array
  • Content-Type setting for .MTS files
  • Seek function not working in perl
  • Perl syntax error printing list index
  • perl matching syntax with mail filter
  • Error Handling Using Perl Tkx
  • Perl : calculation of time in format hh:mm:ss,sss
  • Remove element from array containing empty or whitespace character in Perl
  • Running an external command in Perl / Tkx without blocking the GUI (Windows)
  • perl Parallel::ForkManager stuck in this script?
  • Unable to escape @ sign in perl
  • Loop to define buttons in Perl / Tkx
  • Why can't the Opsview_rest Perl script not find the OPSVIEW_URL_PREFIX Environment variable using $ENV{var} while it has
  • Get http-response header with Perl's File::Fetch
  • Perl Get the web content then writing it as a text file
  • perl $CGI::POST_MAX all parameters
  • Perl Foreach until loop
  • login failed to remote host - prompt does not match at /usr/lib/perl5/site_perl/5.10.0/Net/Appliance/Session/Transport.p
  • How is a literal list having one element represented unambiguously in perl?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org