Re: Excel Sheet Gen Code gives error

2013-07-15 Thread Jing Yu
Hi Jentil, You do not seem to have the module installed. If you have cpanm, you may try: $ cpanm Spreadsheet::WriteExcel Cheers, Jing On 15 Jul 2013, at 19:01, "Tom, Jentil Kuriakose" wrote: > > Hi, > > I have written simple EXCEL sheet gen PEARL code: > > #!/usr/bin/perl

Re: Array iterator count

2013-08-08 Thread Jing Yu
Or maybe you can convert your list into a file, and use the line number variable to do what you want. Cheers, Jing On 9 Aug 2013, at 01:05, Unknown User wrote: > > Hello, > > > If i am iterating through the elements in an array, at any point is it > possible to say which element i am handli

Re: Array iterator count

2013-08-08 Thread Jing Yu
Something like this: while(){ if(/d/){ print; say $.; } } __DATA__ a b c d e f g h i j k l m n o p q r s t u v w x y z Cheers, Jing On 9 Aug 2013, at 01:05, Unknown User wrote: > > Hello, > > > If i am iterating through the elements in an array, at any point is it >

Re: Array iterator count

2013-08-09 Thread Jing Yu
You probably can use 'state' instead of 'my' to keep $counter in scope. foreach my $e ( 'a'..'z' ) { state $counter++; if ( $counter == 5 ) { say $e; } } Cheers, Jing On 9 Aug 2013, at 16:24, Dermot wrote: > my $counter = 0; > foreach my $e ( a .. z ) { > $counter++;

Re: Array iterator count

2013-08-09 Thread Jing Yu
That is true.. Perhaps it's better to introduce a bare block enclosing the loop, and declare $count as 'my' just before 'foreach'. Cheers, Jing On 9 Aug 2013, at 16:39, Uri Guttman wrote: > On 08/09/2013 04:34 AM, Jing Yu wrote: >> You probably can u

Re: Single equals operator inside an if statement

2013-08-14 Thread Jing Yu
Hi Alexey, If I remember correctly, when you assign a value to an lvalue like this: $foo = 1; The value of the assignment is the value on the right hand side of the equal sign. So when you do something like: if ($foo=2){...} It has the same effect as this: $foo=2; If (2){...} The condition

Re: Single equals operator inside an if statement

2013-08-14 Thread Jing Yu
Hi there, Allow me to correct myself, the value of the assignment is the new value of the variable. But in the end it is the same. The compiler won't be able to see what $bar is when used in if ($foo=$bar), therefore won't throw any warnings. Cheers, Jing On 15 Aug 2013, at 01:21, Alexey Mishus

Re: Single equals operator inside an if statement

2013-08-14 Thread Jing Yu
Hi Alex, I guess it would be very difficult and error-prone to do it. Here's my thought: my $bar = 3; my $assign = (my $foo = $bar); if($assign){ say '$assign=',$assign; } my $equal = ($foo == $bar); if($equal){ say '$equal=',$equal; } output: $ perl tst.pl $assign=3 $equal=1 But if $

Re: Single equals operator inside an if statement

2013-08-14 Thread Jing Yu
Or maybe he can write a perl script to check the "if/while" conditionals of his perl script... while(<>){ say '= is detected where == is expected at line ',"$." if /if\s*\(\S+?=[^=]/; } On 15 Aug 2013, at 03:02, Rob Dixon wrote: > On 14/08/2013 18:21, Alexey Mishustin wrote: >> >> If

Re: Filtering Characters

2013-09-03 Thread Jing Yu
Maybe you should put chomp after the filtering line? Jing On 4 Sep 2013, at 01:08, Matt wrote: > I have this: > > while () { >chomp; >next if /^#/; ># do stuff >} > > > It skips to the next item in the while loop of the string begins with > # and works fine. I would also like

Re: help for an array refence within an hash pattern

2013-09-23 Thread Jing Yu
Hi Luca, Doesn't it autovivify $hash_ref->{$key} when you push $new_value to it? At least when I tested the following code, it worked. push @{ $hash_ref->{$key} }, $new_value; Regards, Jing On 23 Sep 2013, at 20:12, Luca Ferrari wrote: > Hi, > in my applications often I end up with an hash re

Re: hash function and combining function/operator

2013-09-23 Thread Jing Yu
Hi David, I don't know the answer but... it sounds like NCBI's BLAST to me, which compares nucleotide or protein sequences. NCBI's FTP site provides local BLAST binaries, and bioperl offers some convenient tools to implement it. Regards, Jing On 24 Sep 2013, at 07:01, David Christensen wrote

Re: hash function and combining function/operator

2013-09-25 Thread Jing Yu
Hi David, Another look at it, and I think I've pointed you to a wrong way. BLAST might not what you need. Sorry about this. Jing On 25 Sep 2013, at 03:31, David Christensen wrote: > On 09/24/13 00:12, Dr.Ruud wrote: >> I assume this is about paths and filenames. Have you considered an rsync >>

Re: check list if values meet criteria

2014-02-25 Thread Jing Yu
Data::Constraint is an alternative if you are thinking to add more different types of constraints. On 25 Feb 2014, at 22:36, Bill McCormick wrote: > On 2/25/2014 4:30 PM, Bill McCormick wrote: >> What would be the perl'ish way using map or some other sugar to check if >> a list of values meet so

Re: Search one character against one string

2014-03-12 Thread Jing Yu
Is @_[0] even legit? On 12 Mar 2014, at 04:58, Alex Chiang wrote: > Hi there, > > I got a wired bug with the following perl script: > > 35 # return non-negative value if particular character is in string array > 36 # otherwise, return -1 > > sub is_in_string { > 38 # @s: string array, $c

Re: Operand evaluation order

2014-03-14 Thread Jing Yu
Perlop: ... Auto-increment and Auto-decrement "++" and "--" work as in C. That is, if placed before a variable, they increment or decrement the variable by one before returning the value, and if placed after, increment or decrement after returning the value. $i = 0; $j = 0; print $i++;

Re: How to parse C#, javascript, lisp source code for quoted literal strings

2014-05-22 Thread Jing Yu
On 22 May 2014, at 10:04, siegfr...@heintze.com wrote: > I need to extract some information from source code. > > How can I write a perl regular expression that will match a literal string in > languages like C#, javascript, java and lisp? > > Here is my naive approach: > > /"[^"]*"/ > > Thi

Re: Regular expression: option match after a greedy/non-greedy match

2014-09-16 Thread Jing Yu
Hi Viet-Duc Le, On 17 Sep 2014, at 10:23, Viet-Duc Le wrote: > Greeting from S. Korea ! > > I am parsing the output of ffmpeg with perl. Particular, I want to print only > these lines among the output and capturing the resolution, i.e. 1280x720. > > Stream #0:0: Video: h264 (High), yuv42

Re: Regular expression: option match after a greedy/non-greedy match

2014-09-17 Thread Jing Yu
On 17 Sep 2014, at 17:08, Uday Vernekar wrote: > When i run this script i get following Error > > bash-4.2$ ./regex.pl > feature version v5.16.0 required--this is only version v1.160.0 at ./regex.pl > line 4. > BEGIN failed--compilation aborted at ./regex.pl line 4. > > > > But I am using p

Re: Removing text

2015-05-18 Thread Jing Yu
Hi Richard, When you printf "0.0%st” in the command line, it prints 0.0t And that is the string piped to perl. This is perhaps why you didn’t succeed. J -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.or

Re: Counter Help

2016-02-09 Thread Jing Yu via beginners
Hello, I don’t know whether it is possible to count the occurrence in hash? print $var, $myhash{$var}++.”\n”; Jing > On 9 Feb 2016, at 14:08, James Kerwin wrote: > > Afternoon all, > > I have the following problem: > > I have an array containing a list of non-unique strings. eg: > > @array