- 论坛徽章:
- 0
|
> Hi!
>
> I work in a library and i need to have several fields in one line
>
> Example
>
> I have this
>
> =995 \\$xPR$wLivre
> =995 \\$bECAM$cECAM
> =995 \\$n
> =995 \\$oDisponible
> =995 \\$kG1 42171
>
>
> and i want in one line
>
> =995 \\$bECAM$cECAM$kG1 42171$n$oDisponible$xPR$wLivre
>
Using Dr., Ruud's data. This is another way of doing it:- use warnings;
- use strict;
-
- my %data_collection;
-
- while (<DATA>) {
- chomp;
- my ( $key, $value ) = split /\s+/, $_, 2;
- push @{ $data_collection{$key} }, $value;
- }
-
- print $_, " ", @{ $data_collection{$_} }, $/ for keys %data_collection;
-
- __DATA__
-
- =995 \\$xPR$wLivre
- =995 \\$bECAM$cECAM
- =995 \\$n
- =995 \\$oDisponible
- =995 \\$kG1 42171
- zz 1
- zz 2
- zz 3
复制代码 求大神 解释下push 这行中的@{} ,还有顺便解释下$/!!!
ths !!!
|
|