Sponsored Content
Top Forums Shell Programming and Scripting Passing multiple value in a single argument in Perl. Post 302930066 by Abhisrajput on Tuesday 30th of December 2014 05:44:49 AM
Old 12-30-2014
Passing multiple value in a single argument in Perl.

Hi all,

I have below code through which trying to pick data from specific columns strating from a certain row.

Code:
#!/usr/bin/perl
#This script is to pick the specific fields from a files starting from a specific row
# FILE -> Name of the file to be pasd at runtime.
# rn -> Number of the row from where the data has to be picked.
use strict;
use warnings;
my $file = shift || "FILE";
my $rn = shift;
my $cols = shift;
open( my $fh, "<", $file) or die "Could not open file '$file' : $!\n";
while (<$fh>) {
    $. <= $rn and next;
    my @fields = split(/\t/);
    print "$fields[$cols]\n";
}

My proble here is I am only able to get one column at a time. I want to fetch columns from
Code:
0, 1, 3..6, 21..33

but its giving me only first column.

I am runing below comand to execute the script.
Code:
perl extract.pl FILE 3 0, 1, 3..6, 21..33


Last edited by Abhisrajput; 12-30-2014 at 12:36 PM.. Reason: Missed the file name
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passing Argument

Hi All, i have script like below.. echo "1) first option" echo "" echo "2) second option" echo "" echo "*) please enter the correct option" read select case $select in 1) echo "first option selected" ;; 2) echo "second option selected" ;; *) echo "please enter the correct... (4 Replies)
Discussion started by: Shahul
4 Replies

2. UNIX for Dummies Questions & Answers

Using * when passing argument to alias

I have some folders with this structure: /data/me/a123xxx Where "xxx" is some changing series of letters, and "123" changes so folders might look like: /data/me/a123xxx /data/me/a234ysd /data/me/a534sds etc. The numbers are what matter to me (they identify the folder), so I created an... (7 Replies)
Discussion started by: ramparts
7 Replies

3. Shell Programming and Scripting

Help with Passing argument and testing

Hi all First of all thanks for everyone to read by doubt.Am beginner in shell scripting Following are my doubts i have to pass an argument to shellscript how can i do that second i have to test the argument and shows error when nothing is passes third i have to match exact argument... (3 Replies)
Discussion started by: zeebala1981
3 Replies

4. Shell Programming and Scripting

passing either of argument, not both in shell

Hi, I have a requirement to work on script, it should take either of arguments. wrote it as below. #!/bin/bash usage() { echo "$0: missing argument OR invalid option ! Usage : $0 -m|-r|-d } while getopts mrdvh opt; do case "$opt" in m) monitor_flag=monitor;;... (1 Reply)
Discussion started by: ramanaraoeee
1 Replies

5. Programming

PERL:Combining multiple lines to single line

Hi All I need a small help for the below format in making a small script in Perl or Shell. I have a file in which a single line entries are broken into three line entries. Eg: I have a pen and notebook. All i want is to capture in a single line in a separate file. eg: I have a pen and... (4 Replies)
Discussion started by: Kalaiela
4 Replies

6. Shell Programming and Scripting

passing argument from one function to another

Hi all, In the given script code . I want to pass the maximum value that variable "i" will have in function DivideJobs () to variable $max of function SubmitCondorJob(). Any help? Thanks #!/bin/bash ... (55 Replies)
Discussion started by: nrjrasaxena
55 Replies

7. Shell Programming and Scripting

Help with passing argument

Hi, I have a script that is scheduled with cron and runs every night. The cron part looks like this: 00 20 * * 0,1,2,3,4,5,6 /usr/local/bin/BACKUP TBTARM HOT DELETE My issue is with the 3rd parameter. Somewhere in the script, i want to tell the script to delete some files if the 3rd... (7 Replies)
Discussion started by: dollypee
7 Replies

8. Shell Programming and Scripting

Argument passing

How to pass the alphabet character as a argument in case and in if block? ex: c=$1 if a-z ]] then echo "alphabet" case $1 in a-z) echo "the value is a alphabet" edit by bakunin: please use CODE-tags. We REALLY mean it. (9 Replies)
Discussion started by: Roozo
9 Replies

9. Shell Programming and Scripting

Tabbed multiple csv files into one single excel file with using shell script not perl

Hi Experts, I am querying backup status results for multiple databases and getting each and every database result in one csv file. so i need to combine all csv files in one excel file with separate tabs. I am not familiar with perl script so i am using shell script. Could anyone please... (4 Replies)
Discussion started by: ramakrk2
4 Replies

10. UNIX for Beginners Questions & Answers

Passing a second argument

I am trying to pass a second argument like so: if ] then export ARG2=$2 else message "Second argument not specified: USAGE - $PROGRAM_NAME ARG1 ARG2" checkerror -e 2 -m "Please specify if it is a history or weekly (H or W) extract in the 2nd argument" fi however, it always goes... (4 Replies)
Discussion started by: MIA651
4 Replies
mlib_MatrixMulShift_S16_S16_Mod(3MLIB)			    mediaLib Library Functions			    mlib_MatrixMulShift_S16_S16_Mod(3MLIB)

NAME
mlib_MatrixMulShift_S16_S16_Mod, mlib_MatrixMulShift_S16_S16_Sat, mlib_MatrixMulShift_S16C_S16C_Mod, mlib_MatrixMulShift_S16C_S16C_Sat - matrix multiplication plus shifting SYNOPSIS
cc [ flag... ] file... -lmlib [ library... ] #include <mlib.h> mlib_status mlib_MatrixMulShift_S16_S16_Mod(mlib_s16 *z, const mlib_s16 *x, const mlib_s16 *y, mlib_s32 m, mlib_s32 l, mlib_s32 n, mlib_s32 shift); mlib_status mlib_MatrixMulShift_S16_S16_Sat(mlib_s16 *z, const mlib_s16 *x, const mlib_s16 *y, mlib_s32 m, mlib_s32 l, mlib_s32 n, mlib_s32 shift); mlib_status mlib_MatrixMulShift_S16C_S16C_Mod(mlib_s16 *z, const mlib_s16 *x, const mlib_s16 *y, mlib_s32 m, mlib_s32 l, mlib_s32 n, mlib_s32 shift); mlib_status mlib_MatrixMulShift_S16C_S16C_Sat(mlib_s16 *z, const mlib_s16 *x, const mlib_s16 *y, mlib_s32 m, mlib_s32 l, mlib_s32 n, mlib_s32 shift); DESCRIPTION
Each of these functions performs a multiplication of two matrices and shifts the result. For real data, the following equation is used: l-1 z[i*n + j] = {SUM (x[i*l + k] * y[k*n + j])} * 2**(-shift) k=0 where i = 0, 1, ..., (m - 1); j = 0, 1, ..., (n - 1). For complex data, the following equation is used: l-1 z[2*(i*n + j)] = {SUM (xR*yR - xI*yI)} * 2**(-shift) k=0 l-1 z[2*(i*n + j) + 1] = {SUM (xR*yI + xI*yR)} * 2**(-shift) k=0 where xR = x[2*(i*l + k)] xI = x[2*(i*l + k) + 1] yR = y[2*(k*n + j)] yI = y[2*(k*n + j) + 1] i = 0, 1, ..., (m - 1) j = 0, 1, ..., (n - 1) PARAMETERS
Each of the functions takes the following arguments: z Pointer to the first element of the result matrix, in row major order. x Pointer to the first element of the first matrix, in row major order. y Pointer to the first element of the second matrix, in row major order. m Number of rows in the first matrix. m > 0. l Number of columns in the first matrix, and the number of rows in the second matrix. l > 0. n Number of columns in the second matrix. n > 0. shift Right shifting factor. 1 <= shift <= 16. RETURN VALUES
Each of the functions returns MLIB_SUCCESS if successful. Otherwise it returns MLIB_FAILURE. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Committed | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
mlib_MatrixMul_U8_U8_Mod(3MLIB), attributes(5) SunOS 5.11 2 Mar 2007 mlib_MatrixMulShift_S16_S16_Mod(3MLIB)
All times are GMT -4. The time now is 10:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy