Sponsored Content
Full Discussion: parsing argument in perl
Top Forums Shell Programming and Scripting parsing argument in perl Post 302551654 by hfreyer on Wednesday 31st of August 2011 08:12:32 AM
Old 08-31-2011
Code:
while (<>) {
  chomp; split;
  foreach $i (@_) {
    ...
  }
}

If you want to get more familiar with perl, in any case it is recommendable to study the man pages (which in case of perl are very instructive), the most basic ones are:
perlrun, perlsyn, perldata, perlop, perlfunc (second level: perlsub, perlre, perlvar)
This User Gave Thanks to hfreyer For This Post:
 

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 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 ... (0 Replies)
Discussion started by: mingming88
0 Replies

8. 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

9. 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

10. 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
MouseX::NativeTraits::Str(3pm)				User Contributed Perl Documentation			    MouseX::NativeTraits::Str(3pm)

NAME
MouseX::NativeTraits::Str - Helper trait for Str attributes SYNOPSIS
package MyHomePage; use Mouse; has 'text' => ( traits => ['String'], is => 'rw', isa => 'Str', default => q{}, handles => { add_text => 'append', replace_text => 'replace', }, ); my $page = MyHomePage->new(); $page->add_text("foo"); # same as $page->text($page->text . "foo"); DESCRIPTION
This module provides a simple string attribute, to which mutating string operations can be applied more easily (no need to make an lvalue attribute metaclass or use temporary variables). Additional methods are provided for completion. PROVIDED METHODS
These methods are implemented in MouseX::NativeTraits::MethodProvider::Str. It is important to note that all those methods do in place modification of the value stored in the attribute. inc Increments the value stored in this slot using the magical string autoincrement operator. Note that Perl doesn't provide analogous behavior in "--", so "dec" is not available. append($string) Append a string, like ".=". prepend($string) Prepend a string. replace($pattern, $replacement) Performs a regexp substitution ("s" in perlop). A code references will be accepted for the replacement, causing the regexp to be modified with a single "e". "/smxi" can be applied using the "qr" operator. replace($pattern, $replacement) Performs a regexp substitution ("s" in perlop) with the "g" flag. A code references will be accepted for the replacement, causing the regexp to be modified with a single "e". "/smxi" can be applied using the "qr" operator. match($pattern) Like "replace" but without the replacement. Provided mostly for completeness. chop "chop" in perlfunc chomp "chomp" in perlfunc clear Sets the string to the empty string (not the value passed to "default"). length "length" in perlfunc substr "substr" in perlfunc. We go to some lengths to match the different functionality based on "substr"'s arity. METHODS
meta method_provider_class helper_type SEE ALSO
MouseX::NativeTraits perl v5.14.2 2011-12-04 MouseX::NativeTraits::Str(3pm)
All times are GMT -4. The time now is 09:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy