On Thursday 31 Mar 2011 16:54:14 Peter Scott wrote:
> On Thu, 31 Mar 2011 12:07:41 +0200, Shlomi Fish wrote:
> > Also, Larry Wall has allowed Perl 5 numeric constants to contain
> > underscore so you can write 10**9 as 1_000_000_000 instead of 10
> > which is much less readable and also mor
Hi List
I am trying to parse the following file and load it into a hash.
File Structure
DN: 2570764 (PORTED-IN)
TYPE: SINGLE PARTY LINE
SNPA: 438 SIG: DTLNATTIDX: 4
XLAPLAN KEY : 438CAUC1RATEAREA KEY : ILEPEROT
LINE EQUIPMENT NUMBER: LG3
See Inline comments
use strict;
> use warnings;
> my $fname = $ARGV[0];
> open my $RFH,'<',$fname;
>
> while (<$RFH>) {
>next unless /:/ and my %field = /(.*?):(.*?)/mg; # Wrong
>
# I would prefer doing this
chomp;
if(/^(.+?)\:(.+?)/){ $field{$1}=$2;}
}
>
Have u run your code?\
Here u cant chomp because you have key/value pairs spans more than one
line..
Thanks & Regards
Anirban.
On Fri, Apr 1, 2011 at 4:37 PM, Ramprasad Prasad wrote:
> See Inline comments
>
> use strict;
>> use warnings;
>> my $fname = $ARGV[0];
>> open my $RFH,'<',$fnam
Anirban Adhikary wrote:
Hi List
Hello,
I am trying to parse the following file and load it into a hash.
File Structure
DN: 2570764 (PORTED-IN)
TYPE: SINGLE PARTY LINE
SNPA: 438 SIG: DTLNATTIDX: 4
XLAPLAN KEY : 438CAUC1RATEAREA KEY : ILEPERO
I want to create a new file where I get each line like KEY=VALUE
In the source file in a single line the are multiple KEY-VALUE pair
and there is also some line where KEY VALUE pair spreads across two
lines.
On Fri, Apr 1, 2011 at 4:49 PM, John W. Krahn wrote:
> Anirban Adhikary wrote:
>>
>> Hi L
Anirban Adhikary wrote:
I want to create a new file where I get each line like KEY=VALUE
In the source file in a single line the are multiple KEY-VALUE pair
and there is also some line where KEY VALUE pair spreads across two
lines.
That's nice.
Please do not top-post your replies. And please
On 01/04/2011 12:00, Anirban Adhikary wrote:
> Hi List
>
> I am trying to parse the following file and load it into a hash.
>
> File Structure
>
>
[snip data]
>
> Separater is colon(:)
>
> my code
>
> use strict;
> use warnings;
> my $fname = $ARGV[0];
> open my $RFH,'<',$fname;
>
> while (
On 01/04/2011 13:57, Rob Dixon wrote:
>
> use strict;
> use warnings;
>
> my $data;
> {
>local $/;
>$data =;
> }
>
> my $key = qr/ (?: \w+ [ ] )* \w+ /x;
>
> my @xx = $data =~ /\G ( $key ) \s? : \s* (.+?) \s* (?= $key \s? : | \z)/sgx;
My apologies, I had thought that there was always e
Hi,
>From the folowing list is a result of the @power array, when run
through the foreach loop:
Pseudo name=emcpowerd
1 lpfc sdba SP A7 active alive 0 0
1 lpfc sddd SP B7 active alive 0 0
3 lpfc
> "WE" == Wernher Eksteen writes:
WE> Pseudo name=emcpowerd
WE> 1 lpfc sdba SP A7 active alive 0
0
WE> 1 lpfc sddd SP B7 active alive 0
0
WE> 3 lpfc sdfg SP B6 active
On 01/04/2011 19:52, Wernher Eksteen wrote:
From the folowing list is a result of the @power array, when run
through the foreach loop:
Pseudo name=emcpowerd
1 lpfc sdba SP A7 active alive 0 0
1 lpfc sddd SP B7 active a
> Please always 'use strict' and 'use warnings', and consequently declare
> all of your variables. That way most straightforward problems will be
> solved my Perl before ever reaching his list.
Thanks, I will remember to do so for future.
> It is better to open a pipe to a child process running y
> that * isn't doing what you think it does. perl regexes are not shell
> globs. it happens to work anyway since the tokens are unique
> enough. read perlretut to learn perl regexes.
>
> what have you tried so far? you know enough perl to get the array of
> lines and loop over that. in english (or
14 matches
Mail list logo