----- Original Message ----- 
From: "Rob Anderson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, September 04, 2003 4:50 PM
Subject: Re: Extracting equal entities from two different sized arrays?


>
> ""Freddy söderlund"" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > ----- Original Message -----
> > From: "Rob Anderson" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Thursday, September 04, 2003 3:30 PM
> > Subject: Re: Extracting equal entities from two different sized arrays?
> >
> >
> > >
> > > >""Freddy söderlund"" <[EMAIL PROTECTED]> wrote in
> > > > message news:[EMAIL PROTECTED]
> > > >Hi!
> > > >
> > >
> > > Hi
> >
> > Hi again!
> >
>
> [snip]
>
> >
> > 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).
> >
>
> [snip]
>
> >
> > 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.
> >
>
>
> but you're so close now!. You know how many characters match at the front
of
> the string, so just substring them off. He's a working example, which is
> spoon feeding a bit, but I guess you don't know the substr function
> (perldoc -f substr)

/me is going to the "shame-on-me-corner" now. ;-)

I think I need to look deeper into my coffe-cup or maybe I need to sleep.
Once again, you're correct. I tried the code and it works like a charm.
Surely, I know the substr function but it never came to me.

I suffer from the "to-easy-to-solve" syndrome.
If it's too easy to solve, I can't solve it since my thoughts are stuck on
the complicated things.

Thanx for your help!

It saved my day and a lot of headache!

> #!/perl -w
> use strict;
>
> my $string1 = "The quick bruwn fox.";
> my $string2 = "The quick brown fox.";
>
> my $string_xor = ("$string1" ^ "$string2");
> $string_xor =~ /^(\0*)/;
> my $matching_char_count = length($1);
> my $string3 = substr($string1, 0, $matching_char_count);
> print $string3 . "<==\n";
>
>
> HTH
>
> Rob Anderson
>
>
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to