Hello,
I have a comma delimited input feed file. The first field has directory location and the second field has file name.
Ex of input feed:
/export/appl/a,abc*.dat
/export/appl/b,xyz*.dat
/export/appl/c,pmn*.dat
Under each directory, there would be many files like...
.
.
.... (4 Replies)
I am trying to use a script to replace the header of each file, whose filename are stored within the array $test, using the sed command within a Perl script as follows:
$count = 0;
while ( $count < $#test )
{
`sed -e 's/BIOGRF 321/BIOGRF 332/g' ${test} > 0`;
`cat 0 >... (2 Replies)
Hi,
My doubt is how to access array elements..
Situation is as below:
#!/bin/ksh
set -x
typeset -i x=0
typeset -i y=0
typeset -i BID=0
typeset -i count=0
while ] ; do
x=`expr $x + 1`;
hwmgr show scsi > scsi.tmp
while read line; do
set... (1 Reply)
I need to use array elements while pattern matching.
@myarr = (ELEM1, ELEM2, ELEM3);
following is the statement which I am using in my code. Basically I want to replace the ELEM1/2/3 with other thing which is mentioned as REPL here.
if (condition) {
s/(ELEM1|ELEM2|ELEM3): REPL: /;
}
I... (3 Replies)
How can I get my array to understand the double-quotes I'm passing into it are to separate text strings and not part of an element? here's what I'm working with...
db2 -v connect to foo
db2 -x "select '\"' || stats_command || '\",' from db2law1.parallel_runstats where tabname = 'BAZ'"
set... (4 Replies)
Hello,
I have the following perl array:
@longname = (Fasthernet0/0 Fasthernet0/1 Serial0/1/0 Serial0/2/1 Tunnel55 Tunnel77)
with the followinh array:
@shortname = (Fa0/0 Fa0/1 Se0/1/0 Se0/2/1 Tu55 Tu77)
in other words, I need to remove the following from each element in the array... (4 Replies)
Hi I have two arrays :
@arcb= (450,625,720,645);
@arca=(625,645);
I need to remove the elements of @arca from elements of @arcb so that the content of @arcb will be (450,720).
Can anyone sugget me how to perform this operation?
The code I have used is this :
my @arcb=... (3 Replies)
Hi
I wanted to print random elements from an array at bash shell
I use the following code, but I always see first element getting printed
#!/bin/bash
c=1
expressions=(pink red white yellow purple)
while ]; do
echo "The value of RANDOM is $RANDOM"
selectedexpression=${expressions}]};... (5 Replies)
Hi All,
need help with reading the array and sum of the array elements.
given an array of integers of size N . You need to print the sum of the elements in the array, keeping in mind that some of those integers may be quite large.
Input Format
The first line of the input consists of an... (1 Reply)
I have an array code and output is below:
echo $1
while read -r fline; do
echo "%%%%%%$fline%%%%%"
fmy_array+=("$fline")
done <<< "$1"
Output:
CR30903 YU0007 SRIL CR30903 Yogesh SRIL
%%%%%%CR30903 YU0007 SRIL%%%%%
%%%%%%CR30903 Yogesh SRIL%%%%%
... (8 Replies)
Discussion started by: mohtashims
8 Replies
LEARN ABOUT PHP
uasort
UASORT(3) 1 UASORT(3)uasort - Sort an array with a user-defined comparison function and maintain index associationSYNOPSIS
bool uasort (array &$array, callable $value_compare_func)
DESCRIPTION
This function sorts an array such that array indices maintain their correlation with the array elements they are associated with, using a
user-defined comparison function.
This is used mainly when sorting associative arrays where the actual element order is significant.
Note
If two members compare as equal, their relative order in the sorted array is undefined.
PARAMETERS
o $array
- The input array.
o $value_compare_func
- See usort(3) and uksort(3) for examples of user-defined comparison functions.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
Basic uasort(3) example
<?php
// Comparison function
function cmp($a, $b) {
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
}
// Array to be sorted
$array = array('a' => 4, 'b' => 8, 'c' => -1, 'd' => -9, 'e' => 2, 'f' => 5, 'g' => 3, 'h' => -4);
print_r($array);
// Sort and print the resulting array
uasort($array, 'cmp');
print_r($array);
?>
The above example will output:
Array
(
[a] => 4
[b] => 8
[c] => -1
[d] => -9
[e] => 2
[f] => 5
[g] => 3
[h] => -4
)
Array
(
[d] => -9
[h] => -4
[c] => -1
[e] => 2
[g] => 3
[a] => 4
[f] => 5
[b] => 8
)
SEE ALSO usort(3), The comparison of array sorting functions.
PHP Documentation Group UASORT(3)