LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-21-2009, 04:10 AM   #1
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 707

Rep: Reputation: 55
Arrow matching pattern in perl


hi all......

This is my perl script:

while ($text){
if($text=~ /^\s+\S+\s+CHAR|VARCHAR2/){
print ($text);


CONTENTS TO BE MATCHED IN A FILE:

NAME CHAR(5);
VIN CHAR(5);
CLASS VARCHAR2(18,2);
ADDS CHAR(30);

here i am not able to match any of these....can anyone please help me......

Thanks in advance......

Last edited by vinaytp; 06-21-2009 at 04:12 AM.
 
Old 06-21-2009, 04:18 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Well, /^\s/ will fail on the lines you've posted,
none of them begin with whitespace
 
Old 06-21-2009, 04:50 AM   #3
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 707

Original Poster
Rep: Reputation: 55
Talking

Quote:
Originally Posted by Tinkster View Post
Well, /^\s/ will fail on the lines you've posted,
none of them begin with whitespace
sorry...actually it has white spaces..i forgot to put.....

Last edited by vinaytp; 06-21-2009 at 04:51 AM.
 
Old 06-21-2009, 06:06 AM   #4
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
simpler:
1) split the line into array on whitespaces
2) iterate the array using for loop
3) check for each item, use /^(CHAR|VARCHAR)/
 
Old 06-21-2009, 12:27 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Btw, if the code-snippet is complete ... where do you
change $text for the next iteration? Or is the whole
file in the scalar?



Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
need help with perl - pattern matching johngreg Programming 5 10-13-2008 01:08 PM
Perl pattern matching - greedy wondergirl Programming 2 06-17-2008 03:32 PM
Perl pattern matching in VB rigel_kent Programming 1 05-30-2006 11:00 AM
Perl Pattern Matching Question pete1234 Programming 2 08-27-2005 10:26 AM
pattern matching in perl ludeKing Programming 9 04-02-2004 09:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration