Re: interpoliation within regexp



--- "Mumia W." <mumia.w.18.spam+nospam@xxxxxxxxxxxxx>
wrote:

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?



******************************************
The input data is a 6 character randomized string that
could start with a # such as 6FhJ9Z. If it does start
with a number then I need to convert this character
into its cooresponding alpha char, [a-z,A-Z].

The output data from the string 6FhJ9Z should be
[a-z,A-Z]FhJ9Z I guess what I am asking for is not
plausible after looking at the ASCII table b/c there
is no cooresponding letter for number 6. Silly me, ok
then maybe grab any [a-z,A-Z] character.

my $foo = pack("C*", 6); print $foo;
or
chr ('6');

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
.



Relevant Pages

  • [TOMOYO #15 3/8] Common functions for TOMOYO Linux.
    ... This file contains common functions (e.g. policy I/O, pattern matching). ... Since TOMOYO Linux is a name based access control, ... TOMOYO Linux's string manipulation functions make reviewers feel crazy, ... the Linux kernel accepts all characters but NUL character ...
    (Linux-Kernel)
  • RfD: Escaped Strings
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... \b BS (backspace, ASCII 8) ... chars + swap move ...
    (comp.lang.forth)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)
  • Re: RfD: Escaped Strings
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... \b BS (backspace, ASCII 8) ... \ ** escapes to characters much as C does. ...
    (comp.lang.forth)