Re: beginners Digest 6 May 2015 07:20:38 -0000 Issue 4811

2015-05-06 Thread Shlomi Fish
Hi Илья, some comments on your code: On Wed, 06 May 2015 08:09:01 + Илья Рассадин elcaml...@gmail.com wrote: HI, Anirban. Regexp and hash of arrays can help you. my @a = ('1900-0','1900-1','NULL','NULL','1900-2','1900-4','1902-5','1902-6','1902-7','1902-8'); Always start with

Fwd: Fw: Perl array question

2015-05-06 Thread Shlomi Fish
-- Forwarded message -- From: Shlomi Fish shlo...@shlomifish.org Date: Wed, May 6, 2015 at 11:31 AM Subject: Fw: Perl array question To: shlo...@gmail.com Begin forwarded message: Date: Wed, 6 May 2015 11:04:30 +0300 From: Shlomi Fish shlo...@shlomifish.org To: beginners

Re: beginners Digest 6 May 2015 07:20:38 -0000 Issue 4811

2015-05-06 Thread Anirban Adhikary
Thanks to all for your kind support. On Wed, May 6, 2015 at 1:39 PM, Илья Рассадин elcaml...@gmail.com wrote: HI, Anirban. Regexp and hash of arrays can help you. my @a = ('1900-0','1900-1','NULL','NULL','1900-2','1900-4','1902-5','1902-6','1902-7','1902-8'); my %result; foreach (@a)

Re: beginners Digest 6 May 2015 07:20:38 -0000 Issue 4811

2015-05-06 Thread Илья Рассадин
Hi, Shlomi. Of course, you need to use strict and warnings. I'm sorry to not specify it my answer. And I'm agree with your suggestion about checking result of regexp validation. For cycle create very concrete and understandable lexical scope and you can safely use loop variable outside this

Re: Perl array question

2015-05-06 Thread Shlomi Fish
Hi Vincent, On Wed, 06 May 2015 10:07:41 +0200 Vincent Lequertier s...@riseup.net wrote: It's a bit ugly, but here is one way to do it : Your code encourages many bad practices. Some notes are: #!/usr/bin/perl no use strict;/use warnings;:

Re: Perl array question

2015-05-06 Thread Vincent Lequertier
Thank you for the review, I'm learning and didn't know about this way of using hashes :-) --- Vincent Lequertier s...@riseup.net Le 2015-05-06 11:09, Shlomi Fish a écrit : Hi Vincent, On Wed, 06 May 2015 10:07:41 +0200 Vincent Lequertier s...@riseup.net wrote: It's a bit ugly, but here is

Re: Perl array question

2015-05-06 Thread Vincent Lequertier
It's a bit ugly, but here is one way to do it : #!/usr/bin/perl my @array = ('1900-0', '1900-1', 'NULL', 'NULL', '1900-2', '1900-4', '1902-5', '1902-6', '1902-7', '1902-8'); my $num1900 = 'EARFCN=1900, PCID='; my $num1902 = 'EARFCN=1902, PCID='; for (@array) { # print $_ . \n; $num1900

Re: beginners Digest 6 May 2015 07:20:38 -0000 Issue 4811

2015-05-06 Thread Илья Рассадин
HI, Anirban. Regexp and hash of arrays can help you. my @a = ('1900-0','1900-1','NULL','NULL','1900-2','1900-4','1902-5','1902-6','1902-7','1902-8'); my %result; foreach (@a) { next if $_ eq 'NULL'; my ($earfcn, $pcid) = /^(\d+)-(.+)$/; push @{$result{$earfcn}}, $pcid;

Perl array question

2015-05-06 Thread Anirban Adhikary
Hi List I have the following array --- ('1900-0','1900-1','NULL','NULL','1900-2','1900-4','1902-5','1902-6','1902-7','1902-8'); There are two part for each element separated by a dash. first one known as earfcn and second one is pcid . The requirement is For the same “earfcn”, concatenate the

Re: Perl array question

2015-05-06 Thread Shawn H Corey
On Wed, 6 May 2015 12:49:53 +0530 Anirban Adhikary anirban.adhik...@gmail.com wrote: Hi List I have the following array --- ('1900-0','1900-1','NULL','NULL','1900-2','1900-4','1902-5','1902-6','1902-7','1902-8'); There are two part for each element separated by a dash. first one known as

Fwd: Fw: Perl array question

2015-05-06 Thread Shlomi Fish
-- Forwarded message -- From: Shlomi Fish shlo...@shlomifish.org Date: Wed, May 6, 2015 at 11:31 AM Subject: Fw: Perl array question To: shlo...@gmail.com Begin forwarded message: Date: Wed, 6 May 2015 11:04:30 +0300 From: Shlomi Fish shlo...@shlomifish.org To: beginners

Re: Perl array question

2015-05-06 Thread Marius Gavrilescu
anirban.adhik...@gmail.com (Anirban Adhikary) writes: Hi List I have the following array --- ('1900-0','1900-1','NULL','NULL','1900-2','1900-4','1902-5','1902-6','1902-7','1902-8'); There are two part for each element separated by a dash. first one known as earfcn and second one is pcid .