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

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

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

multiple pattern matching

2012-03-08 Thread Sunita.Pradhan
Hi All I have one output of one my command like : $output = Step 155 of 171 steps.Executing. Step 168 of 171 steps.Executing. Step 171 of 171 steps.Executing. Local:

Re: multiple pattern matching

2012-03-08 Thread Chris Stinemetz
On Thu, Mar 8, 2012 at 11:03 AM, sunita.prad...@emc.com wrote: Hi All I have one output of one my command like : $output = Step 155 of 171 steps.Executing.    Step 168 of 171 steps.Executing.    Step 171 of 171

Re: multiple pattern matching

2012-03-08 Thread Rob Dixon
On 08/03/2012 17:03, sunita.prad...@emc.com wrote: Hi All I have one output of one my command like : $output = Step 155 of 171 steps.Executing. Step 168 of 171 steps.Executing. Step 171 of 171

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

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

Perl, pattern matching, substitution, replacing

2010-11-14 Thread Zachary Brooks
Hello again, Yesterday I had a question on pattern matching. A couple of people responded with very useful information. After some finagling, I got my rudimentary code to work. I'm a PhD student studying computational linguistics without any formal programming training. While there are various

Re: Perl, pattern matching, substitution, replacing

2010-11-14 Thread shawn wilson
On Sun, Nov 14, 2010 at 11:42 AM, Zachary Brooks zbro...@email.arizona.eduwrote: Hello again, Yesterday I had a question on pattern matching. A couple of people responded with very useful information. After some finagling, I got my rudimentary code to work. I'm a PhD student studying

Re: Perl, pattern matching, substitution, replacing

2010-11-14 Thread Shawn H Corey
On 10-11-14 11:42 AM, Zachary Brooks wrote: $hello = This is some sample text.; $hello =~ s/^../s/gi; $hello =~ s/..$/\/s/gi; print $hello\n; *sis is some sample tex/s* The meta-character '.' matches every character except a newline. The first substitution replaces 'Th' with 's'. The

Re: Perl, pattern matching, substitution, replacing

2010-11-14 Thread Uri Guttman
sw == shawn wilson ag4ve...@gmail.com writes: sw second, why not use a place holder like someone recommended yesterday? sw something like: sw s/^(.+)$/s\1\/s/g what is a placeholder? nothing like that in regexes. what you have there is a backreference and used in the wrong place. \1 is

Re: Perl, pattern matching, substitution, replacing

2010-11-14 Thread shawn wilson
On Sun, Nov 14, 2010 at 1:53 PM, Uri Guttman u...@stemsystems.com wrote: sw == shawn wilson ag4ve...@gmail.com writes: sw second, why not use a place holder like someone recommended yesterday? sw something like: sw s/^(.+)$/s\1\/s/g what is a placeholder? nothing like that in regexes.

Re: Perl, pattern matching, substitution

2010-11-14 Thread Rob Dixon
On 14/11/2010 13:53, Zachary Brooks wrote: Hey Rob, Of all the feedback. yours was the one I was able to drop into my code and make it work, no matter how rudimentary my understanding of Perl is. Thanks. You're welcome. I'm glad to be able to help. As far as the XML libraries, we are

Re: Perl, pattern matching, substitution, replacing

2010-11-14 Thread shawn wilson
so, if you've got a file, do something like: while ($line = FH ) { $line =~ m/^(.+)$/ig; print s$1\/s\n; } On Sun, Nov 14, 2010 at 1:53 PM, Uri Guttman u...@stemsystems.com wrote: sw == shawn wilson ag4ve...@gmail.com writes: sw second, why not use a place holder like someone recommended

Re: Perl, pattern matching, substitution, replacing

2010-11-14 Thread Rob Dixon
On 14/11/2010 19:04, Zachary Brooks wrote: What happened when I used the code -- $hello =~ s/^(.+)$/s\1\/s/gis; -- is that is properly markeds and the beginning of the sentence and/s at the end of the sentence, but then it only worked for one sentence. Any suggestions on gettings to appear

Re: Perl, pattern matching, substitution, replacing

2010-11-14 Thread Jim Gibson
At 2:16 PM -0500 11/14/10, shawn wilson wrote: so, if you've got a file, do something like: while ($line = FH ) { $line =~ m/^(.+)$/ig; print s$1\/s\n; } If all you want to do is print each line in the file surrounded bys tags, you don't need regular expressions, and you don't need to

Perl, pattern matching, substitution

2010-11-13 Thread Zachary Brooks
Hello, I'm taking a PhD course that requires the use of Perl and pattern matching. I've taken on the motto divide and conquer, but it hasn't quite worked. I appreciate anyone's help. The task is to extract sentences from a relatively large text file (928K, ca. 300 pages). But of course, the text

Re: Perl, pattern matching, substitution

2010-11-13 Thread Shawn H Corey
On 10-11-13 01:42 PM, Zachary Brooks wrote: 1. My first approach was to use substitute to get rid of a range of things betweenDOC and/DATELINE. A short version looks like this. $hello = DOC man at the bar order the/DATELINE; $hello =~ s/DOC.*\/DATELINE//gi; print $hello\n; I was about to

Re: Perl, pattern matching, substitution

2010-11-13 Thread Sheppy R
I've had similar issues and the \Q \E flags didn't fix it. One thing I've done to fix an issue where regex metacharacters are being caught is to do a replace on all of the characters to include a \ right in front. Something like this: open (my $FILE, , $file) or die $!\n; my @lines = $FILE; for

Re: Perl, pattern matching, substitution

2010-11-13 Thread Rob Dixon
On 13/11/2010 18:42, Zachary Brooks wrote: Hello, I'm taking a PhD course that requires the use of Perl and pattern matching. I've taken on the motto divide and conquer, but it hasn't quite worked. I appreciate anyone's help. The task is to extract sentences from a relatively large text file

usage of Split on pattern matching

2010-07-19 Thread Chandan Kumar
Hi all,   Iam beginner to perl i have a small query on split. using split i want print everything even the character used to split on string.   Here is my example :   my $string = hi123now456itstimeforsplit789right my @array  = split ( '/(\d+\s)/ ',$string); ## Trying to split using digitnumber

Re: usage of Split on pattern matching

2010-07-19 Thread Chas. Owens
On Mon, Jul 19, 2010 at 08:14, Chandan Kumar chandan_28...@yahoo.com wrote: snip my $string = hi123now456itstimeforsplit789right my @array  = split ( '/(\d+\s)/ ',$string); snip When I run the program ,it prints the whole string. so my assumption is wrong. please Could some one explain me on

Re: usage of Split on pattern matching

2010-07-19 Thread John W. Krahn
Chandan Kumar wrote: Hi all, Hello, Iam beginner to perl i have a small query on split. using split i want print everything even the character used to split on string. Here is my example : my $string = hi123now456itstimeforsplit789right my @array = split ( '/(\d+\s)/ ',$string); ##

Re: usage of Split on pattern matching

2010-07-19 Thread Chandan Kumar
Thanks guys, I could able to understand split fun. --- On Mon, 19/7/10, John W. Krahn jwkr...@shaw.ca wrote: From: John W. Krahn jwkr...@shaw.ca Subject: Re: usage of Split on pattern matching To: Perl Beginners beginners@perl.org Date: Monday, 19 July, 2010, 4:29 PM Chandan Kumar wrote: Hi

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

Pattern matching problem - Why won't this work?

2010-04-12 Thread Owen Chavez
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 interest in). I've

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
(3rd) and it's not entirely clear to me how to proceed with a hash. Owen On Mon, Apr 12, 2010 at 10:11 PM, Peter Scott pe...@psdt.com wrote: 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

Pattern matching question

2009-04-01 Thread Richard Hobson
Hi, 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 = @_[$_]; foreach (0..7) { my $piece = $ref-[$_];

AW: Pattern matching question

2009-04-01 Thread Thomas Bätzler
Richard Hobson m...@richardhobson.com wrote: 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 = @_[$_]; foreach (0..7) {

Re: AW: Pattern matching question

2009-04-01 Thread Richard Hobson
Firstly, apologies for the double posting of this question. On Wed, 01 Apr 2009 09:49 +0200, Thomas Bätzler t.baetz...@bringe.com wrote: How about (untested): sub display_board { foreach my $ref (@_){ foreach my $piece ( @$ref ){ print substr( $piece, -2); } } }

Pattern matching question

2009-03-31 Thread Richard Hobson
Hi, 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 = @_[$_]; foreach (0..7) { my $piece = $ref-[$_];

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
] Sent: Tuesday, September 23, 2008 6:52 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 sequences ie they are exclusively composed of the letters A, T, G, C- no spaces

Re: pattern matching question

2008-09-23 Thread Mr. Shawn H. Corey
to have other strings that are made of word/digit/space characters. i tried if($x=~ /[ATGC]/ )then . however this pattern matching expression is unable to filter out the non-DNA sequences. i have also tried other expressions too convoluted to write out here. any ideas? Your question

RE: pattern matching question

2008-09-23 Thread sanket vaidya
PROTECTED] Sent: Tuesday, September 23, 2008 6:52 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 sequences ie they are exclusively composed of the letters A, T, G, C

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

Pattern matching question

2008-09-23 Thread Darren Nay
Hey All, I hope that you can help me. I have been struggling with this issue the past couple of hours and can't seem to get it to work. I am trying to get a value through pattern matching. Here is the string: xsl:output method=html encoding=utf-8 indent=yes doctype-system=http://www.w3.org

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

pattern matching question

2008-09-22 Thread ANJAN PURKAYASTHA
tried if($x=~ /[ATGC]/ )then . however this pattern matching expression is unable to filter out the non-DNA sequences. i have also tried other expressions too convoluted to write out here. any ideas? tia, anjan -- = anjan purkayastha, phd bioinformatics analyst

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

Pattern matching problem

2008-02-29 Thread Anirban Adhikary
Dear List 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 file there are 4 particular lines which i need to extract from this log file. *Total logical records skipped:

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

help in variable pattern matching

2007-12-19 Thread Jin Zhisong
HI, I'm looking for some advice of how to do this? I need to match some variable pattenrs so I define a $match variable and use it in the patterr below. However it didn't match anything for the sample data. If I change the match critia to hardcode next unless /\s+BCV\s+N/Grp/;

Re: help in variable pattern matching

2007-12-19 Thread Roberto Etcheverry
Jin Zhisong wrote: HI, I'm looking for some advice of how to do this? I need to match some variable pattenrs so I define a $match variable and use it in the patterr below. However it didn't match anything for the sample data. If I change the match critia to hardcode

Re: help in variable pattern matching

2007-12-19 Thread Tom Phoenix
On 12/19/07, Jin Zhisong [EMAIL PROTECTED] wrote: next unless /\s+BCV\s+N/Grp/; it works Oh, I hope it doesn't work. The number of forward slashes is all wrong. next unless /\s+BCV\s+N\/Grp/; it didn't work But this one might actually parse. If it doesn't match when it's supposed

Re: help in variable pattern matching

2007-12-19 Thread Dr.Ruud
Jin Zhisong schreef: I define a $match variable and use it in the patterr below. However it didn't match anything for the sample data. perldoc -f qr -- Affijn, Ruud Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: help in variable pattern matching

2007-12-19 Thread Jin Zhisong
Thanks every one that helps. I find my problem. Now how can I have a $pattern that contain some special characters to pass it into regex? I want to extract the line that contains either RAID-5N/Grp'd Or BCV N/Asst'd The following code didn't

Re: help in variable pattern matching

2007-12-19 Thread Tom Phoenix
On 12/19/07, Jin Zhisong [EMAIL PROTECTED] wrote: The following code didn't work. my $pattern = ( $type eq 'bcv' ) ? ${match}\s+N\/Asst : ${match}\s+N\/Grp ; Did it not work because it did not use qr//? That's at least part of the problem. It may help you during development if you output

Re: help in variable pattern matching

2007-12-19 Thread Gunnar Hjalmarsson
Jin Zhisong wrote: The following code didn't work. My $type = $ARGV[1] my $match = ( $type eq 'bcv' ) ? 'BCV' : 'RAID-5' ; my $pattern = ( $type eq 'bcv' ) ? ${match}\s+N\/Asst : ${match}\s+N\/Grp ; while ( DATA )

problem with simple pattern matching

2007-08-29 Thread Jim
Hi, I hope this is simple, as i am very new to perl. I am trying to use pattern matchinig to create many srcipts from a template file which i have read into a list then print out to files. the problem is the patter match only matches on the first 2 successful matches after that it keeps the

Re: problem with simple pattern matching

2007-08-29 Thread Chas Owens
On 8/29/07, Jim [EMAIL PROTECTED] wrote: Hi, I hope this is simple, as i am very new to perl. I am trying to use pattern matchinig to create many srcipts from a template file which i have read into a list then print out to files. the problem is the patter match only matches on the first 2

Re: Doubt on Pattern Matching

2007-08-28 Thread Chas Owens
On 8/28/07, Dharshana Eswaran [EMAIL PROTECTED] wrote: When i write the condition my @m = $fullStruct =~ /$DLstatement/g; and try printing the array, print \nThe array is @m\n; It prints nothing This is the problem... Thanks and Regards, Dharshana snip That is not the

Re: Doubt on Pattern Matching

2007-08-28 Thread Rob Dixon
Dharshana Eswaran wrote: On 8/28/07, Chas Owens [EMAIL PROTECTED] wrote: On 8/28/07, Dharshana Eswaran [EMAIL PROTECTED] wrote: I have a pattern, which reads as shown below: my $comment= qr{\s* (?:/\* .*? \*/ \s*)*}xs; my $identifier = qr{ [A-Za-z_]\w* }xs; my $statement = qr{

Re: Doubt on Pattern Matching

2007-08-28 Thread Dharshana Eswaran
On 8/28/07, Chas Owens [EMAIL PROTECTED] wrote: On 8/28/07, Dharshana Eswaran [EMAIL PROTECTED] wrote: When i write the condition my @m = $fullStruct =~ /$DLstatement/g; and try printing the array, print \nThe array is @m\n; It prints nothing This is the problem...

Doubt on Pattern Matching

2007-08-27 Thread Dharshana Eswaran
Hi All, I have a pattern, which reads as shown below: my $comment= qr{\s* (?:/\* .*? \*/ \s*)*}xs; my $identifier = qr{ [A-Za-z_]\w* }xs; my $statement = qr{ \s* ($identifier) \s+ ($identifier)

Re: Doubt on Pattern Matching

2007-08-27 Thread Chas Owens
On 8/28/07, Dharshana Eswaran [EMAIL PROTECTED] wrote: Hi All, I have a pattern, which reads as shown below: my $comment= qr{\s* (?:/\* .*? \*/ \s*)*}xs; my $identifier = qr{ [A-Za-z_]\w* }xs; my $statement = qr{ \s* ($identifier)

Re: Doubt on Pattern Matching

2007-08-27 Thread Dharshana Eswaran
When i write the condition my @m = $fullStruct =~ /$DLstatement/g; and try printing the array, print \nThe array is @m\n; It prints nothing This is the problem... Thanks and Regards, Dharshana On 8/28/07, Chas Owens [EMAIL PROTECTED] wrote: On 8/28/07, Dharshana Eswaran [EMAIL

Re: Regarding pattern matching

2007-05-24 Thread Jeff Pang
Dharshana Eswaran 写道: Hi All, I am trying to extract strings from few files. The content of the file reads as shown typedef struct { REFID_T pp_ref_id; /* destination */ CAUSE_T pp_cause;/* Reason registered */ STATE_T pp_state; /* State for

Regarding pattern matching

2007-05-24 Thread Dharshana Eswaran
Hi All, I am trying to extract strings from few files. The content of the file reads as shown typedef struct { REFID_T pp_ref_id; /* destination */ CAUSE_T pp_cause;/* Reason registered */ STATE_T pp_state; /* State for indicators */

Re: Regarding pattern matching

2007-05-24 Thread Dr.Ruud
Dharshana Eswaran schreef: $xyz =~ /\s*(\w+)\s+(\w+);/; $b = $2; #variable name is stored here ... But the variables like pp_lac[COMMON_TYPE_MAX] and pp_plmn_list[COMMON_TYPE_MAX] are not getting stored because of the special character used inbetween the names. Then don't

Regarding pattern matching

2007-05-17 Thread Dharshana Eswaran
Hi All, I am trying to extract few strings from a text file. The pattern of the text stored in the file is as follows: #define MNSS_FACILITY_IND_ID (TF_MNSS_MESSAGE_CATEGORY + 0x01) /* @LOG MNSS_MESSAGE_T */ I need to extract MNSS_FACILITY_IND_ID, TF_MNSS_MESSAGE_CATEGORY + 0x01 and

Re: Regarding pattern matching

2007-05-17 Thread Rob Coops
How about this? #!/usr/local/bin/perl use strict; use warnings; my $string = '#define MNSS_FACILITY_IND_ID (TF_MNSS_MESSAGE_CATEGORY + 0x01) /* @LOG MNSS_MESSAGE_T */'; my @parts = $string =~ m/\S+?(\w+)\s+?\((\w+.*?)\)[EMAIL PROTECTED](\w+).*/; use Data::Dumper; print Dumper @parts;

Re: Regarding pattern matching

2007-05-17 Thread Rob Coops
On 5/17/07, Rob Coops [EMAIL PROTECTED] wrote: How about this? #!/usr/local/bin/perl use strict; use warnings; my $string = '#define MNSS_FACILITY_IND_ID (TF_MNSS_MESSAGE_CATEGORY + 0x01) /* @LOG MNSS_MESSAGE_T */'; my @parts = $string =~ m/\s+?(\w+)\s+?\((\w+.*?)\)[EMAIL

Re: Regarding pattern matching

2007-05-17 Thread Dharshana Eswaran
Thank you But i want to try without using any perl modules. Can you suggest some way with no modules used in that? Thanks and Regards, Dharshana On 5/17/07, Rob Coops [EMAIL PROTECTED] wrote: On 5/17/07, Rob Coops [EMAIL PROTECTED] wrote: How about this? #!/usr/local/bin/perl use

Re: Regarding pattern matching

2007-05-17 Thread Rob Coops
Sure, though I do not see why you would not want to use strict and warnings (you should should should or the people on this list will hunt you down and ) anyway Data::Dumper was just there for convenience: #!/usr/local/bin/perl #use strict; #use warnings; my $string = '#define

RE: Regarding pattern matching

2007-05-17 Thread Moon, John
Subject: Regarding pattern matching Hi All, I am trying to extract few strings from a text file. The pattern of the text stored in the file is as follows: #define MNSS_FACILITY_IND_ID (TF_MNSS_MESSAGE_CATEGORY + 0x01) /* @LOG MNSS_MESSAGE_T */ I need to extract MNSS_FACILITY_IND_ID

Re: Regarding pattern matching

2007-05-17 Thread Matthew J. Avitable
Dharshana Eswaran wrote: Hi All, I am trying to extract few strings from a text file. The pattern of the text stored in the file is as follows: #define MNSS_FACILITY_IND_ID (TF_MNSS_MESSAGE_CATEGORY + 0x01) /* @LOG MNSS_MESSAGE_T */ I need to extract MNSS_FACILITY_IND_ID,

Re: Regarding pattern matching

2007-05-17 Thread Dharshana Eswaran
Of Course Rob, i always use strict and warnings... Since i had to write a pseudocode, i did not write them. But i wil lsurely keep this in mind. :-) Thank you... :-) On 5/17/07, Rob Coops [EMAIL PROTECTED] wrote: Sure, though I do not see why you would not want to use strict and warnings (you

Re: Query on pattern matching

2007-03-09 Thread Rob Dixon
Dharshana Eswaran wrote: On 3/9/07, John W. Krahn [EMAIL PROTECTED] wrote: Chas Owens wrote: [snip] ( \w+ | \d+ | 0x[a-fA-F0-9] That only matches a single hexadecimal digit, you probably want

Query on pattern matching

2007-03-08 Thread Dharshana Eswaran
number too. the 3rd string is sometimes is not present. Once these are extracted, i can process it further to the requirement. I tried reading each line, splitting it using spaces, grouping them using pattern matching and then displaying. The code, which i wrote for this, is written at the end

Re: Query on pattern matching

2007-03-08 Thread Chas Owens
On 3/8/07, Dharshana Eswaran [EMAIL PROTECTED] wrote: Hi all, I need to extract few strings from one file and paste it to another file. snip This doesn't seem like a good job for split. The split function is good for parsing X separated records where X is either constant or simple. What you

Re: Query on pattern matching

2007-03-08 Thread Rob Dixon
or sometimes it can be a 2 digit decimal number too. the 3rd string is sometimes is not present. Once these are extracted, i can process it further to the requirement. I tried reading each line, splitting it using spaces, grouping them using pattern matching and then displaying. The code, which i wrote

Re: Query on pattern matching

2007-03-08 Thread John W. Krahn
Chas Owens wrote: On 3/8/07, Dharshana Eswaran [EMAIL PROTECTED] wrote: I need to extract few strings from one file and paste it to another file. snip This doesn't seem like a good job for split. The split function is good for parsing X separated records where X is either constant or

Re: Query on pattern matching

2007-03-08 Thread Dharshana Eswaran
On 3/9/07, John W. Krahn [EMAIL PROTECTED] wrote: Chas Owens wrote: On 3/8/07, Dharshana Eswaran [EMAIL PROTECTED] wrote: I need to extract few strings from one file and paste it to another file. snip This doesn't seem like a good job for split. The split function is good for parsing X

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

Pattern matching

2007-02-20 Thread Dharshana Eswaran
Hello All, I have quite a number of strings which has some typical matches between them. I am unable to come up with a generalised pattern for them. Few among those strings are like this: TAPI_VOICE_NOTIFY_OTHERAPP_JOINING_MSGID TAPI_TTY_NOTIFY_TTY_TONE_MSGID TAPI_NOTIFY_CALL_LINE_INFO_MSGID

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
in a variable. I need to pull out only the numbers and store them in a array. Like: @array = (53, 65, 63, 75, 72, 69, 74, 79, 43, 6F, 64, 65, 00); I am unable to get a pattern to try pattern matching and spliting it. How do i do this? $ perl -le' my $string = {[0]=0x53,[1]=0x65,[2]=0x63,[3

Pattern Matching

2007-01-19 Thread Dharshana Eswaran
= (53, 65, 63, 75, 72, 69, 74, 79, 43, 6F, 64, 65, 00); I am unable to get a pattern to try pattern matching and spliting it. How do i do this? Thanks and Regards, Dharshana

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
and store them in a array. Like: @array = (53, 65, 63, 75, 72, 69, 74, 79, 43, 6F, 64, 65, 00); I am unable to get a pattern to try pattern matching and spliting it. How do i do this? $ perl -le' my $string = {[0]=0x53,[1]=0x65,[2]=0x63,[3]=0x75,[4]=0x72,[5]=0x69,[6]=0x74,[7]=0x79,[8

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

Pattern Matching

2006-07-23 Thread Jimstone77
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 lines and

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

  1   2   3   4   5   >