----- Original Message -----
From: "Rob Anderson" <rjanderson@uk2.net>
To: <beginners@perl.org>
Sent: Thursday, September 04, 2003 3:30 PM
Subject: Re: Extracting equal entities from two different sized arrays?
""Freddy söderlund"" <freddy_soderlund@chello.se> wrote in
message news:010301c372e1$6a5158f0$6400a8c0@winter...
Hi!
Hi
Hi again!
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
earlier).
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.
Good luck
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.
Any suggestions?
Greatfull for any help!
/Freddy
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org