Sponsored Content
Top Forums Shell Programming and Scripting Perl - if conditions is meet, push the last field of $_ into an array Post 302266547 by popeye on Wednesday 10th of December 2008 01:16:35 PM
Old 12-10-2008
This works ... but it just seems that there is a better way ..
if ($_ =~ /\s\b[5-9]\./) {
@ip = split(/ /,$_);
push(@dos, $ip[4])};
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shift and push question in perl

hi, another perl question, I don't understand the below while (<FILE>) { push @last5, $_; #add to the end shift @last5 if @last5 > 5 ; #take from the beginning } can someone please explain to me how does shift @last5 if @last5 > 5 is taking last 5 lines from... (5 Replies)
Discussion started by: hankooknara
5 Replies

2. Shell Programming and Scripting

PERL, push to hash of array problem

$key = "a"; $value = "hello"; %myhash = {} ; push @{ myHash{$key} }, $hello; print $myHash{$key}."\n"; this script prints "hello" but has following error message. Reference found where even-sized list expected at ./test line 5. can any one help me to fix this problem?? (3 Replies)
Discussion started by: bonosungho
3 Replies

3. Shell Programming and Scripting

Push records to array during implicit loop and write to file

NEWBIE ALERT! Hi, I'm 1 month into learning Perl and done reading "Minimal Perl" by Tim Maher (which I enjoyed enoumously). I'm not a programmer by profession but want to use Perl to automate various tasks at my job. I have a problem (obviously) and are looking for your much appreciated help.... (0 Replies)
Discussion started by: jospan
0 Replies

4. Shell Programming and Scripting

perl sort array by field

Hi Everyone, Any simple code can simplify the code below, please advice. Thanks # cat 2.pl #!/usr/bin/perl use warnings; use strict; my @aaaaa = <DATA>; my @uids; foreach (@aaaaa) { my @ccccc = split (",", $_); push @uids, $ccccc;... (3 Replies)
Discussion started by: jimmy_y
3 Replies

5. Shell Programming and Scripting

perl, put one array into many array when field is equal to sth

Hi Everyone, #!/usr/bin/perl use strict; use warnings; my @test=("a;b;qqq;c;d","a;b;ggg;c;d","a;b;qqq;c;d"); would like to split the @test array into two array: @test1=(("a;b;qqq;c;d","a;b;qqq;c;d"); and @test2=("a;b;ggg;c;d"); means search for 3rd filed. Thanks find the... (0 Replies)
Discussion started by: jimmy_y
0 Replies

6. Shell Programming and Scripting

perl sum 2nd field in an array

Hi Everyone, ($total+=$_) for @record; assume @record=(1,2,3), so the result is 6. if @record=("1 3","2 3","3 3"), would like to sum up the 2nd field of this array, the result is 9. i tried " ($total+=$) for @record ", cannot, please advice. Thanks ---------- Post updated at 03:45... (1 Reply)
Discussion started by: jimmy_y
1 Replies

7. Shell Programming and Scripting

Perl - use search keywords from array and search a file and print 3rd field when matched

Hi , I have been trying to write a perl script to do this job. But i am not able to achieve the desired result. Below is my code. my $current_value=12345; my @users=("bob","ben","tom","harry"); open DBLIST,"<","/var/tmp/DBinfo"; my @input = <DBLIST>; foreach (@users) { my... (11 Replies)
Discussion started by: chidori
11 Replies

8. Programming

Javascript issue: array.push

I have a code snippet here that is supposed to vary values of certain parameter values: <script type="text/javascript"> // dynamic array of which its ultimate size is unknown // an array of arrays, each consisting of one variation var variations = ; // parameters of how to create a... (0 Replies)
Discussion started by: figaro
0 Replies

9. Shell Programming and Scripting

Print header and lines that meet both conditions in awk

In the awk below I am trying to print only the header lines starting with # or ## and the lines that $7 is PASS and AF= is less than 5%. The awk does execute but returns an empty file and I am not sure what I am doing wrong. Thank you. file ... (0 Replies)
Discussion started by: cmccabe
0 Replies

10. Shell Programming and Scripting

awk to print lines that meet conditions and have value in another file

I am trying to use awk to print lines that satisfy either of the two conditions below: condition 1: $2 equals CNV and the split of $3, the value in red, is greater than or equal to 4. ---- this is a or so I think condition 2: $2 equals CNV and the split of $3, the value in red --- this is a... (4 Replies)
Discussion started by: cmccabe
4 Replies
Devel::Symdump(3pm)					User Contributed Perl Documentation				       Devel::Symdump(3pm)

NAME
Devel::Symdump - dump symbol names or the symbol table SYNOPSIS
# Constructor require Devel::Symdump; @packs = qw(some_package another_package); $obj = Devel::Symdump->new(@packs); # no recursion $obj = Devel::Symdump->rnew(@packs); # with recursion # Methods @array = $obj->packages; @array = $obj->scalars; @array = $obj->arrays; @array = $obj->hashes; @array = $obj->functions; @array = $obj->filehandles; # deprecated, use ios instead @array = $obj->dirhandles; # deprecated, use ios instead @array = $obj->ios; @array = $obj->unknowns; # only perl version < 5.003 had some $string = $obj->as_string; $string = $obj->as_HTML; $string = $obj1->diff($obj2); $string = Devel::Symdump->isa_tree; # or $obj->isa_tree $string = Devel::Symdump->inh_tree; # or $obj->inh_tree # Methods with autogenerated objects # all of those call new(@packs) internally @array = Devel::Symdump->packages(@packs); @array = Devel::Symdump->scalars(@packs); @array = Devel::Symdump->arrays(@packs); @array = Devel::Symdump->hashes(@packs); @array = Devel::Symdump->functions(@packs); @array = Devel::Symdump->ios(@packs); @array = Devel::Symdump->unknowns(@packs); DESCRIPTION
This little package serves to access the symbol table of perl. "Devel::Symdump->rnew(@packages)" returns a symbol table object for all subtrees below @packages. Nested Modules are analyzed recursively. If no package is given as argument, it defaults to "main". That means to get the whole symbol table, just do a "rnew" without arguments. The global variable $Devel::Symdump::MAX_RECURSION limits the recursion to prevent contention. The default value is set to 97, just low enough to survive the test suite without a warning about deep recursion. "Devel::Symdump->new(@packages)" does not go into recursion and only analyzes the packages that are given as arguments. packages, scalars, arrays, hashes, functions, ios The methods packages(), scalars(), arrays(), hashes(), functions(), ios(), and (for older perls) unknowns() each return an array of fully qualified symbols of the specified type in all packages that are held within a Devel::Symdump object, but without the leading "$", "@" or "%". In a scalar context, they will return the number of such symbols. Unknown symbols are usually either formats or variables that haven't yet got a defined value. as_string as_HTML As_string() and as_HTML() return a simple string/HTML representations of the object. diff Diff() prints the difference between two Devel::Symdump objects in human readable form. The format is similar to the one used by the as_string method. isa_tree inh_tree Isa_tree() and inh_tree() both return a simple string representation of the current inheritance tree. The difference between the two methods is the direction from which the tree is viewed: top-down or bottom-up. As I'm sure, many users will have different expectation about what is top and what is bottom, I'll provide an example what happens when the Socket module is loaded: % print Devel::Symdump->inh_tree AutoLoader DynaLoader Socket DynaLoader Socket Exporter Carp Config Socket The inh_tree method shows on the left hand side a package name and indented to the right the packages that use the former. % print Devel::Symdump->isa_tree Carp Exporter Config Exporter DynaLoader AutoLoader Socket Exporter DynaLoader AutoLoader The isa_tree method displays from left to right ISA relationships, so Socket IS A DynaLoader and DynaLoader IS A AutoLoader. (Actually, they were at the time this manpage was written) You may call both methods, isa_tree() and inh_tree(), with an object. If you do that, the object will store the output and retrieve it when you call the same method again later. The typical usage would be to use them as class methods directly though. SUBCLASSING
The design of this package is intentionally primitive and allows it to be subclassed easily. An example of a (maybe) useful subclass is Devel::Symdump::Export, a package which exports all methods of the Devel::Symdump package and turns them into functions. AUTHORS
Andreas Koenig <andk@cpan.org> and Tom Christiansen <tchrist@perl.com>. Based on the old dumpvar.pl by Larry Wall. COPYRIGHT, LICENSE This module is Copyright (c) 1995, 1997, 2000, 2002, 2005, 2006 Andreas Koenig "<andk@cpan.org>". All rights reserved. This library is free software; you may use, redistribute and/or modify it under the same terms as Perl itself. perl v5.10.1 2008-04-01 Devel::Symdump(3pm)
All times are GMT -4. The time now is 12:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy