CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
simple matching

 



kojr
Novice

Apr 19, 2001, 11:08 AM

Post #1 of 8 (794 views)
simple matching Can't Post

I am really a beginner of perl..If anyone can help me solve this question..
I have a some information in a text file like following:
INSERT INTO emails VALUES ( '123text@dihost.com', '1', '1');
INSERT INTO emails VALUES ( 'nglinux@hotmail.com', '1', '2');
INSERT INTO emails VALUES ( 'xyirl2000@yahoo.com', '1', '3');
now I like to input this information into a form and after parsing by perl script it will change to show out as
123text@dihost.com
nglinux@hotmail.com
xyirl2000@yahoo.com
there is something as =~(matching) and how to write it so the other irrelevant stuff be omitted






freddo
User

Apr 21, 2001, 8:18 AM

Post #2 of 8 (781 views)
Re: simple matching [In reply to] Can't Post

Hello Kojr,

here's my try at it (if your file is called emails.sql):

Code
#!/usr/bin/perl 

open(FILE, "emails.sql");
while (<FILE>) {
print "$1\n" if /.*?'(.*?)'/;
}
close(FILE);

in fact it print what is between the first quotes on the line.

i hope this helps;
freddo

;---
Real Programmers are surprised when their cars'odometer don't turn
from 99999 to 9999A!?


kojr
Novice

Apr 21, 2001, 11:04 AM

Post #3 of 8 (775 views)
Re: simple matching [In reply to] Can't Post

Done it.
but, there should be a \n somewhere after =~since the result is
123text@dihost.com nglinux@hotmail.com xyirl2000@yahoo.com
instead of
123text@dihost.com
nglinux@hotmail.com
xyirl2000@yahoo.com
Just one more step
Grateful for your help again.




freddo
User

Apr 22, 2001, 5:33 AM

Post #4 of 8 (763 views)
Re: simple matching [In reply to] Can't Post

Hi Kojr,

you're welcome ;-)

I dont understand your problem about newlines, here's my output:

Code
administrator@COKE /cygdrive/h/scripts.pl/perlguru 
$ kojr.pl
123text@dihost.com
nglinux@hotmail.com
xyirl2000@yahoo.com


if you are under windows with active perl, you can replace \n with \r\n.

freddo

;---
Real Programmers are surprised when their cars'odometer don't turn
from 99999 to 9999A!?


kojr
Novice

Apr 22, 2001, 8:34 AM

Post #5 of 8 (757 views)
Re: simple matching [In reply to] Can't Post

I put the script in the website not test through window
Here is the link
http://csss.hypermart.net/golden.cgi
Since the script elimilate the unwant part after parsing. I am able copy the result to words2000. Through its editing function by serch the space between three email addresses with a replacement by ^1(represent a new line in words)
then I got the required result.
Anyway, thank you...
But, for knowledge enrichment and fufill the purpose of this learning centre. There must a way to do it with perl...
Now I know something of matching on perl and its logic after 'parsing' your script and a lot of threads in this forum. I tried several attempts to make it perfect, but no success.
I still like to know the solution.....( really a fresh learning experience)




freddo
User

Apr 22, 2001, 8:57 AM

Post #6 of 8 (755 views)
Re: simple matching [In reply to] Can't Post

Hey hey Kojr...

look the source of your page:

Code
123text@dihost.com 
nglinux@hotmail.com
xyirl2000@yahoo.com

all the mails are on a separate line, if you want them, each on a new line, in html, you should try to replace \n with < br > (no spaces around the br) :-)

now this should work :-)
see you
freddo

;---
Real Programmers are surprised when their cars'odometer don't turn
from 99999 to 9999A!?


kojr
Novice

Apr 22, 2001, 10:36 AM

Post #7 of 8 (752 views)
Re: simple matching [In reply to] Can't Post

Thanks freddo
Done!!!!!!!!!!!!!!!
html code ....yaa--
nice nice to meet you
I am sure
seeeeeee youuuuuuuu
if you don't mind my standard is much lower than the basic requirement of this beginner forum.
regars
kojr



freddo
User

Apr 22, 2001, 12:06 PM

Post #8 of 8 (750 views)
Re: simple matching [In reply to] Can't Post

Kojr!

hehehe, no probs, you're always welcome to ask questions, at least two persons learn from it... you by getting an answer to your problem, me by reading the docs in order to find a solution and trying to explain it :-)

bye
freddo

;---
Real Programmers are surprised when their cars'odometer don't turn
from 99999 to 9999A!?

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives