Re: Strange hidden string to array conversion



ScriptKid wrote:
Hugh Oxford pisze:
So what are you trying to achieve with $s[4] = 'A'?

AFAIK, doing that will create an array, and set the fifth element to 'A'.

No, I'm trying to achieve

$s == ' A';

by writing:

$s = '';
$s [4] = 'A';

which should be possible according to documentation, but as Curtis wrote
(thanks, Curtis!) array conversion is chosen over string padding.

Sad, but true.

I don't see where the documentation says you can do that. The doc specifies "Characters within strings may be accessed and modified by specifying the zero-based offset of the desired character after the string using square array brackets, as in $str[42]. ".

So you can access characters in the string, but it says nothing about being able to access characters which don't exist.

If you want it equal to ' A', then set it to ' A'.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages

  • Re: How do you retrieve a char from a string?
    ... The above clearly doesn't work since $greet is not an array. ... an easy way to access characters at specific index in a string without ...
    (comp.lang.perl.misc)
  • How do you retrieve a char from a string?
    ... I have the following string: ... The above clearly doesn't work since $greet is not an array. ... an easy way to access characters at specific index in a string without ...
    (comp.lang.perl.misc)
  • Help in French|Spanish|German translation.
    ... I am also an author of User-defined string functions. ... WORDTRANEX (cSearched, cArExpressionSought | cExpressionSough, ... each string of the array is searched ... If the parameter nArStartOccurrence is -1 or omitted, the replacement starts ...
    (microsoft.public.fox.helpwanted)
  • Re: passing a string to a dll
    ... Joe, I really appreciate you taking the time to demonstrate this. ... sure how I would implement indexing it for random alphanumeric codes. ... I might handle the array. ... I actually have been wondering if I could use a second string ...
    (microsoft.public.vc.mfc)
  • Re: passing a string to a dll
    ... I might handle the array. ... I actually have been wondering if I could use a second string ... look at insertion cost, organization cost, and search cost. ...
    (microsoft.public.vc.mfc)