@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet


Comments:

<0> anyone here who can help me?
<1> depends on what your problem is
<0> heh my problem is i am printing out this for example " San Francisco, CA61 " and i want to print just San Francisco, CA
<0> i dont know what regexp to use
<0> the is always different also
<1> neither do i - i need more examples and/or a description of exactly what you want to accomplish
<1> you want to strip off the last two characters? s/..$//;



<0> that still doesnt fix it
<1> it fixes the prblem as described by you
<1> you need to better describe your problem
<0> before that it prints the same thing as after i add $match =~ s/..$//;
<0> Beverly Hills, CA60 FOvercastWind: SE at 8 mphHumidity: 51%Mon63
<0> for example
<1> what? make sense
<0> i am making sense.
<0> that is what i am getting printed out ^
<1> "before that it prints the same thing as after" - so your regexp is doing nothing?
<0> exactly!
<1> are either of the last two chars a newline?
<1> they weren't in your example
<0> no
<1> $foo = "Beverly Hills, CA60 FOvercastWind: SE at 8 mphHumidity: 51%Mon63"; $foo =~ s/..$//; print $foo;
<1> prints "Beverly Hills, CA60 FOvercastWind: SE at 8 mphHumidity: 51%Mon" as expected
<0> not what i want
<1> you're wasting my time
<0> i want to just print "Beverly Hills, CA" as i stated
<1> then here's your program: print "Beverly Hills, CA";
<0> lol!
<0> the output is always different
<1> when you can articulate what it is you want to do, i'll help you
<1> in the meantime, i'm going to have a shower
<0> the problem is you dont understand.
<0> not my questioning.
<0> the output i am trying to fix is always different, the City, State is always different.. I want to fix it and remove the numbers from the State abrivation
<1> regular expressions match patterns. you can't devise one until you know what kind of pattern you're looking for



<1> so the city and the state change, but they're always at the front of the string?
<1> /^([^,]+, \w\w)/
<1> or simply /^(.*?, ..)/
<1> next time, try to provide a few examples so that people can find a pattern. it's pretty difficuly to find a pattern with a single input
<2> I need to find the location of an element in the array index... @array = ("this","that","more"); I have the word 'this' in $find, how do I ask PERL where 'this' is in @array? ie, $array[0]
<2> after I find the location, I plan to delete the value. delete (@array,$array[0]); for example.
<3> I don't think that perl has an indexOf function. Let me check...
<3> Nope.
<3> You'd have to iterate through the array. Do you know for sure that the array has unique elements?
<2> they are all unique
<2> @idx = grep { $foo[$_] =~ /^t/ } (0..$#foo); # I found this, but it only seems to work if there are 2 or more elements found. I will always be having only 1 result found.
<2> So I guess my question is now..., is there an easier way to do this:
<2> for ($x=0;$x<$#array,$x++) { if ($find eq $array[$x]) { $found = $x; } } delete (@array,$array[$x]);
<2> oops
<2> for ($x=0;$x<$#array,$x++) { if ($find eq $array[$x]) { $found = $x; } } delete (@array,$array[$found]);
<3> The grep one is for extracting unique elements.
<3> The most efficient way I can think of is (and it's very similar to what you've suggested):
<3> $aIndex=0; while(($aArray[$aIndex] != $ElementToFind)&&($aIndex <= $#aArray)) { $aIndex++; }
<3> $aIndex being the index of the element you want to delete.
<3> The for statement can also be written:
<2> but the while statement will stop once it finds the match, ie, quicker (especially if the first few elements are the match)
<3> for $x(0..$#array) { if ($find eq $array[$x]) { $found = $x; break; } }
<2> break, stops the for?
<3> Yes. Same as using break.
<3> snap! heh
<3> Oh, than != should be ne in the while statement.
<2> right
<3> And you can leave out the &&($aIndex <= $#aArray) id you're certain that the element is in the array.
<3> Interestingly enough, I've found that case statements and stringlist searches are two of the advantages that Delphi has over Perl.
<3> Here's a more widely applicable way of doing it: http://www.india-seo.com/perl/cookbook/ch04_13.htm


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #perl
or
Go to some related logs:

#kl
ya tayabah
#chat-world
#chat-world
#india
Fatal error: Can't open and lock privilege tables: Can't find file: './mysql/hos
www.hi-5
#chat-world
chating.girl
uriel bey



Home  |  disclaimer  |  contact  |  submit quotes