Sponsored Content
Full Discussion: Perl Parsing Argument
Top Forums Shell Programming and Scripting Perl Parsing Argument Post 302316766 by mingming88 on Saturday 16th of May 2009 11:30:39 AM
Old 05-16-2009
Perl Parsing Argument

i wanna passing an argument which read in a file or a set of files if the files are given in the command line, otherwise use STDIN if no file argument.
i got something like that, but it is not really working.
so can anyone help me? which one is better to use for and how? Use perl.

Thank you

Code:
use Getopt()::Long;
GetOptions( "file=s" => \$file );


Code:
$str = @ARGV ? $ARGV[0] : <STDIN>
chomp ($str = <STDIN>);

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script argument parsing

how to parse the command line argument to look for '@' sign and the following with '.'. In my shell script one of the argument passed is email address. I want to parse this email address to look for correct format. rmjoe123@hotmail.com has '@' sign and followed by a '.' to be more... (1 Reply)
Discussion started by: rmjoe
1 Replies

2. UNIX for Dummies Questions & Answers

command line argument parsing

how to parse the command line argument to look for '@' sign and the following with '.'. In my shell script one of the argument passed is email address. I want to parse this email address to look for correct format. rmjoe123@hotmail.com has '@' sign and followed by a '.' to be more... (1 Reply)
Discussion started by: rmjoe
1 Replies

3. Shell Programming and Scripting

argument parsing...

Hi all, Iam a beginer in shell scripting. i need a script that can parse the arguments and store them in variables. ex: ./myScript -v v1 -h v2 -c v3...... can someone suggest me...? tnx in adv. (1 Reply)
Discussion started by: midhun_u
1 Replies

4. Shell Programming and Scripting

not null cheking of an argument in perl

Hi, I have to check whether an argument say $ARGV is not null in an if operator. Please let me know the operator. It would be great if you write a psuedo code. Thanks in advance Ammu (4 Replies)
Discussion started by: ammu
4 Replies

5. Shell Programming and Scripting

problem with spaces and argument parsing

public class HelloWorld { public static void main(String args) { System.out.println("Welcome, master"); } } and I compiled using javac HelloWorld.java ] Suppose that I execute the following command directly from the shell: java -XX:OnError="gdb - %p" HelloWorld Then it works... (8 Replies)
Discussion started by: fabulous2
8 Replies

6. Shell Programming and Scripting

Perl parsing compared to Ksh parsing

#! /usr/local/bin/perl -w $ip = "$ARGV"; $rw = "$ARGV"; $snmpg = "/usr/local/bin/snmpbulkget -v2c -Cn1 -Cn2 -Os -c $rw"; $snmpw = "/usr/local/bin/snmpwalk -Os -c $rw"; $syst=`$snmpg $ip system sysName sysObjectID`; sysDescr.0 = STRING: Cisco Internetwork Operating System Software... (1 Reply)
Discussion started by: popeye
1 Replies

7. Shell Programming and Scripting

PERL need help splitting argument

If i have a script name.pl I run it like name.pl -v file.txt -t ext2 -u user -j how can I edit the array @ARGV so when my script calls $ARGV = -v file.txt $ARGV = -j (2 Replies)
Discussion started by: 3junior
2 Replies

8. Shell Programming and Scripting

How to use perl to run bash with argument?

Hi All, I want to run a bash script using perl. But they are in the different dir. #! /usr/bin/perl -w use strict; my $root=`pwd`; chomp($root); my $cmd=".$root/testdir/ft_623.sh 3 4 5 6 7"; print $cmd; my @line=`$cmd`; foreach (@line){ print $_; } ft_623.sh (0 Replies)
Discussion started by: Damon sine
0 Replies

9. Shell Programming and Scripting

Question about argument parsing in scripts

Hello all, I am relatively new to linux and bash scripting. I have what seems to be a simple question but I'm having trouble finding the answer. The question is what is the difference between the variables $@ and $*. I've seen them both used in the same context, and I've tried a number of... (4 Replies)
Discussion started by: nicthu
4 Replies

10. Shell Programming and Scripting

parsing argument in perl

in bash: LIST=`cat $1` for i in $LIST do ... done how will i do this in perl ? $1 is my first arguement. I'm a newbie in perl and will appreciate much your help guys ... (4 Replies)
Discussion started by: linuxgeek
4 Replies
Locale::Codes::LangExt(3pm)				 Perl Programmers Reference Guide			       Locale::Codes::LangExt(3pm)

NAME
Locale::Codes::LangExt - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangExt; $lext = code2langext('acm'); # $lext gets 'Mesopotamian Arabic' $code = langext2code('Mesopotamian Arabic'); # $code gets 'acm' @codes = all_langext_codes(); @names = all_langext_names(); DESCRIPTION
The "Locale::Codes::LangExt" module provides access to standard codes used for identifying language extensions, such as those as defined in the IANA language registry. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default IANA language registry codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language extensions. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langext('acm','alpha'); $lext = code2langext('acm',LOCALE_LANGEXT_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from the IANA language registry, such as 'acm' for Mesopotamian Arabic. This is the default code set. ROUTINES
code2langext ( CODE [,CODESET] ) langext2code ( NAME [,CODESET] ) langext_code2code ( CODE ,CODESET ,CODESET2 ) all_langext_codes ( [CODESET] ) all_langext_names ( [CODESET] ) Locale::Codes::LangExt::rename_langext ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangExt::add_langext ( CODE ,NAME [,CODESET] ) Locale::Codes::LangExt::delete_langext ( CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_alias ( NAME ,NEW_NAME ) Locale::Codes::LangExt::delete_langext_alias ( NAME ) Locale::Codes::LangExt::rename_langext_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::delete_langext_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.iana.org/assignments/language-subtag-registry The IANA language subtag registry. AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2012 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.2 2012-10-11 Locale::Codes::LangExt(3pm)
All times are GMT -4. The time now is 05:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy