Re: regex matching statements

2024-06-18 Thread Levi Elias Nystad-Johansen via beginners
Hi, Yes, they are the same. I like to use $_ only when the data comes in $_ naturally. Like in a for loop: for (qw< abc >) { if ( !/\w+\d+/ ) { print "not matched"; } } Otherwise, I have to write $_, then I prefer to name the variable something descriptive instead. Makes the code

regex matching statements

2024-06-18 Thread Jeff Peng via beginners
Hello list, are these statements the same in perl? $ perl -le '$_="abc";if (!/\w+\d+/){print "not matched"}' not matched $ perl -le '$_="abc";if ($_ !~ /\w+\d+/){print "not matched"}' not matched or which is the better one? Thanks. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org Fo

Re: difficulty with matching

2018-06-04 Thread Shlomi Fish
On Sat, 2 Jun 2018 07:30:48 -0500 p...@reason.net wrote: > Very useful advice, Shlomi; thanks! > you are welcome! Also see http://perl-begin.org/tutorials/bad-elements/ , which I also maintain. > > > On Jun 2, 2018, at 3:57 AM, Shlomi Fish wrote: > > > > On Fri, 1 Jun 2018 15:54:55 -0500 > >

Re: difficulty with matching

2018-06-03 Thread Mike Flannigan
ith it like this you can at least figure out what it is doing, but maybe not why.  The manpages will probably be needed to answer that. Please let us know what you find out. Mike On 6/1/2018 3:55 PM, beginners-digest-h...@perl.org wrote: Subject: difficulty with matching From: Rick T Date:

Re: difficulty with matching

2018-06-02 Thread perl
Very useful advice, Shlomi; thanks! > On Jun 2, 2018, at 3:57 AM, Shlomi Fish wrote: > > On Fri, 1 Jun 2018 15:54:55 -0500 > Rick T mailto:p...@reason.net>> wrote: > >> This is a newbie question, I’m sure. But I get perplexed easily! >> >> The follow code segment expects to receive a $student

Re: difficulty with matching

2018-06-02 Thread Shlomi Fish
On Fri, 1 Jun 2018 15:54:55 -0500 Rick T wrote: > This is a newbie question, I’m sure. But I get perplexed easily! > > The follow code segment expects to receive a $student_id consisting of a > surname followed by a hyphen followed by a number. The die is for testing > what I’m doing. > > If I

Re: difficulty with matching

2018-06-01 Thread Andy Bach
> If I feed it 'jones-123’ it dies with ‘jones, - , 123’ as I expected. But if I feed it ‘jones-‘ omitting the number on the end, it dies with no matches at all (or blanks): ‘ , , ‘ and I cannot figure out why it does not die with ‘jones, -, ' and would appreciate an explanation. Many thanks!

Re: difficulty with matching

2018-06-01 Thread Octavian Rasnita
[0-9]+ means at least one digit in range 0-9. If there is no digit, the string won't match. You want [0-9]* instead. --Octavian - Original Message - From: Rick T To: Perl Beginners Sent: Friday, June 01, 2018 11:54 PM Subject: difficulty with matching This is a n

difficulty with matching

2018-06-01 Thread Rick T
This is a newbie question, I’m sure. But I get perplexed easily! The follow code segment expects to receive a $student_id consisting of a surname followed by a hyphen followed by a number. The die is for testing what I’m doing. If I feed it 'jones-123’ it dies with ‘jones, - , 123’ as I expect

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread Shawn H Corey
On Sat, 05 Nov 2016 21:30:12 + Aaron Wells wrote: > True. It could get hairy. Unicode is a pretty vast landscape, and I > think if you only want ASCII word characters to count as things that > could be in a filename, your original [A-Za-z0-9_] is your best bet. > Thanks to the others for thei

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread Octavian Rasnita
From: Aaron Wells True. It could get hairy. Unicode is a pretty vast landscape, and I think if you only want ASCII word characters to count as things that could be in a filename, your original [A-Za-z0-9_] is your best bet. Thanks to the others for their comments. As Ken says: there are pro

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread X Dungeness
ly ASCII, use the /a modifer, eg, /\w+/a >From perlre: /a is the same as "/u", except that "\d", "\s", "\w", and the Posix character classes are restricted to matching in the ASCII range only. That is, with this modifier, "\d&

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread Aaron Wells
ed m/[A-Za-z0-9\_]+(?!\.)/ but I still get both strings > > captured. > > Alternatively, if your use case allows it, it might be more viable to > use negative matching. > > $file !~ /[.]/ and print "$file has no extension" > > There's probably a reason w

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread Kent Fredric
se case allows it, it might be more viable to use negative matching. $file !~ /[.]/ and print "$file has no extension" There's probably a reason why you're not doing this already, but can't tell from the context. NB: Clearly defining what an "extension&quo

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread Ken Slater
Hi Jovan, On Sat, Nov 5, 2016 at 1:14 PM, Jovan Trujillo wrote: > Hi All, > I thought I could use a simple regex to match files like this: > > 1207003PE_GM_09TNPLM2 > > and ignore files with extensions like this: > > 1207003PE_GM_09TNPLM2.csv > > I originally though m/[A-Za-z0-9\_]+/ wou

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread Jovan Trujillo
Hi Aaron, In perlre I read that \w " - \w[3] Match a "word" character (alphanumeric plus "_", plus - other connector punctuation chars plus Unicode - marks) " So since I didn't know what these 'other' con

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread Aaron Wells
*predefined On Sat, Nov 5, 2016, 10:27 AM Aaron Wells wrote: > Hi Jovan. \w is a presidents character classes that is equivalent to > [A-Za-z0-9_], so this works also: > m/^\w+$/ > > On Sat, Nov 5, 2016, 10:24 AM Jovan Trujillo > wrote: > > Ah, I figured it out. > m/^[A-Za-z0-9_]+$/ works beca

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread Aaron Wells
Hi Jovan. \w is a presidents character classes that is equivalent to [A-Za-z0-9_], so this works also: m/^\w+$/ On Sat, Nov 5, 2016, 10:24 AM Jovan Trujillo wrote: > Ah, I figured it out. > m/^[A-Za-z0-9_]+$/ works because it will only match if the entire string > follows the pattern. Thanks! >

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread Jovan Trujillo
Ah, I figured it out. m/^[A-Za-z0-9_]+$/ works because it will only match if the entire string follows the pattern. Thanks! On Sat, Nov 5, 2016 at 10:14 AM, Jovan Trujillo wrote: > Hi All, > I thought I could use a simple regex to match files like this: > > 1207003PE_GM_09TNPLM2 > > and

Regex for matching files that don't have type extensions

2016-11-05 Thread Jovan Trujillo
Hi All, I thought I could use a simple regex to match files like this: 1207003PE_GM_09TNPLM2 and ignore files with extensions like this: 1207003PE_GM_09TNPLM2.csv I originally though m/[A-Za-z0-9\_]+/ would work, but it captures both strings. So then I tried m/[A-Za-z0-9\_]+(?!\.)/ but

Re: Increasing a counter while matching against list of given words.

2014-05-13 Thread Mike Dunaway
That makes sense, thanks. On 05/13/2014 01:46 PM, Shlomi Fish wrote: Hi Mike, please reply to the list. On Tue, 13 May 2014 12:49:42 -0500 Mike Dunaway wrote: Actually, can you tell me what's going on here: my %words_lookup = (map { $_ => 1 } @words_to_look_for); I build a hash called %w

Re: Increasing a counter while matching against list of given words.

2014-05-13 Thread Shlomi Fish
Hi Mike, please reply to the list. On Tue, 13 May 2014 12:49:42 -0500 Mike Dunaway wrote: > Actually, can you tell me what's going on here: > > my %words_lookup = (map { $_ => 1 } @words_to_look_for); > I build a hash called %words_lookup whose keys are the entries of @words_to_look_for and

Re: Increasing a counter while matching against list of given words.

2014-05-13 Thread Mike Dunaway
t of words and increase a counter every time a word in the given list appears in what I'm matching against, what might a possible solution look like for that? The only thing I could think of is a nasty mess of a ton of for loops restarted until you get to the end of the user provided list w

Re: Increasing a counter while matching against list of given words.

2014-05-13 Thread Shlomi Fish
in what > I'm matching against, what might a possible solution look like for that? > The only thing I could think of is a nasty mess of a ton of for loops > restarted until you get to the end of the user provided list which may > end up being very slow depending on the size of the li

Increasing a counter while matching against list of given words.

2014-05-13 Thread Mike Dunaway
Hello everyone. Let's say I have a user provide @list of words and I want to match each words against a file or a another @list of words and increase a counter every time a word in the given list appears in what I'm matching against, what might a possible solution look like for that?

Re: match not matching

2014-03-01 Thread Jim Gibson
On Feb 28, 2014, at 9:13 PM, Bill McCormick wrote: > 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(

Re: match not matching

2014-03-01 Thread Dr.Ruud
On 2014-03-01 06:13, Bill McCormick wrote: $found = $$_ =~ m|$project|; Alternative: $found = ( index( $project, $$_ ) >= 0 ); or rather use: $found = $project =~ /\b\Q$$_\E\b/; Always add escaping and anchors, or you will match the unmatchable. -- Ruud -- To unsubscribe, e-mail: be

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:

Re: match not matching

2014-03-01 Thread Paul Johnson
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: $found = $project =~ m|$$_|; >

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: matching certain lines

2013-02-10 Thread Chris Stinemetz
On Sun, Feb 10, 2013 at 8:05 AM, Chris Stinemetz wrote: > To take this a step further. > > How would you go about creating a hash to sum up all the values in group > $3 utilizing the flip/flop operator and print the results of the key and > value with the key being group $2? > > This is what I cam

Re: matching certain lines

2013-02-10 Thread Chris Stinemetz
To take this a step further. How would you go about creating a hash to sum up all the values in group $3 utilizing the flip/flop operator and print the results of the key and value with the key being group $2? Thank you, Chris while( ) { if ( /0x3\|68\|/ .. /^#END/ ) { print if /\|

Re: matching certain lines

2013-02-10 Thread Chris Stinemetz
Thank you everyone for you help. -Chris On Sat, Feb 9, 2013 at 5:15 PM, Uri Guttman wrote: > On 02/09/2013 03:59 PM, John W. Krahn wrote: > > >> Let's re-factor that down to its essence: >> >> while ( ) { >> print if /\|68\|/; >> print "$1\t$2\t$3\n" if /(\|\d)\|(\d+)\|(\d+)/; >>

Re: matching certain lines

2013-02-09 Thread Uri Guttman
On 02/09/2013 03:59 PM, John W. Krahn wrote: Let's re-factor that down to its essence: while ( ) { print if /\|68\|/; print "$1\t$2\t$3\n" if /(\|\d)\|(\d+)\|(\d+)/; } Now we need to add something that starts at |68| and stops at #END: while ( ) { if ( /\|68\|/ .. /^#EN

Re: matching certain lines

2013-02-09 Thread timothy adigun
Hi, On Sat, Feb 9, 2013 at 6:06 PM, Chris Stinemetz wrote: > I would like to only work with the data that has a line with |68| in it > Does it mean even, that |68| can be anyway in the your data before any of the #END is reached? If yes, then I think you have been given a good solution. If not,

Re: matching certain lines

2013-02-09 Thread John W. Krahn
Chris Stinemetz wrote: I would like to only work with the data that has a line with |68| in it print that line and then print each subsequent lines in that match /\|7\|\d+\|\d+/ until #END is reached and then repeat for the rest of the input data. Below is what I have attempted. Thanks in adva

Re: matching certain lines

2013-02-09 Thread David Precious
On Sat, 9 Feb 2013 11:06:46 -0600 Chris Stinemetz wrote: > I would like to only work with the data that has a line with |68| in > it print that line and then print each subsequent lines in that match > /\|7\|\d+\|\d+/ until #END is reached and then repeat for the rest of > the input data. OTTOMH

matching certain lines

2013-02-09 Thread Chris Stinemetz
I would like to only work with the data that has a line with |68| in it print that line and then print each subsequent lines in that match /\|7\|\d+\|\d+/ until #END is reached and then repeat for the rest of the input data. Below is what I have attempted. Thanks in advance. Chris #!/usr/bin/p

Re: Pattern matching to hash

2012-12-29 Thread Dr.Ruud
On 2012-12-28 21:32, twle...@reagan.com wrote: I hope this is a simple fix. I want to check the beginning characters of items in a hash, and compare that to a scalar variable. I do not need for the entire value to match; just the first couple of characters. Here is a simple example of what I

Re: Pattern matching to hash

2012-12-28 Thread Chris Charley
"timothy adigun" wrote in message news:CAEWzkh6mZohVJn__LRL60AGoqbHkmTPyn=JM=cewcmmftpj...@mail.gmail.com... Hello Chris, Please see my comment below. On Fri, Dec 28, 2012 at 10:24 PM, Chris Charley wrote: [snip] I only answered the question using a for loop. Am not the one who origi

RE: Pattern matching to hash

2012-12-28 Thread Tim Lewis
matching to hash Chris Charley"" wrote in message news >Tim wrote in message news:1356726727.215915...@webmail.reagan.com... >>I hope this is a simple fix. I want to check the beginning characters >>of items in a hash, and compare that to a scalar variable. >>I do n

RE: Pattern matching to hash

2012-12-28 Thread Tim Lewis
@perl.org Subject: Re: Pattern matching to hash Hi, my $prefix_search_list = '03S,04S'; my @prefix_array = split /\,/,$prefix_search_list; my %prefix_hash = map {$_ => 1 } @prefix_array; #compare 05S to 03S and 04S my $input_field = "05S885858"; #should not match

Re: Pattern matching to hash

2012-12-28 Thread Chris Charley
Chris Charley"" wrote in message news Tim wrote in message news:1356726727.215915...@webmail.reagan.com... I hope this is a simple fix. I want to check the beginning characters of items in a hash, and compare that to a scalar variable. I do not need for the entire value to match; just the

Re: Pattern matching to hash

2012-12-28 Thread timothy adigun
Hello Chris, Please see my comment below. On Fri, Dec 28, 2012 at 10:24 PM, Chris Charley wrote: > > > Tim wrote in message news:1356726727.215915216@**webmail.reagan.com... > > I hope this is a simple fix. I want to check the beginning characters of >> items in a hash, and compare that to a s

Re: Pattern matching to hash

2012-12-28 Thread Chris Charley
Tim wrote in message news:1356726727.215915...@webmail.reagan.com... I hope this is a simple fix. I want to check the beginning characters of items in a hash, and compare that to a scalar variable. I do not need for the entire value to match; just the first couple of characters. Tim my $p

Re: Pattern matching to hash

2012-12-28 Thread timothy adigun
Hi, > my $prefix_search_list = '03S,04S'; > my @prefix_array = split /\,/,$prefix_search_list; > my %prefix_hash = map {$_ => 1 } @prefix_array; > > #compare 05S to 03S and 04S > my $input_field = "05S885858"; #should not match > 1. using stricts and warnings pragma, shows clearly that there i

Pattern matching to hash

2012-12-28 Thread twlewis
I hope this is a simple fix. I want to check the beginning characters of items in a hash, and compare that to a scalar variable. I do not need for the entire value to match; just the first couple of characters. Here is a simple example of what I want, but it does not work. Both "if" statemen

Re: Multiple matching of a group of characters

2012-10-03 Thread Brandon McCaig
"foo=$foo\n"; print "bar=$bar\n"; print "baz=$baz\n"; sub parse_sequence { my ($sequence) = @_; # We don't want the leading > character. $sequence =~ s/^>//; my @parts = split /\|/, $sequence; # We're interested in the first two fields.

Re: Multiple matching of a group of characters

2012-10-03 Thread Florian Huber
Alright, thanks for your answers! I think I know what my mistake was: although I realised that * means 0 or more I thought that it would prefer to match as often as possible - but it seems that the matching stops as soon as the regex is successful, that's why. Thanks again.

Re: Multiple matching of a group of characters

2012-10-02 Thread William Muriithi
nt "ENSG0112365 ENST0230122" > > without the sequence. Originally I had .* before the ([ACGT]) so I figured > it's greedy and will eat the sequence away. ? makes it nongreedy, doesn't > it? Still doesn't work. > Greed here don't mean eating, its h

Re: Multiple matching of a group of characters

2012-10-02 Thread Jim Gibson
112365 ENST0230122" > > without the sequence. Originally I had .* before the ([ACGT]) so I figured > it's greedy and will eat the sequence away. ? makes it nongreedy, doesn't it? > Still doesn't work. You are not realizing that [AGCT]* means "zero or more charac

Re: Multiple matching of a group of characters

2012-10-02 Thread Florian Huber
say for sure what is going on (though we can speculate; see below). Note that you should be using the strict and warnings pragmas (see below). The lack of 'my' here suggests that you probably aren't. But when I do $string =~ /[ACGT]/; it matches only the last letter, i.e. &q

Re: Multiple matching of a group of characters

2012-10-01 Thread Brandon McCaig
hen I do > > $string =~ /[ACGT]/; > > it matches only the last letter, i.e. "G". Why doesn't it start > at the beginning? It isn't matching the last letter. You are probably making the wrong assumption. This is common when you're having trouble with code. A

Re: Multiple matching of a group of characters

2012-10-01 Thread Andy Bach
On Mon, Oct 1, 2012 at 5:15 PM, Florian Huber wrote: > > My confusion was complete when I tried > > $string =~ /[ACGT]{5}/; > > now it matches 5 letters, but this time from the beginning, i.e.: ACGAC. >I'm trying to extract a DNA sequence out of a larger string, i.e. the string >is of the follow

Re: Multiple matching of a group of characters

2012-10-01 Thread Jim Gibson
$string, that should be 'A'. Can you show us a minimal program that demonstrates matching the 'G' at the end of the string? We need to see the whole program to explain something so inexplicable. > > But it gets even better, I figured that adding the greedy * should help:

Multiple matching of a group of characters

2012-10-01 Thread Florian Huber
Dear all, I'm trying to extract a DNA sequence out of a larger string, i.e. the string is of the following structure: $string = "/NOTNEEDED/*ACGACGGGTTCAAGGCAG*/NOTNEEDED/" But when I do $string =~ /[ACGT]/; it matches only the last letter, i.e. "G". Why doesn't it start at the beginning?

Re: matching array elements from hash ?

2012-09-01 Thread Dr.Ruud
On 2012-08-20 00:18, John W. Krahn wrote: print map exists $stud{ $_ } ? "$_ = $stud{ $_ }\n" : (), @names; A map using a ternary with (), is like a grep: print "$_ = $stud{ $_ }\n" for grep exists $stud{ $_ }, @names; -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For

Re: matching array elements from hash ?

2012-08-20 Thread timothy adigun
Hi Andy, On 8/20/12, Andy Bach wrote: > On Sun, Aug 19, 2012 at 4:48 PM, timothy adigun <2teezp...@gmail.com> > wrote: >> foreach my $match_value ( sort keys %stud ) { >> print $match_value, "=", $stud{$match_value}, >> $/ if $match_value ~~ @names; >> } > > "smart match" is a Perl

Re: matching array elements from hash ?

2012-08-20 Thread timothy adigun
Hi, > Hi Tim, > > Thanks, i tried to run the code, but get the error as below. Any thing i am > missing line 17. What version of Perl are you using? For smart matching to work you must have Perl 5.10.1 Up (the 5.10.0 version behaved differently). > syntax error at ./match2.p

Re: matching array elements from hash ?

2012-08-20 Thread Jim Gibson
The "smart match" operator (~~) was introduced in Perl 5.10. If you are using a Perl earlier than that, you will get a syntax error. See perldoc perl5100delta perldoc perlsyn and search for "Smart". -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: b

Re: matching array elements from hash ?

2012-08-20 Thread Andy Bach
On Sun, Aug 19, 2012 at 4:48 PM, timothy adigun <2teezp...@gmail.com> wrote: > foreach my $match_value ( sort keys %stud ) { > print $match_value, "=", $stud{$match_value}, > $/ if $match_value ~~ @names; > } "smart match" is a Perl 6 (though it probably back ported to a Perl 5 modul

Re: matching array elements from hash ?

2012-08-20 Thread jet speed
Thanks John, worked as a treat. Appreciate it. On Sun, Aug 19, 2012 at 11:18 PM, John W. Krahn wrote: > jet speed wrote: > >> Hi All, >> > > Hello, > > > Is there a way to find matching array elements from hash. >> >> ex: >> >> @n

Re: matching array elements from hash ?

2012-08-20 Thread jet speed
On Sun, Aug 19, 2012 at 10:48 PM, timothy adigun <2teezp...@gmail.com>wrote: > Hi, > > Please, Check my comments below. > > On 8/19/12, jet speed wrote: > > Hi All, > > > > Is there a way to find matching array elements from hash. > > > > ex:

Re: matching array elements from hash ?

2012-08-19 Thread John W. Krahn
jet speed wrote: Hi All, Hello, Is there a way to find matching array elements from hash. ex: @names = ( abc. def. ghi, jky; ); %stud = ( " abc" =>" 34", "nba" =>"99", "def" =>"24", "ghi"=> "33&quo

Re: matching array elements from hash ?

2012-08-19 Thread timothy adigun
Hi, Please, Check my comments below. On 8/19/12, jet speed wrote: > Hi All, > > Is there a way to find matching array elements from hash. > > ex: > > @names = ( abc. def. ghi, jky; ); The above should be @names=("abc","def","ghi",&qu

matching array elements from hash ?

2012-08-19 Thread jet speed
Hi All, Is there a way to find matching array elements from hash. ex: @names = ( abc. def. ghi, jky; ); %stud = ( " abc" =>" 34", "nba" =>"99", "def" =>"24", "ghi"=> "33"); How can i go through

Re: capture more than one regex matching (oneliner)

2012-03-29 Thread John W. Krahn
Christian wrote: Hi, Hello, is there easy way to capture more than one matching and print this out? In the example below the first matching is suppressed. cat file | perl -nle '/p2=(.+)(?=&p3)/&& /p13=(.+)(?=&p14)/&& print $. . ";" . $1 .

capture more than one regex matching (oneliner)

2012-03-29 Thread Christian
Hi, is there easy way to capture more than one matching and print this out? In the example below the first matching is suppressed. cat file | perl -nle '/p2=(.+)(?=&p3)/ && /p13=(.+)(?=&p14)/ && print $. . ";" . $1 . ";". $2' Thank

Re: multiple pattern matching

2012-03-08 Thread Rob Dixon
following patter matching logic but it does not get me the 1st number (2552) . @devs = $output =~ m/New symdev:\s*([0-9A-Fa-f]{4})/gis; print $output,"\n"; print "Devices>>>> @devs<<<<<<<<<

Re: multiple pattern matching

2012-03-08 Thread Chris Stinemetz
get those numbers like 2552 , 2553 . > > I am applying following patter matching logic but it does not get me the  1st > number (2552) . > > @devs = $output =~ m/New symdev:\s*([0-9A-Fa-f]{4})/gis; >                        print $output,"\n"; >                        pri

multiple pattern matching

2012-03-08 Thread Sunita.Pradhan
OMMITDone. New symdev: 2552 New symdev: 2553 Terminating the configuration change session..Done." ; I need to get those numbers like 2552 , 2553 . I am applying following patter matching logic but it does not get m

RE: Matching Greek letters in UTF-8 file

2011-10-10 Thread Hamann, T.D. (Thomas)
ey occur in two unique formats throughout the whole document (which should match \w- and -\w- ). Thomas Van: Brian Fraser [frase...@gmail.com] Verzonden: donderdag 29 september 2011 16:59 Aan: John Delacour CC: beginners@perl.org Onderwerp: Re: Matching G

Re: smart matching

2011-10-06 Thread John SJ Anderson
On Thu, Oct 6, 2011 at 03:10, Shlomi Fish wrote: > Furthermore, I think you can only put when inside given and not arbitrary > code, > and that "when()" operates on the datum that was given to given(). I don't think there's any restriction on what code can be inside the 'given' block -- at least

Re: smart matching

2011-10-06 Thread timothy adigun
Hi Chris, I think you will need to work on your code to make it better or maybe this is just a dirty codes for practice. If not, there are some stuff you may have to weed out...some of which Shlomi Fish mentioned. However, to make your code work as you suppose, please check this little addition a

Re: smart matching

2011-10-06 Thread Shlomi Fish
On Wed, 5 Oct 2011 23:44:21 -0500 Chris Stinemetz wrote: > trying to learn smart matching in an exercise. > > Why does this program output "odd" when I input an even number? > A few comments on your code. > Thank you, > > Chris > > #!/usr/bin/perl >

smart matching

2011-10-05 Thread Chris Stinemetz
trying to learn smart matching in an exercise. Why does this program output "odd" when I input an even number? Thank you, Chris #!/usr/bin/perl use warnings; use strict; use 5.010; say "Checking the number <$ARGV[0]>"; my $favorite = 62; given( $ARGV[0] ) {

Re: Matching Greek letters in UTF-8 file

2011-09-29 Thread John Delacour
At 17:29 -0300 29/9/11, Brian Fraser wrote: On Thu, Sep 29, 2011 at 4:03 PM, John Delacour wrote: Nitpick: Why the upper-case charset name? Uppercase is UTF-8-strict, while lowercase is the lax version that perl uses internally. Unless you are passing data from one perl program to anothe

Re: Matching Greek letters in UTF-8 file

2011-09-29 Thread Brian Fraser
On Thu, Sep 29, 2011 at 4:03 PM, John Delacour wrote: > > Nitpick: Why the upper-case charset name? > Uppercase is UTF-8-strict, while lowercase is the lax version that perl uses internally. Unless you are passing data from one perl program to another, and you are using illegal-UTF8-but-legal-UT

Re: Matching Greek letters in UTF-8 file

2011-09-29 Thread John Delacour
At 11:59 -0300 29/9/11, Brian Fraser wrote: On Thu, Sep 29, 2011 at 10:58 AM, John Delacour wrote: use encoding 'utf-8'; Nitpick: Please don't use this, as encoding is broken. use utf8; and use open qw< :std :encoding(UTF-8) >; should make do for a replacement. Nitpick: Why the upper-c

Re: Matching Greek letters in UTF-8 file

2011-09-29 Thread Brian Fraser
there's a bit of a difference in case-insensitive matching (i.e. using /i) -- newer versions of Perl do full casefolding (so \N{GREEK CAPITAL LETTER ALPHA WITH PSILI AND PROSGEGRAMMENI} matches \N{GREEK SMALL LETTER ALPHA WITH PSILI}\N{GREEK SMALL LETTER IOTA}), whereas older versions do

Re: Matching Greek letters in UTF-8 file

2011-09-29 Thread John Delacour
At 11:42 + 29/9/11, Hamann, T.D. (Thomas) wrote: I need to write a regex that matches any single Greek letter followed by a hyphen in a UTF-8 text file that is otherwise in English. How can I match the Greek alphabet (lower and upper case)? #!/usr/local/bin/perl use strict; use utf8; us

Matching Greek letters in UTF-8 file

2011-09-29 Thread Hamann, T.D. (Thomas)
Hi, I need to write a regex that matches any single Greek letter followed by a hyphen in a UTF-8 text file that is otherwise in English. How can I match the Greek alphabet (lower and upper case)? Thanks, Thomas -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands

Re: pattern matching regex

2011-09-27 Thread Shawn H Corey
On 11-09-27 05:30 PM, Chris Stinemetz wrote: Trying to match the what is contained in $what 3 consecutive times. But I am getting the followoing error: Use of uninitialized value $_ in pattern match (m//) at ./ex9-1.pl line 7. The program: #!/usr/bin/perl use warnings; use strict; my $what

pattern matching regex

2011-09-27 Thread Chris Stinemetz
Trying to match the what is contained in $what 3 consecutive times. But I am getting the followoing error: Use of uninitialized value $_ in pattern match (m//) at ./ex9-1.pl line 7. The program: #!/usr/bin/perl use warnings; use strict; my $what = 'fred|barney'; if (/($what){3}/) { print $wha

Re: trouble matching words with parentheses using grep

2011-04-10 Thread C.DeRykus
On Apr 9, 1:04 pm, alanhag...@alanhaggai.org (Alan Haggai Alavi) wrote: > > ... > > #!usr/bin/perl > > For increased portability, use the shebang #!/usr/bin/env perl > Hm, portable only in limited situations, risky, and always slower. From: http://www.webmasterkb.com/Uwe/Forum.aspx/perl/3968/

Re: trouble matching words with parentheses using grep

2011-04-09 Thread John W. Krahn
Mariano Loza Coll wrote: Hello everyone, Hello, Here's what I need to do: I need to take each of the words in one List1, search for their presence (or not) in a second List2 and make a new list with all the words in both. These are lists of gene names, which can often include numbers and symb

Re: trouble matching words with parentheses using grep

2011-04-09 Thread Alan Haggai Alavi
Hello Mariano, use List::MoreUtils qw( any each_array ); I was experimenting and forgot to take off `each_array` from the import list. `each_array` is not used in the alternative solution and is hence not required. Regards, Alan Haggai Alavi. -- The difference makes the difference -- To uns

Re: trouble matching words with parentheses using grep

2011-04-09 Thread Alan Haggai Alavi
Hello Mariano, I realize that there may be a number of ways to do what I need to do (most of them better, I bet), and I'd love to learn about them. But now I'm mostly curious about why grep// cannot "see" words with parentheses in either (or both lists). I suspect the trick may be somehow escapi

trouble matching words with parentheses using grep

2011-04-09 Thread Mariano Loza Coll
Hello everyone, Here's what I need to do: I need to take each of the words in one List1, search for their presence (or not) in a second List2 and make a new list with all the words in both. These are lists of gene names, which can often include numbers and symbols in addition to letters. The very

Re: Smart matching

2011-01-18 Thread Vladimir D Belousov
19.01.2011 0:43, Brian Fraser пишет: The smart match is no longer commutative - That was removed after 5.10.1, I think. http://www.learning-perl.com/?p=32 http://perldoc.perl.org/perlsyn.html#Smart-matching-in-detail Brian. Thank you! -- To unsubscribe, e-mail: beginners-unsubscr

Re: Smart matching

2011-01-18 Thread Brian Fraser
The smart match is no longer commutative - That was removed after 5.10.1, I think. http://www.learning-perl.com/?p=32 http://perldoc.perl.org/perlsyn.html#Smart-matching-in-detail Brian.

Re: Smart matching

2011-01-18 Thread Vladimir D Belousov
19.01.2011 0:09, Uri Guttman пишет: but why don't you just call exists on the hash key? there is no win to using smart matching for that. it is included for consistancy but it isn't needed for hash keys. I just want to understand how does it work :) -- To unsubscribe, e-mail:

Re: Smart matching

2011-01-18 Thread Uri Guttman
>>>>> "VDB" == Vladimir D Belousov writes: VDB> I'm trying to check whether the given key exists in the hash. smart matching is powerful and cool but why don't you just call exists on the hash key? there is no win to using smart matching for that. it is

Smart matching

2011-01-18 Thread Vladimir D Belousov
I'm trying to check whether the given key exists in the hash. The simple example: use feature ':5.10'; my %a = (a => 1, b => 2); say %a ~~ 'a' ? 'YES' : 'NO';# says NO -- why? say %a ~~ 'c' ? 'YES' : 'NO';# says NO say 'a' ~~ %a ? 'YES' : 'NO';# says YES say 'c' ~~ %a ? 'YES' : 'NO';

Re: regex for matching Google URLs

2011-01-18 Thread Octavian Rasnita
From: "Uri Guttman" "AM" == Alexey Mishustin writes: AM> I used brackets not for storing but for combining in order to use the AM> combined patterns in alternation. the point is parens (the correct term. brackets are []) is they will grab the match inside them and store it in $1 and friend

Re: regex for matching Google URLs

2011-01-18 Thread Alexey Mishustin
1/18/2011, "Uri Guttman" вы писали: >> "AM" == Alexey Mishustin writes: > > AM> 1/18/2011, "Uri Guttman" РІС‹ писали: > > >>> "AM" == Alexey Mishustin writes: > >> > AM> I used brackets not for storing but for combining in order to use the > AM> combined patterns in altern

Re: regex for matching Google URLs

2011-01-18 Thread Uri Guttman
> "AM" == Alexey Mishustin writes: AM> 1/18/2011, "Uri Guttman" вы писали: >>> "AM" == Alexey Mishustin writes: >> AM> I used brackets not for storing but for combining in order to use the AM> combined patterns in alternation. >> >> the point is parens >> (the corre

Re: regex for matching Google URLs

2011-01-18 Thread Uri Guttman
> "AM" == Alexey Mishustin writes: AM> 1/18/2011, "Alexey Mishustin" вы писали: >> I meant >> >> (imgres) >> >> OR >> >> (images) >> >> OR >> >> (products) AM> Uri wrote the correct alternation for that: AM> (imgres|images|products) AM> So, I should wri

Re: regex for matching Google URLs

2011-01-18 Thread Alexey Mishustin
1/18/2011, "Uri Guttman" вы писали: >> "AM" == Alexey Mishustin writes: > > AM> I used brackets not for storing but for combining in order to use the > AM> combined patterns in alternation. > >the point is parens >(the correct term. brackets are []) Eh... Useful correction. And what is

Re: regex for matching Google URLs

2011-01-18 Thread Alexey Mishustin
1/18/2011, "Uri Guttman" вы писали: >> "AM" == Alexey Mishustin writes: > AM> /(www.){0,1}(google\.).*\/(imgres)|(images)|(products)\?{0,1}/ > >> > >> {0,1} is just ? by itself. > > AM> Yes, I know. But I like the {a,b} syntax more :) It's more uniform than > AM> ?,+,* etc. > >it is

  1   2   3   4   5   6   7   8   9   10   >