I've got a perl script that I'm having a problem with when it prints the output of a hash. Some background. I'm trying to merge two file with a similar structure but with different data. Here is a portion of the script I'm using.
My input file looks like this with their relevant hashes hierarchy
SSMC_1 - This is $sScenario
,,,0,, - These are $sTime
,,,1,,
,,,3,, - SSMC_2 -> Sequence repeated again - This is $sScenario
,,,0,, - These are $sTime
,,,1,,
,,,3,, - SSMC_10
..
SSMC_11
But when I print the the output, it looks like this
Sorting the time hash works fine but the scenario, (line underlined in bold above) doesn't. I'm not sure if it's because it's an alpha-numeric hence why the sort doesn't work. Tried googling but to no avail and I'm at a loss
Thanks in advance
---------- Post updated at 04:05 PM ---------- Previous update was at 11:41 AM ----------
This problem has been solved. Thanks for those who had a look.
I simply removed the characters
$sScenario =~ s/SSMC_//g;
How could i take an input file and split the numeric values from the alpha values (123 vs abc) to distinc columns, and if the source is blank to keep it blank (null) in both of the new columns:
So if the source file had a column like:
Value:
|1 |
|2.3|
| |
|No|
I would... (7 Replies)
I have a file which looks roughly like this:
996 mmmmmmm
996 xxxxxxxxxxxxx
99600 ssssssssss
9964 fffffffffffff
and would like to sort it numerically on the first field. I tried:
sort -nr --key=1 ....
The output I get is:
99600 ssssssssss
9964 ... (3 Replies)
Hi,
I have an hashes of hash, where hash is dynamic, it can be n number of hash. i need to compare data_count values of all .
my %result (
$abc => {
'data_count' => '10',
'ID' => 'ABC122',
}
$def => {
'data_count' => '20',
'ID' => 'defASe',
... (1 Reply)
Hi Folks
I am very much a newbie at perl but picking it up and I'm hoping you can help.
I have a file input that details all the /etc/group files in our enterprise in the following format: "<host>:<group>:<gid>:<users>"
I want to parse this data display it as the following:... (9 Replies)
hi all,
i have a small problem regarding sorting the keys in a hash.
my %hash;
for($i=0;$i<19;$i++)
{
$hash{$i}=$i;
}
foreach $c (sort keys %hash)
{
print "\n $hash{$c}";
} (1 Reply)
Hi,
I would like to do the following sorting, but the output is not what i expected. Why 222 and 2222 are not at the last two elements of array?
awk 'BEGIN{a="22";a="2222";a="33";a="44";a="222";a="11";a="22";a="33";asort(a); for (i=1;i<=8;i++) print a}'
11
22
22
222
2222
33
33
44... (1 Reply)
Hi all.
This is one of my interview question.
input : apple
output :
a - 1
p - 2
l - 1
e - 1
i written the code like this
echo "apple" | fold -w1 | sort | uniq -c | awk '{print $2 "-->" $1}'
is any other way to do ? (5 Replies)
Data I want to sort :-
1 10 jj Y
2 100 vv B
19 5 jj A
1 11 hq D
3 8 op X
44 78 ds GG
1 8 hq D
and want to sort based on the first 2 columns - which hold numeric values.
Am using :
cat filename | sort -nk 1,2
But the result is :-
1 10 jj Y
1 11 hq D (1 Reply)
i've reworked some code from an earlier post, and it isn't working as expected
i've simplified it to try and find the problem. i spent hours trying to figure out what is wrong, eventually thinking there was a bug in perl or a problem with my computer. but, i've tried it on 3 machines with the... (5 Replies)
I am working on a shell program that needs to accept alpha-numeric input (i.e., P00375); when I use a simple 'read' statement to read in the input (i.e., read LOG), I receive the message "p00375: bad number". How must I adjust my input statement to accept alpha-numerics?
Thanks!
Brent (3 Replies)