Sponsored Content
Full Discussion: Perl nested array problem
Top Forums Shell Programming and Scripting Perl nested array problem Post 302442403 by karthigayan on Wednesday 4th of August 2010 06:16:24 AM
Old 08-04-2010
I know Data:: Dumper.I asked the way for traversing .
 

10 More Discussions You Might Find Interesting

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

2. Shell Programming and Scripting

Nested foreach in perl

I have two arrays @nextArray contains some files like \main\1\Xul.xml@@\main\galileo_integration_sjc\0 \main\1\PortToStorageDialog.xml@@\main\galileo_integration_sjc\0 . . . \main\1\PreferencesDialog.xml@@\main\galileo_integration_sjc\0 @otherArray contains some files like ... (2 Replies)
Discussion started by: nmattam
2 Replies

3. Shell Programming and Scripting

PHP: Search Multi-Dimensional(nested) array and export values of currenly worked on array.

Hi All, I'm writing a nagios check that will see if our ldap servers are in sync... I got the status data into a nested array, I would like to search key of each array and if "OK" is NOT present, echo other key=>values in the current array to a variable so...eg...let take the single array... (1 Reply)
Discussion started by: zeekblack
1 Replies

4. Shell Programming and Scripting

Perl and string array problem

#!/usr/bin/perl my @arr=("hello", "how", "are", "you"); $l=length(@arr); print $l; This print 1.Why? How can i print the array size = 4? I want to store these in an array. hello how are you And then i want to access these element through indexing. How can i do this? (4 Replies)
Discussion started by: cola
4 Replies

5. Shell Programming and Scripting

Perl - nested substitutions

How can I nest substitutions ? My solution just seems cheap ... sample data Cisco Catalyst Operating System Software, Version 235.5(18) Cisco Catalyst Operating System Software, Version 17.6(7) Cisco Catalyst Operating System Software, Version 19.6(7) Cisco Catalyst Operating System... (1 Reply)
Discussion started by: popeye
1 Replies

6. Shell Programming and Scripting

[Perl] Strange problem with array

Hi, I have a strange problem with arrays in Perl. That is to say, for me it is strange and perhaps there is a special reason for it that I do not know of. Not a real Perl Ace. This is the program, as an example: #!/usr/bin/perl -w #-d use strict; my $pu; my $pu_list_cmd; my... (2 Replies)
Discussion started by: ejdv
2 Replies

7. Shell Programming and Scripting

Perl nested if statement

I'm just having a bit of trouble running this code. It tells me that there's a syntax error on line 29. Any help appreciated. #!/usr/bin/perl # # Phone Book Application # %phonebook = ( "Wayne", '34687368', "Home", '378643287', "Work", '017374637', "School",... (2 Replies)
Discussion started by: cabaiste
2 Replies

8. Shell Programming and Scripting

Perl- Nested 'for' order change

Hello, I'm quite new to perl so my question is rather basic and I know there is probably a simple way around it but I can't seem to find it. I have a medium-length code and there is a part that works with a nested for loop: foreach my $j(@primpiddelta){ for (my $k=1;... (0 Replies)
Discussion started by: acsg
0 Replies

9. Shell Programming and Scripting

Attempting to pass my array as a nested parameter to loop. A little lost.

I want to pass this array as a parameter. IFS=$'\n' fortune_lines=($(fortune | fold -w 30 )) Inside of this line screen -p 0 -S ${SCREEN_SESSION} -X stuff "`printf "say ${fortune_lines}\r"`" And I am lost at this point. I am thinking something like this? Then make it loop.. ... (7 Replies)
Discussion started by: briandanielz
7 Replies

10. Shell Programming and Scripting

Fastest alternatives to flattening a non-uniform nested array with regex?

Hello, I'm looking at simplfying a function that flattens an array, it uses recursion and filters objects by type but this seems to be a waste of resources to me at least, using conditionals like this seems like a bad idea. The array can be a generic type, int, string, float but not some... (2 Replies)
Discussion started by: f77hack
2 Replies
Data::Visitor::Callback(3pm)				User Contributed Perl Documentation			      Data::Visitor::Callback(3pm)

NAME
Data::Visitor::Callback - A Data::Visitor with callbacks. VERSION
version 0.28 SYNOPSIS
use Data::Visitor::Callback; my $v = Data::Visitor::Callback->new( # you can provide callbacks # $_ will contain the visited value value => sub { ... }, array => sub { ... }, # you can also delegate to method names # this specific example will force traversal on objects, by using the # 'visit_ref' callback which normally traverse unblessed references object => "visit_ref", # you can also use class names as callbacks # the callback will be invoked on all objects which inherit that class 'Some::Class' => sub { my ( $v, $obj ) = @_; # $v is the visitor ... }, ); $v->visit( $some_perl_value ); DESCRIPTION
This is a Data::Visitor subclass that lets you invoke callbacks instead of needing to subclass yourself. METHODS
new %opts, %callbacks Construct a new visitor. The options supported are: ignore_return_values When this is true (off by default) the return values from the callbacks are ignored, thus disabling the fmapping behavior as documented in Data::Visitor. This is useful when you want to modify $_ directly tied_as_objects Whether ot not to visit the "tied" in perlfunc of a tied structure instead of pretending the structure is just a normal one. See "visit_tied" in Data::Visitor. CALLBACKS
Use these keys for the corresponding callbacks. The callback is in the form: sub { my ( $visitor, $data ) = @_; # or you can use $_, it's aliased return $data; # or modified data } Within the callback $_ is aliased to the data, and this is also passed in the parameter list. Any method can also be used as a callback: object => "visit_ref", # visit objects anyway visit Called for all values value Called for non objects, non container (hash, array, glob or scalar ref) values. ref_value Called after "value", for references to regexes, globs and code. plain_value Called after "value" for non references. object Called for blessed objects. Since "visit_object" in Data::Visitor will not recurse downwards unless you delegate to "visit_ref", you can specify "visit_ref" as the callback for "object" in order to enter objects. It is reccomended that you specify the classes (or base classes) you want though, instead of just visiting any object forcefully. Some::Class You can use any class name as a callback. This is colled only after the "object" callback. If the object "isa" the class then the callback will fire. These callbacks are called from least derived to most derived by comparing the classes' "isa" at construction time. object_no_class Called for every object that did not have a class callback. object_final The last callback called for objects, useful if you want to post process the output of any class callbacks. array Called for array references. hash Called for hash references. glob Called for glob references. scalar Called for scalar references. tied Called on the return value of "tied" for all tied containers. Also passes in the variable as the second argument. seen Called for a reference value encountered a second time. Passes in the result mapping as the second argument. AUTHORS
o Yuval Kogman <nothingmuch@woobling.org> o Marcel Gruenauer <marcel@cpan.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Yuval Kogman. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-02-12 Data::Visitor::Callback(3pm)
All times are GMT -4. The time now is 06:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy