Solved

check for tab in Perl

Posted on 2002-06-24
7
143 Views
Last Modified: 2010-03-05
What would be proper syntax to check for a tab in a string of characters using perl? Would I use ($check being my string):

if ($check =~ /\t/)


or

if ($check =~ /'\t')

or how would I do this?

Thanks,

guidway
0
Comment
Question by:guidway
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 50 total points
ID: 7105190
if m/\t/
0
 
LVL 12

Author Comment

by:guidway
ID: 7105199
Never heard of the m before. thanks. I've always matched with a =~. What's the difference?

guidway
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7105244
> .. difference?
m/ returns "true" or "false"
=~ modifies the left hand side, usually
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 84

Expert Comment

by:ozo
ID: 7106700
$check =~ /\t/
is the same as
$check =~ m/\t/
0
 
LVL 12

Author Comment

by:guidway
ID: 7107362
thanks ozo. I figured that out yesterday after he e-mailed me.

guidway
0
 
LVL 84

Expert Comment

by:ozo
ID: 7109735
m/ can return a list, not just "true" or "false"
=~ m// does not modify the left hand side,
=~ s/// or =~ tr/// may modify the left hand side
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7109990
just to clarify:
  with "true" and "false" i didn't mean the exact boolean values, but perl's opinion about it (which might be a list too:)
  and ozo is right about the =~ vs. m/ , both are equal
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question