LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-02-2010, 06:02 AM   #1
ashok.g
Member
 
Registered: Dec 2009
Location: Hyderabad,India
Distribution: RHEl AS 4
Posts: 215

Rep: Reputation: 32
perl matching??


Hi,
I am using perl.
Code:
if( $b =~ m/$inf/ )
{
	print "$b$inf";
}
Actually $b and $inf contains a string value seperated with tabs.
When I execute the above code this code is not executing. why???
 
Old 02-02-2010, 07:57 AM   #2
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 97
By "not executing", do you mean just that nothing is output, or that you are getting an error message?

A match should be found if the contents of $inf can be interpreted as a regular expression that matches $b (meaning that it could be as simple as a substring of $b):

[rh@mypc ~]$ perl -e '$b = "one\ttwo\tthree"; $inf = "\ttwo"; if($b =~ m/$inf/) {print "$b$inf\n";}'
one two three two

Could you give an example of the strings contained by $b and $inf?
 
Old 02-03-2010, 12:03 AM   #3
ashok.g
Member
 
Registered: Dec 2009
Location: Hyderabad,India
Distribution: RHEl AS 4
Posts: 215

Original Poster
Rep: Reputation: 32
Actually the problem lies in getting the inf from files.
Please refer to post where I did some what different.

http://www.linuxquestions.org/questi...0/#post3849442

Thank You,
 
  


Reply



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
Perl partial matching ifeatu Programming 4 12-13-2009 05:57 AM
need help with perl - pattern matching johngreg Programming 5 10-13-2008 01:08 PM
Perl global matching ShaqDiesel Programming 1 11-07-2006 08:54 PM
perl regex matching exodist Programming 2 11-15-2004 10:50 PM
pattern matching in perl ludeKing Programming 9 04-02-2004 09:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:37 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