Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password

Programming > Perl Beginners > special chars a...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 10818 of 11948
Post > Topic >>

special chars as scalar inside regex

by robbenton@[EMAIL PROTECTED] (Rob Benton) Mar 28, 2008 at 02:23 AM

I've got a problem I think there may be a straight-forward solution to  
that I just don't know.  I have a program that reads a variable-length  
input file. And the field delimiter of that file is given as an  
argument.  The problem is something like pipe "|" might show up as the  
delimiter.  So is there a way to quote/protect that in the split()  
function without it being interpreted as a regex special character?

Something like:

../myprog.pl "|"

myprog.pl:
---------
my $delimiter = $ARGV[0];
my @[EMAIL PROTECTED]
 = split(/$delimiter/, $line);


This is a very simplified example.  Hope that makes sense.
 



 3 Posts in Topic:
special chars as scalar inside regex
robbenton@[EMAIL PROTECTE  2008-03-28 02:23:22 
Re: special chars as scalar inside regex
noreply@[EMAIL PROTECTED]  2008-03-28 09:50:13 
Re: special chars as scalar inside regex
krahnj@[EMAIL PROTECTED]   2008-03-28 01:55:15 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 7 16:26:22 CDT 2008.