----- Original Message -----
From: "Rob Anderson" <email@example.com>
Sent: Thursday, September 04, 2003 3:30 PM
Subject: Re: Extracting equal entities from two different sized arrays?
""Freddy söderlund"" <firstname.lastname@example.org> wrote in
Thanx for your time!
Got time for an elaboration?
I have stuck my thoughts on this one, maybee someone can help me out?
I have two arrays
@array1 = "C:\Program files\directory1\directory2\directory3";
@array2 = "C:\Program files\directory1\dir2\dir3";
It looks like you're trying to build an array, each element of which is a
single character from your string. What you've actually got here is two
arrays both each holding a single string.
Another example on just how *stuck* I was! You're right ofcourse and I were
wrong when typing my example.
It's really two strings: $string1 and $string2.
Let me re-phrase my question a bit:
I want to compare the two strings and I want to extract those chars that are
matching each other in the first and second string (in order from the
beginning), and put them in a new string (not array as I mistakenly said
So, if I have
$string1 = "C:\Program files\directory1\directory2\directory3"
$string2 = "C:\Program files\directory1\dir2\dir3"
then I want the output to be $string3 = "C:\Program files\directory1\";
I gave you the wrong flightplan so your rockets didn't take me all the way
to the moon. ;-)
Your example works good but it can't give me the resulting 3:rd string. It
only gives me the number of how many characters that matches.
What I want to do is, compare the arrays, one char at a time, from the
beginning and stop when I find two >chars that are different, putting the
matching chars in a new scalar.
Greatfull for any help!
To unsubscribe, e-mail: email@example.com
For additional commands, e-mail: firstname.lastname@example.org