Re: how to shorten this code ? x occur how many times in variable

2008-05-06 Thread John W. Krahn
Richard Lee wrote: Can you please tell me how to shorten this? my @an = split(//); my @num = grep { $_ eq ':' } @an ; I was trying to see how many : occur in variable but didn't know how to do it fast so i did it like above... I would like to see as many way different ways to get this done i

how to shorten this code ? x occur how many times in variable

2008-05-06 Thread Richard Lee
Can you please tell me how to shorten this? my @an = split(//); my @num = grep { $_ eq ':' } @an ; I was trying to see how many : occur in variable but didn't know how to do it fast so i did it like above... I would like to see as many way different ways to get this done if possible thank yo

Re: Perl Expect help

2008-05-06 Thread Juan Pablo Feria Gomez
Here's a tiny code to get the prompt, hope it helps $actualprompt=''; $rootexpect->send("\n"); my $shpromvrfy = $rootexpect->expect(750,'#','>','$'); my $match=$rootexpect->match(); my @outp = split /\n/, $rootexpect->exp_before(); $actualprompt= "$o

Compare String is not match !

2008-05-06 Thread vu dinh chung
Hi all, My code is below *My code runs;* when run $array[$j][1] = 101-P-467593 ( this value is stored in excel file and this value input by hand ) and $accountNumber = 101-P-467593 *My code doens't run :* when run $array[$j][1] = 101-P-467593 ( this value is stored in excel file and it is re

Re: csv file question

2008-05-06 Thread Gunnar Hjalmarsson
Anirban Adhikary wrote: I have a csv file having the following contents. col1 col2 col3 "A", "1","2" "B","1", "3" "C","2","4" "D","1","5" "A","1","6" "B","2","7" "C","2","8" " ","3","9" Now I want to implement a logic which will show me the summarize records as follows col1 count A- 2 B - 2

Re: comparing kit names

2008-05-06 Thread Gunnar Hjalmarsson
perl_learner wrote: On May 5, 3:26 am, [EMAIL PROTECTED] (Gunnar Hjalmarsson) wrote: my @kits = qw( aaa.t.z aaa_d.t.z bbb.t.z bbb_d.t.z ccc.t.z ccc_d.t.z ddd.t.z eee.t.z ); my %hash = map { ( my $tmp = $_) =~ s/_d(\.t\.z)$/$1/; $tmp => 1 } grep /_d\.t

Re: chaining defines

2008-05-06 Thread Robert Hicks
Jenda Krynicky wrote: From: Robert Hicks <[EMAIL PROTECTED]> Is there anything wrong with: if ( defined $one && defined $two && $one eq $two ) { do something } As far as I can tell not. I was afraid the operator precedence might play tricks with it, but looks like it doesn't: V:\>

Re: parsing CSV files with control and extended ASCII characters

2008-05-06 Thread Jenda Krynicky
From: David Newman <[EMAIL PROTECTED]> > However, it doesn't answer the root question, namely how to parse text > that contains Western European characters such as accents and umlauts. > > I see from the Text::CSV documentation that this module handles only > characters between 0x20 and 0x7e. I

Re: how to simplify this script

2008-05-06 Thread Richard Lee
Gunnar Hjalmarsson wrote: Richard Lee wrote: Gunnar Hjalmarsson wrote: Richard Lee wrote: code of Gunnar's my $numbers_wanted = 2; my ( @datawanted, @numbers ); LOOP: foreach ( @datas ) { my @test = split; foreach my $num ( @numbers ) { next LOO

Re: chaining defines

2008-05-06 Thread Jenda Krynicky
From: Robert Hicks <[EMAIL PROTECTED]> > Is there anything wrong with: > > if ( defined $one && defined $two && $one eq $two ) { > do something > } As far as I can tell not. I was afraid the operator precedence might play tricks with it, but looks like it doesn't: V:\>perl -MO=Deparse

Re: how to simplify this script

2008-05-06 Thread Gunnar Hjalmarsson
Richard Lee wrote: Gunnar Hjalmarsson wrote: Richard Lee wrote: code of Gunnar's my $numbers_wanted = 2; my ( @datawanted, @numbers ); LOOP: foreach ( @datas ) { my @test = split; foreach my $num ( @numbers ) { next LOOP if grep( $num->{$_}, @tes

Re: parsing CSV files with control and extended ASCII characters

2008-05-06 Thread Gunnar Hjalmarsson
David Newman wrote: On 3/20/08 5:05 PM, Gunnar Hjalmarsson wrote: David Newman wrote: I have some CSV input files that contain control and extended ASCII characters, The Text::CSV or Tie::Handle::CSV modules don't like these characters; the snippets below both return errors when they get t

Re: Compile error

2008-05-06 Thread Robert Hicks
Rodrigo Tavares wrote: Hello, I create a hash, and i want take the keys. Using Deitel Book, i take this example: numbers = ( 1 => 'one', 3 => 'two', 5 => 'three', 7 => 'four', 9 => 'five', ); @hashkey = key

Re: parsing CSV files with control and extended ASCII characters

2008-05-06 Thread David Newman
On 3/20/08 5:05 PM, Gunnar Hjalmarsson wrote: David Newman wrote: I have some CSV input files that contain control and extended ASCII characters, The Text::CSV or Tie::Handle::CSV modules don't like these characters; the snippets below both return errors when they get to one. my $csv =

Re: Compile error

2008-05-06 Thread yitzle
On Tue, May 6, 2008 at 10:43 AM, Rodrigo Tavares <[EMAIL PROTECTED]> wrote: > Hello, > > I create a hash, and i want take the keys. > Using Deitel Book, i take this example: > > numbers = > ( >1 => 'one', >3 => 'two', >5 => 'three', >7

Re: chaining defines

2008-05-06 Thread yitzle
On Tue, May 6, 2008 at 9:49 AM, Robert Hicks <[EMAIL PROTECTED]> wrote: > Is there anything wrong with: > > if ( defined $one && defined $two && $one eq $two ) { > do something > } No. Its fine. You might be interested in "Operator Precedence and Associativity" [1] [1] http://perldoc.pe

Compile error

2008-05-06 Thread Rodrigo Tavares
Hello, I create a hash, and i want take the keys. Using Deitel Book, i take this example: numbers = ( 1 => 'one', 3 => 'two', 5 => 'three', 7 => 'four', 9 => 'five', ); @hashkey = keys (%numbers); When I try

Re: csv file question

2008-05-06 Thread yitzle
I'm sure someone more experienced will have a far more elegant solution, but something along these lines might work. (Note: code untested) %count; while (<>) { if ($_ =~ /^"([^"]*)"/) { %count{$1}++; } } for (keys %count) { print "$_ - $count{$_}\n"; } or, refractored, %count; while (<

chaining defines

2008-05-06 Thread Robert Hicks
Is there anything wrong with: if ( defined $one && defined $two && $one eq $two ) { do something } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: comparing kit names

2008-05-06 Thread perl_learner
On May 5, 3:26 am, [EMAIL PROTECTED] (Gunnar Hjalmarsson) wrote: > perl_learner wrote: > > Hi, > > > I have these type of kits in unix location. > > > aaa.t.z aaa_d.t.z bbb.t.z bbb_d.t.z ccc.t.z ccc_d.t.z ddd.t.z eee.t.z > > (there will be more numbers). > > > I have to come up with idea, so that ,

sed split on pipe

2008-05-06 Thread Jack Butchie
Have been googling for some time now and every command I tried fails. I want to use sed from the command line or use it in a windows batch file to split on a pipe delimited file, windows server. The examples have \n as the carriage return code, but all that happens is the pipe is replaced by t

csv file question

2008-05-06 Thread Anirban Adhikary
Dear list I have a csv file having the following contents. col1 col2 col3 "A", "1","2" "B","1", "3" "C","2","4" "D","1","5" "A","1","6" "B","2","7" "C","2","8" " ","3","9" Now I want to implement a logic which will show me the summarize records as follows col1 count A- 2 B - 2 C - 2 D - 1