Solved

check for tab in Perl

Posted on 2002-06-24
7
141 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…

809 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