>
Thanks for all of you.
>
> my %abbrev;
>
> open my $fh, '<', 'try.txt';
>
>
> while(my $line = <$fh>) {
> chomp $line;
> my $abbr = join '', $line =~ /[A-Z]/g;
> $abbrev{$abbr} = $line;
Here I changed it to $abbrev{$line} = $abbre;
> }
>
> use Data::Dumper;
> print Data::Dumper->Dump([\%abbrev], ['*abbrev']);
>
> **OUTPUT**
>
> %abbrev = (
> 'CNSNDDT' => 'CNS Neurol Disord Drug Targets',
> 'NCB' => 'Nature Cell Biol.',
> 'IF' => 'Intermolecular Forces',
> 'NRMCB' => 'Nat. Rev. Mol. Cell Biol.',
> 'NN' => 'Nat. Neurosci.',
> 'ERMM' => 'Expert Reviews in Molecular Medicine.'
> );
OUTPUT:
%abbrev = (
'CNS Neurol Disord Drug Targets' => 'CNSNDDT',
'Intermolecular Forces' => 'IF',
'Expert Reviews in Molecular Medicine.' => 'ERMM',
'Nat. Neurosci.' => 'NN',
'Nat. Rev. Mol. Cell Biol.' => 'NRMCB',
'Nature Cell Biol.' => 'NCB'
);
My question is that how can I sort the values. I googled for a while.
sort $abbrev{$a} cmp $abbrev{$b} it complains that:
name "main::b" used only once: possible typo at try.pl line 24.
Name "main::a" used only once: possible typo at try.pl line 24.
Use of uninitialized value $a in hash element at try.pl line 24,
<$_[...]> line 6.
Use of uninitialized value $b in hash element at try.pl line 24,
<$_[...]> line 6.
Use of uninitialized value in string comparison (cmp) at try.pl line
24, <$_[...]> line 6.
Use of uninitialized value in string comparison (cmp) at try.pl line
24, <$_[...]> line 6.
Use of uninitialized value in concatenation (.) or string at
Thanks again,
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/