Re: regexp puzzle

2014-03-08 Thread Bill McCormick
On 3/8/2014 12:05 AM, Bill McCormick wrote: I have the following string I want to extract from: my $str = "foo (3 bar): baz"; and I want to to extract to end up with $p1 = "foo"; $p2 = 3; $p3 = "baz"; the complication is that the \s(\d\s.+) is optional,

Re: regexp puzzle

2014-03-07 Thread Bill McCormick
On 3/8/2014 12:41 AM, shawn wilson wrote: my $str = "foo (3 bar): baz"; my $test = "foo (3 bar): baz"; my ($p1, $p2, $p3) = $test =~ /([^]+) \(([0-9]+).*\) ([a-z]+)/; print "p1=[$p1] p2=[$p2] p3=[$p3]\n"; Use of uninitialized value $p1 in concatenation (.) or string at ./lock_report.pl line 1

regexp puzzle

2014-03-07 Thread Bill McCormick
I have the following string I want to extract from: my $str = "foo (3 bar): baz"; and I want to to extract to end up with $p1 = "foo"; $p2 = 3; $p3 = "baz"; the complication is that the \s(\d\s.+) is optional, so in then $p2 may not be set. getting close was my ($p1, $p3) = $str =~ /^(.+):

Re: match not matching

2014-03-01 Thread Bill McCormick
On 3/1/2014 6:19 AM, Paul Johnson wrote: On Fri, Feb 28, 2014 at 11:13:05PM -0600, Bill McCormick wrote: Can somebody help me understand this? Given this loop, and the logged output following ... my $found; for( @$products ) {; $found = $$_ =~ m|$project|; I think you might have meant

match not matching

2014-02-28 Thread Bill McCormick
Can somebody help me understand this? Given this loop, and the logged output following ... my $found; for( @$products ) {; $found = $$_ =~ m|$project|; $dump = Data::Dumper->Dump([$_, $project, $$_, $found]); $logger->trace(qq(dump=$dump)); } I can't explain why $found is not true on the

Re: check list if values meet criteria

2014-02-26 Thread Bill McCormick
On 2/25/2014 7:07 PM, Jim Gibson wrote: On Feb 25, 2014, at 2: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 some criteria? Instead of doing something like my @issues = qq(123,456,a45); my $max = 999; for (@i

Re: check list if values meet criteria

2014-02-25 Thread Bill McCormick
On 2/25/2014 4:36 PM, 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 some criteria? Instead of doing something like my @issues = qq(123,456,a45); my $max = 999; for (@i

Re: check list if values meet criteria

2014-02-25 Thread Bill McCormick
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 some criteria? Instead of doing something like my @issues = qq(123,456,a45); my $max = 999; for (@issues) { die if $_ < 0 or $_ > $max; }

check list if values meet criteria

2014-02-25 Thread Bill McCormick
What would be the perl'ish way using map or some other sugar to check if a list of values meet some criteria? Instead of doing something like my @issues = qq(123,456,a45); my $max = 999; for (@issues) { die if $_ < 0 or $_ > $max; } I want to check if each list item is numeric and > 0 but le

Re: Turn part of a string into a single newline

2014-02-14 Thread Bill McCormick
On 2/14/2014 3:39 AM, kimi ge(巍俊葛) wrote: Hi Parys, Your statement "$joinedDNA =~ s/\R//g;" will remove new line in the string. You may remove this statement. Yea, I don't see that you need that either. maybe you were just trying to get a new line at then end? $joinedDNA =~ s/N+|$/\n/g;

Re: Turn part of a string into a single newline

2014-02-14 Thread Bill McCormick
Is this your homework? On 2/14/2014 1:48 AM, Parysatis Sachs wrote: Hi everyone! I'm new to this mailing list as well as to programming and Perl in general. So there is a chance I might ask relatively stupid questions with very obvious answers... Please bear with me! So, here it goes: I have

exception handling

2014-02-13 Thread Bill McCormick
I have a Perl module that calls a function from in a Swig generated module, which in turn calls a function in a shared library. It's been a while since I put it all together and made it work, so I'm kind of hazy on the technical details - and since it mostly works I never need to look at it.

Re: list to hash puzzle

2014-02-09 Thread Bill McCormick
On 2/9/2014 10:48 AM, Bill McCormick wrote: Trying to map the array list into a hash, but loose the double quotes surrounding the key's value. This is close, but it's not removing the quotes. Solutions? #!/usr/bin/perl -w use strict; use Data::Dumper; my @array = qw(foo1="b

Re: list to hash puzzle

2014-02-09 Thread Bill McCormick
On 2/9/2014 3:58 PM, Shawn H Corey wrote: On Sun, 09 Feb 2014 10:48:46 -0600 Bill McCormick wrote: Trying to map the array list into a hash, but loose the double quotes surrounding the key's value. You can convert a list to a hash directly: my %hash = qw( foo1 bar1 foo2 bar2 );

list to hash puzzle

2014-02-09 Thread Bill McCormick
Trying to map the array list into a hash, but loose the double quotes surrounding the key's value. This is close, but it's not removing the quotes. Solutions? #!/usr/bin/perl -w use strict; use Data::Dumper; my @array = qw(foo1="bar1" foo2="bar2"); print "Array:\n"; print Dumper(@array); pr