Sponsored Content
Homework and Emergencies Homework & Coursework Questions Need help with a Perl Script using Pop, Shift, & Push Post 302707499 by Hax0rc1ph3r on Friday 28th of September 2012 04:57:21 PM
Old 09-28-2012
Corona688,

Thank you! That has been a great help to getting the start that I needed. I had worked with splitting the original array, but then had my loops becoming way too complicated and then they weren't running correctly.
 

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

search & replace password perl script

I wanted a perl script to be done for Password search & replace in two files. For Example: Example 1)--i am having a file such as cat /opt/customer/Ariba/UAT/ariba/app/buyer/Server/config/Parameters.table Example 2)--and i am having a other file in other location such as cat... (4 Replies)
Discussion started by: shellscript22
4 Replies

3. Shell Programming and Scripting

Perl - if conditions is meet, push the last field of $_ into an array

I am using a seed file shown below to separate cisco devices by ios/os type. I want to bunch all the devices based on ios/os version. Once I find a match, I only want to push the ip address into the appropriate array. Example of seedfile 8 host1 (C3500XL-C3H2S-M) 11.0(5)WC17 10.1.44.21 9... (1 Reply)
Discussion started by: popeye
1 Replies

4. Shell Programming and Scripting

Shift Question (Perl)

I am attempting to write a script that reads each line of a file into a separate array and does some work on it then puts it all back together and I think I need to use the 'shift()' command to read each line into its own array, but I need help nesting it into a while loop (while not eof) So... (10 Replies)
Discussion started by: ifeatu
10 Replies

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

6. Shell Programming and Scripting

push and pop directories and subdirectories

I need to use pushd and popd to navigate all of the subdirectories in my current directory. I know how to get into each subdirectory, add it to the stack, and pop back out, but i cant figure out how to get into subdirectories deeper than the first without adding a foreach and if statement for... (1 Reply)
Discussion started by: ollie88r
1 Replies

7. UNIX for Dummies Questions & Answers

Setup a push script from NIS

Hi guys, can we get a pushed script for every NIS client like a policy.? I need to set a symbolic links for for every client. Thanks ... (1 Reply)
Discussion started by: pianz
1 Replies

8. Shell Programming and Scripting

Help on a script to push files once a day

Hello! Please I need some help on writing a script to push files from one server to the other once a day, everyday. I know that I can use this script on a crontab to send the files , but I am not sure how to start writing it, the actual script. I could start by declaring some variables: ... (4 Replies)
Discussion started by: fretagi
4 Replies

9. Web Development

Pop up confirmation box / perl cgi

Hi, I need to add confirmation pop up msg box before deleting the record from database, I have added following snippets to my code but its not working for me, your help will be much appreciated : print header; print <<EOF; <script type="text/javascript"> function confirmOk() { return... (0 Replies)
Discussion started by: terrykhatri531
0 Replies

10. Shell Programming and Scripting

Script to Push Files

Hey Guys, Thanks for always being helpful, I have another issue that I need a little insight on how to fix. See the below script I have and the error I get. I don't understand why it does that, am I not using the continue correctly? #!/bin/bash -x # @(#) File: filepush.sh #... (5 Replies)
Discussion started by: gkelly1117
5 Replies
MakeMethods::Utility::ArraySplicer(3pm) 		User Contributed Perl Documentation		   MakeMethods::Utility::ArraySplicer(3pm)

NAME
Class::MakeMethods::Utility::ArraySplicer - Common array ops SYNOPSIS
use Class::MakeMethods::Utility::ArraySplicer; # Get one or more values $value = array_splicer( $array_ref, $index ); @values = array_splicer( $array_ref, $index_array_ref ); # Set one or more values array_splicer( $array_ref, $index => $new_value, ... ); # Splice selected values in or out array_splicer( $array_ref, [ $start_index, $end_index], [ @values ]); DESCRIPTION
This module provides a utility function and several associated constants which support a general purpose array-splicer interface, used by several of the Standard and Composite method generators. array_splicer This is a general-purpose array accessor function. Depending on the arguments passed to it, it will get, set, slice, splice, or otherwise modify your array. o If called without any arguments, returns the contents of the array in list context, or an array reference in scalar context (or undef). # Get all values $value_ref = array_splicer( $array_ref ); @values = array_splicer( $array_ref ); o If called with a single numeric argument, uses that argument as an index to retrieve from the referenced array, and returns that value (or undef). # Get one value $value = array_splicer( $array_ref, $index ); o If called with a single array ref argument, sets the contents of the array to match the contents of the provided one. # Set contents of array array_splicer( $array_ref, [ $value1, $value2, ... ] ); # Reset the array contents to empty array_splicer( $array_ref, [] ); o If called with a two arguments, the first undefined and the second an array ref argument, uses that array's contents as a list of indexes to return a slice of the referenced array. # Get slice of values @values = array_splicer( $array_ref, undef, [ $index1, $index2, ... ] ); o If called with a list of argument pairs, each with a numeric index and an associated value, stores the value at the given index in the referenced array. The current value in each position will be overwritten, and later arguments with the same index will override earlier ones. Returns the current array-ref value. # Set one or more values by index array_splicer( $array_ref, $index1 => $value1, $index2 => $value2, ... ); o If called with a list of argument pairs, each with the first item being a reference to an array of up to two numbers, loops over each pair and uses those numbers to splice the value array. # Splice selected values in or out array_splicer( $array_ref, [ $start_index, $count], [ @values ]); The first controlling number is the position at which the splice will begin. Zero will start before the first item in the list. Negative numbers count backwards from the end of the array. The second number is the number of items to be removed from the list. If it is omitted, or undefined, or zero, no items are removed. If it is a positive integer, that many items will be returned. If both numbers are omitted, or are both undefined, they default to containing the entire value array. If the second argument is undef, no values will be inserted; if it is a non-reference value, that one value will be inserted; if it is an array-ref, its values will be copied. The method returns the items that removed from the array, if any. Here are some examples of common splicing operations. # Insert an item at position in the array $obj->bar([3], 'Potatoes' ); # Remove 1 item from position 3 in the array $obj->bar([3, 1], undef ); # Set a new value at position 2, and return the old value print $obj->bar([2, 1], 'Froth' ); # Unshift an item onto the front of the list array_splicer( $array_ref, [0], 'Bubbles' ); # Shift the first item off of the front of the list print array_splicer( $array_ref, [0, 1], undef ); # Push an item onto the end of the list array_splicer( $array_ref, [undef], 'Bubbles' ); # Pop the last item off of the end of the list print array_splicer( $array_ref, [undef, 1], undef ); Constants There are also constants symbols to facilitate some common combinations of splicing arguments: # Reset the array contents to empty array_splicer( $array_ref, array_clear ); # Set the array contents to provided values array_splicer( $array_ref, array_splice, [ 2, 3 ] ); # Unshift an item onto the front of the list array_splicer( $array_ref, array_unshift, 'Bubbles' ); # Shift it back off again print array_splicer( $array_ref, array_shift ); # Push an item onto the end of the list array_splicer( $array_ref, array_push, 'Bubbles' ); # Pop it back off again print array_splicer( $array_ref, array_pop ); SEE ALSO
See Class::MakeMethods for general information about this distribution. See Class::MakeMethods::Standard::Hash and numerous other classes for examples of usage. perl v5.10.1 2004-09-06 MakeMethods::Utility::ArraySplicer(3pm)
All times are GMT -4. The time now is 05:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy