07-10-2008
Which shell? Or awk, Perl? 1 line = 1 Element? Need some more info on how your array should look like ie. how the input file looks like. Array by indices or association... ?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
Is it possible to create a dynamic array in shell script. I am trying to get the list of logfiles that created that day and put it in a dynamic array. I am not sure about it. help me
New to scripting
Gundu (3 Replies)
Discussion started by: gundu
3 Replies
2. Shell Programming and Scripting
Could one of you, please, provide some input regarding my problem below and it is as follows:
I have 2 files that I need to make sure are identical before processing:
First, I sort both files
Second, I do a diff file1 file2 > File 3
This provides me with the difference.
Now, I need to... (6 Replies)
Discussion started by: ddedic
6 Replies
3. Shell Programming and Scripting
Hello
I am trying to create a dynamic ksh script and I have an issue.
I have a script a.ksh and it has got the following lines (for example)
#!/bin/ksh
# trace mode +x : without trace -x : with trace
set +xv
echo hi, i am going to create a dynamic script now
cat >> dynamic.ks <<EOF... (2 Replies)
Discussion started by: sundarkumars
2 Replies
4. Programming
I am facing a strange error while creating posix threads:
Given below are two snippets of code, the first one works whereas the second one gives a garbage value in the output.
Snippet 1
This works:
--------------
int *threadids;
threadids = (int *) malloc (num_threads * sizeof(int));
... (4 Replies)
Discussion started by: kmehta
4 Replies
5. Shell Programming and Scripting
I'm fairly new to tcl scripting and could use a little help. I have a simple list file that will be of unknown size (somewhere between 10 to 20 names). I'd like to create a gui that has a checkbutton for each name in the list and a single action button that will do something for all the checkboxes... (0 Replies)
Discussion started by: scottwevans
0 Replies
6. Shell Programming and Scripting
I'm using the korn shell and trying to create a case statement from the contents of a file that is changed regularly,
each line of the file has three fields,
eg
track1 202.111.111.111 99
room7 222.111.222.333 76
I'm using awk to select each variable. I've been unable to figure out how to... (5 Replies)
Discussion started by: squrcles
5 Replies
7. Programming
Hi,
I have the following problem: i must allocate a dynamic array from a subroutine which should return such array to main function. The subroutine has already a return parameter so i thought of pass the array as I/O parameter. I tried the following program but it doesn't work (segmentation... (11 Replies)
Discussion started by: littleboyblu
11 Replies
8. Shell Programming and Scripting
Hi,
I got a requirement to automate the process.
We have SLA files, there are some 80 SLA files comes from 1.30pm - 5.30pm.
I was asked to write a script to check for the SLA files in the load directory, if the files come then we got to send the mail to the group, if the mails doesnt come... (1 Reply)
Discussion started by: afahmed
1 Replies
9. Web Development
Hey everyone. Thanks for looking at this.
I'm trying to create a table with the dynamic name of TableName + today's date.
My variables are all happily created but the system chokes when I try to create the new table name example:
Set @BFBW = CONCAT("BFBW", CURDATE());
Select @BFBW;
... (2 Replies)
Discussion started by: Astrocloud
2 Replies
10. Shell Programming and Scripting
Greetings all,
Been trying to do my Googling and forum searches but can't seem to lock in on a solution.
I have a script that parses a log and collects all the uniq events to a flat file. Some days might have 50 unique events, other days might have 75. (Hence my reference to dynamic.)
... (2 Replies)
Discussion started by: sjrupp
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.16.2 2012-10-11 arybase(3pm)