Re: perl dd

2011-04-01 Thread Shlomi Fish
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

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

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;} } >

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 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
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: 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 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 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

How can I do this in Perl?

2011-04-01 Thread Wernher Eksteen
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

Re: How can I do this in Perl?

2011-04-01 Thread Uri Guttman
> "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

Re: How can I do this in Perl?

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

Re: How can I do this in Perl?

2011-04-01 Thread Wernher Eksteen
> 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

Re: How can I do this in Perl?

2011-04-01 Thread Wernher Eksteen
> 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