Sponsored Content
Top Forums Shell Programming and Scripting perl: Assigning array values.. Post 302214749 by KevinADC on Monday 14th of July 2008 07:31:17 PM
Old 07-14-2008
'unshift' adds to the beginning of an array, 'push' adds to the end of an array.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Assigning values to an array

The way I've been using arrays currently have been: #!/bin/ksh set -A myArray myArray=value1 myArray=value2 myArray=value3 myArray=value4 Is there a way I can assign values to an array that will automatically place the value into the next element in the array like: myArray=value1... (4 Replies)
Discussion started by: yongho
4 Replies

2. Shell Programming and Scripting

Assigning the values to an Array

hi every body, i donot know how to assign a array varible with a file see i having file more file property1 Name property2 Address the above two line are tab Space seperated between the property and its value i want to seperate it and assign to... (1 Reply)
Discussion started by: kkraja
1 Replies

3. Shell Programming and Scripting

Perl: array, assigning multi-word sentences with quotes

Just wondering if there's a better way to get these complete sentences into an array and keep the quotes intact? All the quotes make it look ugly to me but it works. I want to be able to refer to the full sentences by index. I've tried a few qw and qq/ aproaches but what I have below seems about... (4 Replies)
Discussion started by: gctaylor
4 Replies

4. Shell Programming and Scripting

Assigning values to an array via for/while loop

I need to do something like this: for i in 1 2 3 4 5; do arr=$(awk 'NR="$i" { print $2 }' file_with_5_records) done That is, parse a file and assign values to an array in an ascending order relative to the number of record in the file that is being processed on each loop. Is my... (2 Replies)
Discussion started by: fiori_musicali
2 Replies

5. Shell Programming and Scripting

perl -write values in a file to @array in perl

Hi can anyone suggest me how to write a file containing values,... say 19 20 21 22 .. 40 to an array @array = (19, 20, ... 40) -- Thanks (27 Replies)
Discussion started by: meghana
27 Replies

6. Shell Programming and Scripting

Assigning values for a dynamic array for an input

Hello, Can somebody please give me a snippet for the below requirement. I want to assign the values separeted by a comma to be assigned to a dynamic array. If I give an input (read statement) like abc1,abc2,abc3,abc4,abc5, all these strings abc* should be assigned to an array like below... (2 Replies)
Discussion started by: suneelj
2 Replies

7. Shell Programming and Scripting

Reading from a file and assigning to an array in perl

I wrote a simply perl that searched a file for a particualr value and if it found it, rite it and the next three lines to a file. Now I have been asked to check those next three lines for a different value and only write those lines if it finds the second value. I was thinking the best way to... (1 Reply)
Discussion started by: billprice13
1 Replies

8. Shell Programming and Scripting

Assigning array values using awk in shell scripting

hi My script as below #!/bin/ksh for i in `seq 1 7` do a=$(awk '{print $i}' /home/rama/expenese.txt) done for i in `seq 1 7` do echo "${a}" done content of expense.txt is as below 5032 210179 3110 132813874 53488966 11459221 5300794 I want output as... (6 Replies)
Discussion started by: Ramakrishna V
6 Replies

9. Shell Programming and Scripting

Assigning Column Values to ARRAY in ksh

Hi , i have file which is having two fields in it (#delimited) ABC#FILE_01.DAT DEF#FILE_02.DAT i want to write first field values to one array example A_01 and second field values to B_02 array please let me know how to do this ,my final requirement i have send out a mail for each record... (2 Replies)
Discussion started by: kkabc789
2 Replies

10. Shell Programming and Scripting

Perl : Assigning multile hash values to a single array

I know that @food = %fruit; Works. But how do I assign %fruit and %veggies to @food ? (2 Replies)
Discussion started by: popeye
2 Replies
arybase(3pm)						 Perl Programmers Reference Guide					      arybase(3pm)

NAME
arybase - Set indexing base via $[ SYNOPSIS
$[ = 1; @a = qw(Sun Mon Tue Wed Thu Fri Sat); print $a[3], " "; # prints Tue DESCRIPTION
This module implements Perl's $[ variable. You should not use it directly. Assigning to $[ has the compile-time effect of making the assigned value, converted to an integer, the index of the first element in an array and the first character in a substring, within the enclosing lexical scope. It can be written with or without "local": $[ = 1; local $[ = 1; It only works if the assignment can be detected at compile time and the value assigned is constant. It affects the following operations: $array[$element] @array[@slice] $#array (list())[$slice] splice @array, $index, ... each @array keys @array index $string, $substring # return value is affected pos $string substr $string, $offset, ... As with the default base of 0, negative bases count from the end of the array or string, starting with -1. If $[ is a positive integer, indices from "$[-1" to 0 also count from the end. If $[ is negative (why would you do that, though?), indices from $[ to 0 count from the beginning of the string, but indices below $[ count from the end of the string as though the base were 0. Prior to Perl 5.16, indices from 0 to "$[-1" inclusive, for positive values of $[, behaved differently for different operations; negative indices equal to or greater than a negative $[ likewise behaved inconsistently. HISTORY
Before Perl 5, $[ was a global variable that affected all array indices and string offsets. Starting with Perl 5, it became a file-scoped compile-time directive, which could be made lexically-scoped with "local". "File-scoped" means that the $[ assignment could leak out of the block in which occurred: { $[ = 1; # ... array base is 1 here ... } # ... still 1, but not in other files ... In Perl 5.10, it became strictly lexical. The file-scoped behaviour was removed (perhaps inadvertently, but what's done is done). In Perl 5.16, the implementation was moved into this module, and out of the Perl core. The erratic behaviour that occurred with indices between -1 and $[ was made consistent between operations, and, for negative bases, indices from $[ to -1 inclusive were made consistent between operations. BUGS
Error messages that mention array indices use the 0-based index. "keys $arrayref" and "each $arrayref" do not respect the current value of $[. SEE ALSO
"$[" in perlvar, Array::Base and String::Base. perl v5.18.2 2014-01-06 arybase(3pm)
All times are GMT -4. The time now is 12:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy