Re: parsing a delimited file

2011-04-01 Thread Rob Dixon
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

Re: parsing a delimited file

2011-04-01 Thread Rob Dixon
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 (

Re: parsing a delimited file

2011-04-01 Thread John W. Krahn
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

Re: parsing a delimited file

2011-04-01 Thread Anirban Adhikary
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

Re: parsing a delimited file

2011-04-01 Thread John W. Krahn
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

Re: parsing a delimited file

2011-04-01 Thread Anirban Adhikary
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

Re: parsing a delimited file

2011-04-01 Thread Ramprasad Prasad
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;} } >

parsing a delimited file

2011-04-01 Thread Anirban Adhikary
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