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

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 is nothing

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

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 char...@pulsenet.comwrote: 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

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 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 1. using stricts

RE: Pattern matching to hash

2012-12-28 Thread Tim Lewis
Thank you Chris. Using strict and warnings should have been the first thing that I did. Thank you also for the code correction. -Original Message- From: Chris Charley [mailto:char...@pulsenet.com] Sent: Friday, December 28, 2012 5:52 PM To: beginners@perl.org Subject: Re: Pattern

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 char...@pulsenet.comwrote: [snip] I only answered the question using a for loop. Am

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

Re: Pattern matching problem - Why won't this work?

2010-04-13 Thread Peter Scott
On Mon, 12 Apr 2010 23:04:53 -0500, Owen Chavez wrote: Can you suggest a reference on hashes that will provide some clue as to how they can be used for the problem I posted? I've looked over Programming Perl (3rd) and it's not entirely clear to me how to proceed with a hash. Learning Perl

Re: Pattern matching problem - Why won't this work?

2010-04-13 Thread Shawn H Corey
Owen Chavez wrote: Hello! I have a pattern matching question using Perl 5.10, Windows 7. Suppose I have a file containing the following block of text: Hello there TODD I my We Us ourselves OUr I. The file has 10 words, including 7 first-person pronouns (and 3 non-pronouns that I have no

Re: Pattern matching problem - Why won't this work?

2010-04-12 Thread Peter Scott
On Mon, 12 Apr 2010 21:06:58 -0500, Owen Chavez wrote: I have a pattern matching question using Perl 5.10, Windows 7. Suppose I have a file containing the following block of text: Hello there TODD I my We Us ourselves OUr I. The file has 10 words, including 7 first-person pronouns (and 3

Re: Pattern matching problem - Why won't this work?

2010-04-12 Thread Owen Chavez
Thank you for the feedback. I do apologize for not posting a working example; I can't post the full code and I was attempting to extract the offending sections. I have no particular fondness for grep. A search of postings on perlmonks revealed a variation of the code I employed. I am learning

Re: Pattern matching question

2009-03-31 Thread Telemachus
On Tue Mar 31 2009 @ 3:32, Richard Hobson wrote: It works, but is there a way of combining these lines: my $piece = $ref-[$_]; $piece =~ /.*(..$)/; It feels like this could be done in one step. Is this correct? I'm finding that I'm doing

Re: Pattern matching question

2009-03-31 Thread John W. Krahn
Richard Hobson wrote: Hi, Hello, Please be patient with this beginner. I have a subrouting as follows, that prints out an ASCII representation of chess board sub display_board { foreach (0..7) { my $ref = @_[$_]; That should be: my $ref = $_[$_]; Or better:

RE: pattern matching question

2008-09-23 Thread sanket vaidya
Hi Anjan, Not able to get what your column is. I am Assuming your column is in Text file. However even if it is not in text file, then this may provide you a fair hint about how to proceed further. use warnings; use strict; open FH,example.txt or die Cannot open file: $!; #(example.txt

Re: pattern matching question

2008-09-23 Thread Mr. Shawn H. Corey
On Mon, 2008-09-22 at 21:21 -0400, ANJAN PURKAYASTHA wrote: here is my problem: i have to check the entries of a column and write them out to a file if they happen to be DNA sequences ie they are exclusively composed of the letters A, T, G, C- no spaces or digits. the column also happens to

RE: pattern matching question

2008-09-23 Thread sanket vaidya
Hi Anjan, Not able to get where your column is. I am Assuming your column is in Text file. However even if it is not in text file, then also this may provide you a fair hint about how to proceed further. use warnings; use strict; open FH,example.txt or die Cannot open file: $!;

Re: pattern matching question

2008-09-23 Thread ANJAN PURKAYASTHA
hi all, the column is in a text file. fyi, david's pattern matching expression (/^[ATGC]+$/i) did the job perfectly. thanks all for you feedback! anjan On Tue, Sep 23, 2008 at 5:07 AM, sanket vaidya [EMAIL PROTECTED]wrote: Hi Anjan, Not able to get where your column is. I am Assuming

Re: Pattern matching question

2008-09-23 Thread Mr. Shawn H. Corey
On Tue, 2008-09-23 at 14:05 -0700, Darren Nay wrote: Here is the string: xsl:output method=html encoding=utf-8 indent=yes doctype-system=http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; doctype-public=-//W3C//DTD XHTML 1.0 Transitional//EN / Now, I want to match against that string

RE: pattern matching question

2008-09-22 Thread Dave
-Original Message- From: ANJAN PURKAYASTHA [mailto:[EMAIL PROTECTED] Sent: Tuesday, 23 September 2008 11:22 AM To: beginners@perl.org Subject: pattern matching question here is my problem: i have to check the entries of a column and write them out to a file if they happen to be DNA

Re: Pattern matching problem

2008-02-29 Thread Gunnar Hjalmarsson
Anirban Adhikary wrote: Subject: Pattern matching problem As far as I can tell, this is not a pattern matching problem. I have a very large file basically it is logfile generated by sql loader. In the production environment this file can have one million/ two million data. In this

Re: Pattern matching

2007-02-21 Thread Dr.Ruud
Dharshana Eswaran schreef: TAPI_VOICE_NOTIFY_OTHERAPP_JOINING_MSGID TAPI_TTY_NOTIFY_TTY_TONE_MSGID [...] Can anyone help me in getting a generalised pattern from these? m/^ TAPI (?:_[A-Z]+)+ $/x -- Affijn, Ruud Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For

Re: Pattern matching

2007-02-21 Thread Dharshana Eswaran
On 2/21/07, Dr.Ruud [EMAIL PROTECTED] wrote: Dharshana Eswaran schreef: TAPI_VOICE_NOTIFY_OTHERAPP_JOINING_MSGID TAPI_TTY_NOTIFY_TTY_TONE_MSGID [...] Can anyone help me in getting a generalised pattern from these? m/^ TAPI (?:_[A-Z]+)+ $/x -- Affijn, Ruud Gewoon is een tijger. -- To

Re: Pattern matching

2007-02-21 Thread Dharshana Eswaran
On 2/21/07, Dharshana Eswaran [EMAIL PROTECTED] wrote: On 2/21/07, Dr.Ruud [EMAIL PROTECTED] wrote: Dharshana Eswaran schreef: TAPI_VOICE_NOTIFY_OTHERAPP_JOINING_MSGID TAPI_TTY_NOTIFY_TTY_TONE_MSGID [...] Can anyone help me in getting a generalised pattern from these? m/^ TAPI

Re: Pattern matching

2007-02-21 Thread Dr.Ruud
Dharshana Eswaran schreef: m/^ #TAPI (?:_[A-Z]+)+ $/x But this is filtering both the strings starting from TAPI and the strings starting from #TAPI. Yes, # starts a comment, so makes the regex equivalent to m/^/, which will allways match. echo 'abc' | perl -nle ' /^ # test/x and

Re: Pattern Matching

2007-01-21 Thread Dharshana Eswaran
On 1/19/07, Igor Sutton [EMAIL PROTECTED] wrote: I have an update: my @data = $string =~ m/0x(\d{2})/g; my @data = $string =~ m/0x(\S{2}),?/g; Now I think it is right :) -- Igor Sutton Lopes [EMAIL PROTECTED] I used the above expression and it worked for me. Thanks you so much. Thanks

Re: Pattern Matching

2007-01-21 Thread Dharshana Eswaran
On 1/19/07, Rob Dixon [EMAIL PROTECTED] wrote: Igor Sutton wrote: I have an update: my @data = $string =~ m/0x(\d{2})/g; my @data = $string =~ m/0x(\S{2}),?/g; Now I think it is right :) my @data = $string =~ m/=0x(..)/g; :) Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For

Re: Pattern Matching

2007-01-21 Thread Dharshana Eswaran
On 1/19/07, John W. Krahn [EMAIL PROTECTED] wrote: Dharshana Eswaran wrote: Hi All, Hello, I have a string as shown below: $string = {[0]=0x53,[1]=0x65,[2]=0x63,[3]=0x75,[4]=0x72,[5]=0x69,[6]=0x74,[7]=0x79,[8]=0x43,[9]=0x6F,[10]=0x64,[11]=0x65,[12]=0x00} This is stored as a string in

Re: Pattern Matching

2007-01-19 Thread Igor Sutton
Hi Dharshana, 2007/1/19, Dharshana Eswaran [EMAIL PROTECTED]: Hi All, I have a string as shown below: $string = {[0]=0x53,[1]=0x65,[2]=0x63,[3]=0x75,[4]=0x72,[5]=0x69,[6]=0x74,[7]=0x79,[8]=0x43,[9]=0x6F,[10]=0x64,[11]=0x65,[12]=0x00} This is stored as a string in a variable. I need to pull

Re: Pattern Matching

2007-01-19 Thread Igor Sutton
I have an update: my @data = $string =~ m/0x(\d{2})/g; my @data = $string =~ m/0x(\S{2}),?/g; Now I think it is right :) -- Igor Sutton Lopes [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Pattern Matching

2007-01-19 Thread Rob Dixon
Igor Sutton wrote: I have an update: my @data = $string =~ m/0x(\d{2})/g; my @data = $string =~ m/0x(\S{2}),?/g; Now I think it is right :) my @data = $string =~ m/=0x(..)/g; :) Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Pattern Matching

2007-01-19 Thread John W. Krahn
Dharshana Eswaran wrote: Hi All, Hello, I have a string as shown below: $string = {[0]=0x53,[1]=0x65,[2]=0x63,[3]=0x75,[4]=0x72,[5]=0x69,[6]=0x74,[7]=0x79,[8]=0x43,[9]=0x6F,[10]=0x64,[11]=0x65,[12]=0x00} This is stored as a string in a variable. I need to pull out only the numbers

Re: Pattern Matching

2006-07-24 Thread Rob Dixon
[EMAIL PROTECTED] wrote: [EMAIL PROTECTED] writes: [EMAIL PROTECTED] wrote: Hi, I am a beginner in perl and am having a dickens of a time trying to identify this pattern in messages. [URL Here is what I have: if ($FORM{'message} =~ /\[URL/ig) { #do something; } Where

Re: Pattern Matching

2006-07-23 Thread John Ackley
[EMAIL PROTECTED] wrote: Hi, I am a beginner in perl and am having a dickens of a time trying to identify this pattern in messages. [URL Here is what I have: if ($FORM{'message} =~ /\[URL/ig) { #do something; } Where $FORM('message') is a messaage that includes many

Re: Pattern Matching

2006-07-23 Thread Jimstone77
In a message dated 7/23/2006 9:39:34 A.M. Pacific Standard Time, [EMAIL PROTECTED] writes: [EMAIL PROTECTED] wrote: Hi, I am a beginner in perl and am having a dickens of a time trying to identify this pattern in messages. [URL Here is what I have: if

Re: pattern matching

2006-07-18 Thread Rob Dixon
Ryan Dillinger wrote: Hello All, I was studying some pattern matching. And I ran into this piece of code. Now I believe I understand it up until the the last part \1. Can someone explain it for me please? Match lowercase a through z, uppercase A through lc z no more than three times, with white

Re: pattern matching

2006-07-18 Thread Dr.Ruud
Timothy Johnson schreef: You should south-post. You should trim. \1 is the same thing as $1 inside of a regex, but it is generally recommended that you don't use it. That is a misinterpretation. It is OK (and efficient) to use the backreferences \1, \2, \3 etc. in a regex. The \1 (as a

RE: pattern matching

2006-07-17 Thread Timothy Johnson
\1 is the same thing as $1 inside of a regex, but it is generally recommended that you don't use it. From 'perldoc perlre': Warning on \1 vs $1 Some people get too used to writing things like: $pattern =~ s/(\W)/\\\1/g; This is grandfathered for the RHS of a substitute to

Re: pattern matching

2006-07-17 Thread Tom Phoenix
On 7/17/06, Ryan Dillinger [EMAIL PROTECTED] wrote: Now I believe I understand it up until the the last part \1. /([a-zA-z]{3})\s*\1/ That's a backreference; it matches if the corresponding part of the string is equal to what's in memory one at the time of the match. Memory one holds the

Re: pattern matching

2006-07-17 Thread Alan_C
On Monday 17 July 2006 18:20, Timothy Johnson wrote: \1 is the same thing as $1 inside of a regex, but it is generally recommended that you don't use it. I thought it's ok to use it in a match or on the *left* side (but not on the right side) of a substitution then I'm stumped, what's the 1

Re: pattern matching

2006-07-17 Thread John W. Krahn
Ryan Dillinger wrote: Hello All, Hello, I was studying some pattern matching. And I ran into this piece of code. Now I believe I understand it up until the the last part \1. Can someone explain it for me please? Match lowercase a through z, uppercase A through lc z That must be a mistake

Re: pattern matching problems

2006-07-08 Thread Mike Williams
Dr. Claus-Peter Becke wrote: foreach (/(\w+)/i) { push @words,$; } print$q-popup_menu('to_thesaurus', @words); this solution succeeds in finding and returning the last element... There are a few problems here: 1. regex should use the /g modifier to find all matches in the string

Re: pattern matching problems

2006-07-08 Thread Mumia W.
Dr. Claus-Peter Becke wrote: [...] foreach (/(\w+)/i) { push @words,$; } print$q-popup_menu('to_thesaurus', @words); [...] Use the /g (global) option to the match operator, and push $_ onto @words rather than $: foreach (/(\w+)/ig) { push @words, $_; } Or ditch the 'foreach'

Re: pattern matching problems

2006-07-08 Thread Mumia W.
Dr. Claus-Peter Becke wrote: dear mumia w., thank you for your support. i have chosen the simplest solution you recommanded. i still have one problem. i would like to print every word in a new line. push @woerter,/[a-zäöüß]/ig; print$q-li(@woerter); it's unfortunaltely impossible to

Re: Pattern Matching

2006-06-08 Thread anu p
Hi, Sorry, it was working, found out the problem was due to something else. Thanks, Anu. --- anu p [EMAIL PROTECTED] wrote: Hi, I have the following code snippet in which I open two files for read. For each line in file 1 (log.txt), I extract the test name, which is of format

Re: Pattern Matching Question

2005-11-28 Thread Dr.Ruud
Dax Mickelson schreef: I am having problems matching ALL possible matches of a string against another (very large) string. I am doing something like: @LargeArray = ($HugeString =~ m/$Head/ig); Where $Head is an 8 character string. (Basically I want to get all 16 character long

Re: Pattern Matching Question

2005-11-28 Thread Dr.Ruud
Dr.Ruud: #!/usr/bin/perl use strict; use warnings; { local ($,, $\) = (':', \n); $_ = 'AASDFGHJKL'; my $Head = ''; print $Head, $1, substr($',0,7) while /(?=$Head)(.)(?=.{7})/ig; } Revision: #!/usr/bin/perl use strict; use warnings; my

Re: Pattern Matching Question

2005-11-28 Thread Jeff 'japhy' Pinyan
On Nov 27, Dax Mickelson said: I am having problems matching ALL possible matches of a string against another (very large) string. I am doing something like: @LargeArray = ($HugeString =~ m/$Head/ig); Where $Head is an 8 character string. (Basically I want to get all 16 character

RE: Pattern Matching Question

2005-11-27 Thread S, karthik \(IE03x\)
Hope you are getting what you require.. If not, what you expect the result to be? With Best Regards, Karthikeyan S Honeywell Process Solutions - eRetail Honeywell Automation India Limited Phone:91-20-56039400 Extn -2701 Mobile :(0)9325118422 E-Mail: [EMAIL PROTECTED] This e-mail, and any

Re: Pattern Matching Question

2005-11-27 Thread John W. Krahn
Dax Mickelson wrote: I am having problems matching ALL possible matches of a string against another (very large) string. I am doing something like: @LargeArray = ($HugeString =~ m/$Head/ig); Where $Head is an 8 character string. (Basically I want to get all 16 character long

Re: pattern matching question - please help

2005-06-19 Thread MEENA SELVAM
Hi , in $prog =~ s/^.*\///; is it trying to substitute all characters until the last / within $prog? meena --- MEENA SELVAM [EMAIL PROTECTED] wrote: Hi, can anyone please explain? In the following code snippet, what is the meaning of the pattern match s/^.*\/// $prog = $0; $prog

Re: pattern matching question - please help

2005-06-19 Thread Chris Devers
On Sun, 19 Jun 2005, MEENA SELVAM wrote: can anyone please explain? See `perldoc perlre`, or `man perlre`, or a book like _Learning Perl_ or _Mastering Regular Expressions_ for this kind of thing. It's really an introductory question that any decent introductory text should be able to cover

Re: pattern matching question - please help

2005-06-19 Thread MEENA SELVAM
Hi Chris, Thanks for your detailed email and for your time. I think my second email crossed your email. The book I read on Perl did not mention anything about first and second half, and that didnt explain, me that we were replacing all upsto last / by nothing. I thought it is replacing with /

Re: Pattern matching problem

2005-05-10 Thread John Doe
Am Dienstag, 10. Mai 2005 11.01 schrieb Tielman Koekemoer (TNE): Hi all, I have tried various regular expressions to remove null or empty values on array @array1 and create a new array @OPD01 with the values. This, however, does not work as I still get a number of empty values in the @OPD01

Re: Pattern matching problem

2005-05-10 Thread Ing. Branislav Gerzo
Tielman Koekemoer (TNE) [TK], on Tuesday, May 10, 2005 at 11:01 (+0200) contributed this to our collective wisdom: TK I have tried various regular expressions to remove null or empty TK values on array @array1 and create a new array @OPD01 with the values. TK This, however, does not work as I

Re: Pattern matching problem

2005-05-10 Thread Kpramod
Hi John, Try to use 'chop' to get null value Thanks and Regards Pramod John Doe wrote: Am Dienstag, 10. Mai 2005 11.01 schrieb Tielman Koekemoer (TNE): Hi all, I have tried various regular expressions to remove null or empty values on array @array1 and create a new array @OPD01 with the values.

RE: Pattern matching problem

2005-05-10 Thread Tielman Koekemoer \(TNE\)
$counter2 = 0; What's that for? (never used) Hmm yeah sorry that was supposed to be $counter = 0; Use push() to avoid holding the current array index. What do you mean by holding the index? my @array1=(' ', 'a', '', 'b', \0, 'c', undef, 'd', ' ', 'e'); my @new=grep {$_ and !/^\s+$/ and

RE: Pattern matching problem

2005-05-10 Thread Tielman Koekemoer \(TNE\)
Ah I see: use push() to add scalars/lists to arrays. Thanks everyone for the help. Use push() to avoid holding the current array index. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response

Re: Pattern matching problem

2005-05-10 Thread John Doe
Am Dienstag, 10. Mai 2005 11.46 schrieb Tielman Koekemoer (TNE): $counter2 = 0; What's that for? (never used) Hmm yeah sorry that was supposed to be $counter = 0; Use push() to avoid holding the current array index. What do you mean by holding the index? remember (and incrementing) the

Re: Pattern matching problem

2005-05-10 Thread John Doe
Am Dienstag, 10. Mai 2005 11.23 schrieb Kpramod: Hi John, Try to use 'chop' to get null value Thanks and Regards Pramod Hi Pramad, sorry, I don't understand what you mean. Do you refer to the line my @new=grep {$_ and !/^\s+$/ and !/^\0+$/} @array1; (I see that the test for \0 is ugly,

Re: Pattern matching to identify comma separated text

2005-03-08 Thread Wiggins d'Anconia
Chris Schults wrote: I'm sending this on behalf of our intern Elmer. Thanks in advance for any assistance. Chris Hi there! If anyone out there is good with Perl's pattern matching, maybe you can help me out. I am trying to take a string and derive information from it that is separated by commas

Re: pattern matching

2005-03-02 Thread John W. Krahn
Aaron Reist wrote: From: John W. Krahn [EMAIL PROTECTED] Aaron Reist wrote: From: John W. Krahn [EMAIL PROTECTED] You could use a regular expression to do that. my $input = get_input_from_user(); $input =~ /\A(?:[[:alpha:]]([[:alnum:]]{9})[[:alpha:]]|(\d[[:alnum:]]{7}\d))\z/ and my

Re: pattern matching

2005-02-28 Thread John W. Krahn
Aaron Reist wrote: From: John W. Krahn [EMAIL PROTECTED] Aaron Reist wrote: Currently I have a simple program takes a username from a html textbox and checks against a list of values in a notepad document. If the name is found the user is given access, if not they are prompted to try again.

Re: pattern matching

2005-02-25 Thread John W. Krahn
Aaron Reist wrote: Hello everyone, Hello, not quite sure if what I m trying to do is possible, but here is the basic idea: Currently I have a simple program takes a username from a html textbox and checks against a list of values in a notepad document. If the name is found the user is given

Re: pattern matching

2005-02-24 Thread Ing. Branislav Gerzo
Aaron Reist [AR], on Friday, February 25, 2005 at 01:58 (-0500) typed the following: AR The program will check for two types of usernames - the first is #xxx# AR (9 alphanumeric characters. beginning and ending with a number)the AR second is XxX (11 alphanumeric charactors, the

Re: Pattern matching variables

2005-01-13 Thread John W. Krahn
Dan Fish wrote: Are ALL pattern matching variables set back to undef once another m// or s/// expression is encountered, even if it contains no parenthized expressions? perldoc perlre [snip] The numbered match variables ($1, $2, $3, etc.) and the related punctuation set ($+, $, $`,

Re: Pattern matching variables

2005-01-13 Thread Tor Hildrum
On Wed, 12 Jan 2005 17:27:46 -0700, Dan Fish [EMAIL PROTECTED] wrote: Are ALL pattern matching variables set back to undef once another m// or s/// expression is encountered, even if it contains no parenthized expressions? For example, I would have expected $1 $2 to be valid in BOTH print

Re: pattern matching question

2004-12-23 Thread Jonathan Paton
i'm trying to figure out how to split a file delimited by commas and newlines. Sounds like a CSV file to me, and for those you look on CPAN for a ready made solution. http://search.cpan.org/search?query=CSVmode=module Jonathan Paton -- #!perl $J=' 'x25 ;for (qq 1+10 9+14 5-10 50-9 7+13 2-18

Re: pattern matching question

2004-12-23 Thread Chris Charley
- Original Message - From: John McCormick i'm trying to figure out how to split a file delimited by commas and newlines. @data = split (/\n|\,/, infile) the only problem is that some of the data fields are strings enclosed in double quotes, and within some of those double quotes are

Re: pattern matching question

2004-12-23 Thread Chris Devers
On Thu, 23 Dec 2004, John McCormick wrote: i'm trying to figure out how to split a file delimited by commas and newlines. @data = split (/\n|\,/, infile) the only problem is that some of the data fields are strings enclosed in double quotes, and within some of those double quotes are more

Re: pattern matching

2004-11-01 Thread Robert Citek
On Sunday, Oct 31, 2004, at 21:11 US/Central, John W. Krahn wrote: Robert Citek wrote: On Saturday, Oct 30, 2004, at 20:52 US/Central, John W. Krahn wrote: [EMAIL PROTECTED] wrote: I have to match patterns of the format string1string2 where the strings 1 2 can contain alphabets,numbers and

Re: pattern matching

2004-10-31 Thread Robert Citek
On Saturday, Oct 30, 2004, at 20:52 US/Central, John W. Krahn wrote: [EMAIL PROTECTED] wrote: I have to match patterns of the format string1string2 where the strings 1 2 can contain alphabets,numbers and spaces. The string are separated by '' sign. I wrote the following code for this.

Re: pattern matching

2004-10-31 Thread mk76
I used this solution if(/([a-z0-9\t ]*)([a-z0-9\t ]*)/gi) { $string1 = $1; $string2 = $2; } Quoting Robert Citek [EMAIL PROTECTED]: On Saturday, Oct 30, 2004, at 20:52 US/Central, John W. Krahn wrote: [EMAIL PROTECTED] wrote: I have to match patterns of the format

Re: pattern matching

2004-10-31 Thread Gunnar Hjalmarsson
[EMAIL PROTECTED] wrote: I used this solution if(/([a-z0-9\t ]*)([a-z0-9\t ]*)/gi) { $string1 = $1; $string2 = $2; } That was the one I suggested. It may or may not be a decent solution for what you are doing; I for one can't tell without knowing more. One detail: The /g modifier is

Re: pattern matching

2004-10-31 Thread Don VanSyckel
The original regex matched on lower case then uper case then digits then white space then the separator then lower case then uper case then digits then white space This is not what you wanted. If '' is the separator then you should match on: anything other than the separator

Re: pattern matching

2004-10-31 Thread John W. Krahn
Robert Citek wrote: On Saturday, Oct 30, 2004, at 20:52 US/Central, John W. Krahn wrote: [EMAIL PROTECTED] wrote: I have to match patterns of the format string1string2 where the strings 1 2 can contain alphabets,numbers and spaces. The string are separated by '' sign. I wrote the following code

Re: pattern matching

2004-10-30 Thread Gunnar Hjalmarsson
[EMAIL PROTECTED] wrote: I have to match patterns of the format string1string2 where the strings 1 2 can contain alphabets,numbers and spaces. The string are separated by '' sign. I wrote the following code for this. if(/([a-z]*[A-Z]*[0-9]*[\s]*)([a-z]*[A-Z]*[\s]*[0-9]*)/g) { $string1 = $1;

Re: pattern matching

2004-10-30 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Hi All, Hello, I have to match patterns of the format string1string2 where the strings 1 2 can contain alphabets,numbers and spaces. The string are separated by '' sign. I wrote the following code for this. if(/([a-z]*[A-Z]*[0-9]*[\s]*)([a-z]*[A-Z]*[\s]*[0-9]*)/g) {

Re: Pattern Matching records from a table query.

2004-07-19 Thread jason corbett
Thanks James. I am going to try this method also. Your input is very much appreciated. JC James Edward Gray II [EMAIL PROTECTED] wrote: On Jul 16, 2004, at 3:46 PM, jason corbett wrote: I want to eliminate the . (periord) or , (comma) from records that I return from a query, but I cannot

Re: Pattern Matching records from a table query.

2004-07-17 Thread Adam
Jason, I want to eliminate the . (periord) or , (comma) from records that I return from a query, but I cannot figure out how to approach it. Does Perl have a way that I can match a string that from an array, remove a character or characters? Yes. You could use a regular expression s/\.//

Re: Pattern Matching records from a table query.

2004-07-16 Thread James Edward Gray II
On Jul 16, 2004, at 3:46 PM, jason corbett wrote: I want to eliminate the . (periord) or , (comma) from records that I return from a query, but I cannot figure out how to approach it. Does Perl have a way that I can match a string that from an array, remove a character or characters? For

RE: Pattern Matching records from a table query.

2004-07-16 Thread Charles K. Clarkson
jason corbett [EMAIL PROTECTED] wrote: : I want to eliminate the . (periord) or , (comma) from : records that I return from a query, but I cannot figure out : how to approach it. Does Perl have a way that I can match a : string that from an array, remove a character or characters? : : : For

RE: pattern matching binary or garbage characters in string

2004-07-01 Thread christopher . l . hood
Thanks to all that helped with this problem, and thanks especially to RandyS as he hit the nail on the head. Here is the final working code block below. while (LOGFILE) { chop $_ ; if( (/JUNIPER/) || (/REDBACK/) ){ print DSL $_ . \n; } else {

Re: pattern matching binary or garbage characters in string

2004-06-30 Thread Gunnar Hjalmarsson
Christopher L Hood wrote: I have a log file with thousands of lines, some of those lines come in with garbage / binary data in them. The lines with that happening are junk and of no use to me I want to pattern match for the junk and simply do nothing with that line, all other lines get divided

Re: pattern matching binary or garbage characters in string

2004-06-30 Thread Randy W. Sims
On 6/30/2004 5:20 PM, [EMAIL PROTECTED] wrote: I have a log file with thousands of lines, some of those lines come in with garbage / binary data in them. The lines with that happening are junk and of no use to me I want to pattern match for the junk and simply do nothing with that line, all other

Re: pattern matching binary or garbage characters in string

2004-06-30 Thread John W . Krahn
On Wednesday 30 June 2004 15:07, Randy W. Sims wrote: try either: /[:print:]/ print junk; So you are saying that the characters ':', 'p', 'r', 'i', 'n' and 't' are junk? You probably meant to use the character class [^[:print:]] or [[:^print:]] instead. :-) John -- use Perl; program

Re: pattern matching

2004-06-23 Thread James Edward Gray II
On Jun 23, 2004, at 12:34 PM, [EMAIL PROTECTED] wrote: Hi, I have a string similar to: Comment: FILING --- - This is read in as one line (with the page feed). I was trying to whatever follows the words and I tried

Re: pattern matching

2004-06-23 Thread James Edward Gray II
(Let's keep our discussion on the list for all to see.) On Jun 23, 2004, at 12:44 PM, [EMAIL PROTECTED] wrote: Let's try to get a little simpler with our approach. Does this grab what you need? m/(\W+)$/ James What a quick response. Thanks. No problem. I assume you mean do this? Am I right?

Re: pattern matching

2004-06-23 Thread Murzc
OK. I am reading a file. This line is at the bottom of the file and the ---** is a sign that the section is complete. I need to be able to pick up that line, and see if there is also code on the beginning of that line that I need to save. So in this case I was searching for

RE: pattern matching

2004-06-23 Thread Bob Showalter
[EMAIL PROTECTED] wrote: Hi, I have a string similar to: Comment: FILING --- - This is read in as one line (with the page feed). I was trying to whatever follows the words and I tried this. Trying to remove?

Re: pattern matching

2004-06-23 Thread Murzc
Would something like this do the trick? $_ = $1 if /((\s*\w+:?)+)/; True. But I need to test the line to see if it contains those '*--**'. Otherwise how do I know that the line needs to be edited. (I am reading a file with many lines. I have to detect when the line comes with

Re: pattern matching

2004-06-23 Thread James Edward Gray II
On Jun 23, 2004, at 12:59 PM, [EMAIL PROTECTED] wrote: OK. I am reading a file. This line is at the bottom of the file and the ---** is a sign that the section is complete. This may be a sign that you aren't reading the file in the easiest possible way. I wonder if setting the

RE: Pattern matching line by line

2004-06-16 Thread Marcos . Rebelo
why not to split the String first something like foreach my $line (split(/\n/, $a)) { if ($line =~ /whatever/) { print $line; } } shall do the trick Marcos -Original Message- From: bzzt [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 16, 2004 1:33 PM To: [EMAIL

Re: Pattern matching line by line

2004-06-16 Thread Jeff 'japhy' Pinyan
On Jun 16, bzzt said: I'm trying to match a patern in a string but I want to do it a line at a time. Is there an easier way than this : while ($a =~ m/(.+?)\n/g ) { if ($1 =~ /whatever/g) { print $1; } Your regex, /(.+?)\n/, is unnecessarily complex. The ? modifier on .+ isn't

Re: Pattern matching \b

2004-06-14 Thread Jeff 'japhy' Pinyan
On Jun 14, [EMAIL PROTECTED] said: $field = Search, This is part of the code.; I have marked the word boundaries (the places in your string that are matched by \b) with # signs: #Search#, #This# #is# #part# #of# #the# #code#. A word boundary is defined as the position in a string where a word

Re: Pattern matching \b

2004-06-14 Thread Roberto Etcheverry
[EMAIL PROTECTED] wrote: $field = Search, This is part of the code.; ## We need to split by spaces. The issue is that the comma comes along. local(@words) = split('\s+', $field); foreach $word (@words) { if ($word =~ /Search/i) { $word =~ s/[,\]\)\}]\b//; $word =~

Re: Pattern Matching

2004-04-06 Thread James Edward Gray II
On Apr 6, 2004, at 7:46 AM, prabu wrote: Hi, Howdy. I want to match a pattern and replace with another string.Since the ? is also one of the character present in the string. I am not able to do it. I bet we can fix that. Please help to how to make ? acceptable in the string used for

Re: Pattern matching problem

2004-02-26 Thread Henry Todd
On 2004-02-26 00:43:21 +, [EMAIL PROTECTED] (Wolf Blaum) said: As I understand Biology, there is 4 nucleotid acids which gives 4**2 combinaions for dupplets. So you need 8 vars to count the occourence of all douplets. Worse for triplets. (24) As I understand genetics, triplets are what

Re: Pattern matching problem

2004-02-26 Thread wolf blaum
On Thursday 26 February 2004 12:28, Henry Todd generously enriched virtual reality by making up this one: On 2004-02-26 00:43:21 +, [EMAIL PROTECTED] (Wolf Blaum) said: As I understand Biology, there is 4 nucleotid acids which gives 4**2 combinaions for dupplets. So you need 8 vars to

  1   2   3   >