Re: interpoliation within regexp
- From: mumia.w.18.spam+nospam@xxxxxxxxxxxxx (Mumia W.)
- Date: Thu, 28 Sep 2006 09:33:59 -0500
On 09/28/2006 08:16 AM, Derek B. Smith wrote:
--- "Derek B. Smith" <derekbellnersmith@xxxxxxxxx>
wrote:
I need to substitute a conversion using chr, but
have
failed on multiple attempts. Basically if the first
element contains a # then convert it. Will anyone
advise?
thank you
derek
#if first char is a-z then print it else warn
#chop string into individual characters
my @chars = unpack
("A1" x length($password),$password);
if ($chars[0] =~ /^\D/) {
print "Your new string is:\t",@chars,"\n";
}
else {
print "string starts with number, now
converting\n",
@chars, "\n";
substr($chars[0],0,1) =~
s/\Q{$chars[0]}/{chr($chars[0]}\E/;
print @chars;
}
I will try to use the /e modifier as such:
s/(\$\w+)/$1/e;
An explanation is below:
/e
Righthand side of a s/// is code to eval
/ee
Righthand side of a s/// is a string to eval, then
run as code, and its return value eval'led again.
What does your input data look like, and what do you want the output to look like?
.
- Follow-Ups:
- Re: interpoliation within regexp
- From: Derek B. Smith
- Re: interpoliation within regexp
- References:
- Re: interpoliation within regexp
- From: Derek B. Smith
- Re: interpoliation within regexp
- Prev by Date: Re: why Perl complaints my script
- Next by Date: Re: cgi script
- Previous by thread: Re: interpoliation within regexp
- Next by thread: Re: interpoliation within regexp
- Index(es):
Relevant Pages
|