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:
Perl beginner - I need help please

 

First page Previous page 1 2 3 4 5 Next page Last page  View All


JennyW
journeyman

Jun 8, 2001, 7:31 PM

Post #76 of 123 (6193 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Sparkus Marus!

In Reply To
Fortunately, you don't have to do this. I figured out someone else has just done it and made a Perl module out of the regex. It's called Email::Valid and is available from CPAN if it should not be installed locally or at netfirms. Usage is very simple:

use Email::Valid;

my $email = 'mhx@gmx.de';

if( Email::Valid->address( $email ) ) {
print "$email is a valid email address!\n";
}
else {
print "$email is invalid!\n";
}
The red part makes the module available to the script, the green part is used to check the address.

So, you池e saying instead of that regex I can use the above to verify email addresses?

In Reply To
>>Out of curiosity, why would you take the optimized version versus the unoptomized version?

>Because it's optimized (?!) What do you want to hear? I assume the optimized version is faster, therefore I'd prefer it.

You値l have to bare with me. I知 not too versed with some internet language. What does optimized mean versus unoptimzed? Why is optimized faster?

I have to figure out what I want to learn first: polls or a mailing list? And right now accepting email addresses for a mailing list is higher priority for me than learning polls.

I知 want to learn more about polls after I figure how to make a mailing list. If I do two things at once (mailing list and polls) I値l confuse myself.

I知 gonna start looking for a mailing list script that suits my needs. Like usual I値l ask you for your help when I come across a problem.

I want to be able to send HUGE amounts of emails when I have my mailing list set up. Do you have any suggestions as to what kind of mailing list script I should be looking for?

Thanks,
Jenny



mhx
Enthusiast / Moderator

Jun 9, 2001, 12:06 AM

Post #77 of 123 (6187 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,


In Reply To
So, you池e saying instead of that regex I can use the above to verify email addresses?

Oui, c'est que je dit. (I'm just sitting at home watching a Cranberries concert in Paris. I'll leave the french now...)
You can use the code I provided instead of the regex, because Email::Valid contains that regex. So you don't have to care about how to use it.

In Reply To
You値l have to bare with me. I知 not too versed with some internet language. What does optimized mean versus unoptimzed? Why is optimized faster?

I'm sorry, I thought a term like optimized would be self-explaining in any language. It's not from internet language in this context, but from programming language. Code development mostly works like this: You start searching for or inventing an algorithm and write a very simple version of it. Then you check if it works. Because it's simple, you can easily fix any bugs (errors are called bugs). If you got the algorithm working, you normally do some benchmarking. This means you check how long it takes for the algorithm to perform its task and how much memory is consumed. If you find that its performance is very poor or not good enough for you, you normally consider to optimize your simple (or basic or unoptimized) algorithm. This means you search for parts of the code that aren't very efficient and replace them by equivalent code that seems more efficient to you. The problem is that efficient code is often significantly longer and more complicated than the basic version of it. So your basic code becomes faster or uses less memory when you optimize it. I hope I explained this without using too much terms unknown to you...

In Reply To
I want to be able to send HUGE amounts of emails when I have my mailing list set up. Do you have any suggestions as to what kind of mailing list script I should be looking for?

If you really want to set up a huge mailing list (which is quite close to the forum you're currently in, just without the forum), there are special server software called majordomo. It's written in Perl, but I don't think it's intended to be used as cgi-script, so you won't be able to use it on netfirms. But, there is a list of internet mailing list provider available. These allow you to create and maintain your own mailing list(s). Since I haven't done anything with mailing lists yet, I cannot really help you in choosing one of them (if you want to). Right now, I'm not sure if you want a mailing list, because a mailing list is relatively independent from your website. The purpose of a mailing list - in brief - is to manage that incomimg mails (sent by anyone who's on the list) are sent to everyone else on the list but the sender itself (except he wants to receive copies). I hope this makes clear what a mailing list is and helps you to decide whether what you want is a mailing list or not.

Bye,
Marcus



JennyW
journeyman

Jun 9, 2001, 10:24 AM

Post #78 of 123 (6183 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus!! Saturday is here!

Thanks for the explanation on optimization. I read it through a couple times and it seems to be somewhat sinking in (sinking in means I知 beginning to understand it!!


In Reply To
The purpose of a mailing list - in brief - is to manage that incomimg mails (sent by anyone who's on the list) are sent to everyone else on the list but the sender itself (except he wants to receive copies). I hope this makes clear what a mailing list is and helps you to decide whether what you want is a mailing list or not.

Thank heavens you explained that too me. I would have wasted a good hour looking for a mailing list script. I guess I知 not looking for a mailing list.

What I知 looking for is something similar to my email Form. I want people to ONLY send me their email address so I can add them to a list. Then I want to email that list once a month to tell them about updates on my website.

Thanks for the explanation!
Jenny



alex
stranger

Jun 9, 2001, 10:28 AM

Post #79 of 123 (6183 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Wow. That took ages to read. Interesting tho :)



freddo
User

Jun 10, 2001, 12:57 PM

Post #80 of 123 (6173 views)
my two cents [In reply to] Can't Post

Hello,

when there's that much different problems in a question, wouldnt it be smarter to post it in, smaller, different questions (posts), with a revealing subject?

it's hard to understand all the follow ups when you read them since replies appears in the date of the post order.

dont want to bother, it's just my two cents,
freddo

;---
ygjohn: sometimes. you talk too much.. hahaha..


JennyW
journeyman

Jun 10, 2001, 3:34 PM

Post #81 of 123 (6168 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus,

Well, I found a script(s) that I can use! But like normal I知 having a few problems. The good thing is you helped me sooo well with the last email Form that I used a lot of that knowledge when making slight adjustments to this new script!

http://maillist.pl and mail-admin.pl

In Reply To

2) Open cfg.pl with a text editor than modify the variables.

I used notepad and made my modifications to cfg.pl.

The only error I could have made in this file was with on the sendmail line. I changed the location of sendmail to /usr/lib/sendmail, which is correct. The original script had sendmail in a different location and they also had a -t"; after the sendmail line. Could the problem be that I kept the -t"; ?

In Reply To
3) Upload the scripts to your cgi-bin then chmod them to "755."

I uploaded maillist.pl and mail-admin.pl and cfg.pl to the .cgi-bin at netfirms. I gave each file chmod of 755. I have read, write, execute permission to the OWNER. I gave read and execute permissions to GROUP AND OTHER.

In Reply To
4) Modify the header and footer files with a text editor.
header.txt and footer.txt will go in the email message.
dheader.txt and dfooter.txt will be used when a visitor's email address has been added or removed.

I don稚 think I can make errors on these files, they were very very very basic. But here they are header.txt, footer.txt, dheader.txt, dfooter.txt

In Reply To
5) Upload header.txt, footer.txt, dheader.txt, and dfooter.txt to the same directory where you uploaded the scripts.
Then chmod them to "777."

I uploaded the scripts above to the my .cgi-bin. I gave them all chmod 777, which gives the owner, group and other read, write and execute permissions.

In Reply To
6) Upload pass.dat, list.txt, and errorlog.txt, to the same directory where you uploaded the scripts.
Then chmod them to "777."

I uploaded the .txt files and .dat file above with the same permissions as I wrote for #5 (above). The list.txt file is empty right now. That痴 where the email addresses will be stored when people send me their email address.

I don稚 really know what I can do with the errorlog.txt file. I uploaded it, but how can I view it so it can help me?

In Reply To
7) Execute the admin script (mail-admin.pl) with your browser (Point to url to main-admin.pl).
The script will ask you to set up your admin password.

I called the main-admin.pl script by typing the url
<A target="_blank" HREF=http://jennyw2.netfirms.com/cgi-bin/mail-admin.pl.

I entered my password and the received this message

An error has been occured. The error is: Unable to open the data file for reading
Reason: No such file or directory


What does that mean? Which file do you think they池e talking about?

In Reply To
8) copy and paste the tags below then paste them on your html document.

Here痴 the url where the user can send me their email address: http://jennyw2.netfirms.com/mailing_list.htm

In Reply To
9) Done.

!!Important!!
All of the script files and data files have to be uploaded in "ASCII" mode or you will always get a 500 server error while accessing the program.

I did this. I would never forget this step!

What do you think the problem could be?

Thanks for taking the time to read all this.
Jenny



JennyW
journeyman

Jun 10, 2001, 6:21 PM

Post #82 of 123 (6165 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Marcus WAIT! WAIT!

Disregard a lot of the above. I figured out how to send bulk emails. I got the .cgi scripts working correctly!


My only problem is on this page

http://jennyw2.netfirms.com/mailing_list.htm

I can稚 send in an email address. Nothing happens. I enter an address, press Go! and nothing sends, I知 just transferred to a page that doesn稚 exist.

What do you think the problem could be?

P.S. Even though the Form above doesn稚 send email addresses yet, I was able to successfully test the .cgi script because there痴 field for adding email addresses to the mailing list within the admin section.

http://jennyw2.netfirms.com/cgi-bin/mail-admin.pl

Thanks,
Jenny



mhx
Enthusiast / Moderator

Jun 11, 2001, 12:11 PM

Post #83 of 123 (6153 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,


In Reply To
What do you think the problem could be?

That's super-easy! It's the path to the cgi-script. Just change

Code
<form action="cgi-bin/list/maillist.pl" method="post">

to

Code
<form action="cgi-bin/maillist.pl" method="post">

and everything should work just file!
As you will see, I've added myself to the list...

Bye,
Marcus



JennyW
journeyman

Jun 12, 2001, 4:51 PM

Post #84 of 123 (6137 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus!

Thanks for correcting my Form痴 path to point to my .cgi script! I appreciate it!

I have a few questions for you. ~

If you look at this page

http://jennyw2.netfirms.com/mailing_list.htm

You値l notice that there are two radio buttons Subscribe and Unsubscribe.
I don稚 like this at all. I want to get rid of both the radio buttons.

When someone signs up for my mailing list all I want him/her to do is enter their email address and then select GO! I don稚 want them to have to check the radio button (Subscribe).

How do you think I can do this?

I want to do the same thing for Unsubscribing. I want to make a separate page for Unsubscribing (don稚 want radio buttons).

Is it possible to do this?

If you go to this page again

http://jennyw2.netfirms.com/mailing_list.htm

and enter this email address

chaaaaaa@hotmail.com

You値l get one of five .cgi messages. In this case you will get the 兎mail address already in database message. Now this is fine. But the page the messages show up on looks so plain. The page is .cgi generated, calls two scripts (below), is located within the .cgi-bin, and is at a chmod of 777.

Here痴 the url痴 to those .cgi scripts that are called

http://jennyw2.netfirms.com/006_dheader.txt

http://jennyw2.netfirms.com/007_dfooter.txt

Now, I have a page that I designed specifically for my website. It has images, links and a menu etc. I want to make that page appear after someone enters an email address in the Form field.

Is it possible to do this?

Do I just cut-and-paste my html in the documents above?

Since the documents above are in the .cgi-bin and my html images are in the www-bin do I need to specify a path to my images like this

../image_example.html

to point to the images so they can be displayed when the page is called upon?

Thanks for taking the time to read all this nonsense!
Jenny



mhx
Enthusiast / Moderator

Jun 12, 2001, 10:05 PM

Post #85 of 123 (6128 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,


In Reply To
How do you think I can do this?
I want to do the same thing for Unsubscribing. I want to make a separate page for Unsubscribing (don稚 want radio buttons).
Is it possible to do this?

Yes, I think you can get rid of the radio buttons. But IMO adding a second page for unsubscribing is real overkill. Personally, I'd prefer to have one page, without radio buttons, but with two push buttons, one for 'Subscribe' and one for 'Unsubscribe'. So there will be no radios, and the 'GO!' push button is replaced by the two other buttons. This can be easily implemented in both, the html and the cgi. I can have a look at them again later, but I gotta work now. Wink
I'll also have a look at the redirection stuff you mentioned below. Only two things for now:

In Reply To
Since the documents above are in the .cgi-bin and my html images are in the www-bin do I need to specify a path to my images like this
../image_example.html

First, you www directory isn't www-bin. cgi-bin has the bin in the name because it contains (mainly) binary files that are about to be executed.
Second, if you refer to an image, this image shouldn't be called .html. Nevertheless, your idea with the path is absolutely ok.
I just took the time to look at some of the links above. Yes, I think cut&paste should work quite well for your very plain looking pages. Just try it. There's only one way to become a good programmer: practice, practice, practice! Even if you're failing, there should always be something you've learned from it!

Bye,
Marcus




JennyW
journeyman

Jun 18, 2001, 10:11 AM

Post #86 of 123 (6092 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus! I missed you!!
Did you have a good weekend?

Ok, I tried cutting-and-pasting my html in the documents (below) and everything worked great!

http://jennyw2.netfirms.com/006_dheader.txt

http://jennyw2.netfirms.com/007_dfooter.txt

Subscribing and Unsubscribing

I really want two separate pages for both Subscribing and Unsubscribing. I want to get rid of the radio buttons and just have a submit button for both.

How can I do this?

Do I have to make any adjustments to my .cgi script if I want to make these changes?


I have another basic question.

As you know, I have .cgi files, which are located in my cgi-bin.
Some of the .cgi files generate html and call images from my www directory, so as you致e explained in the past, I use the following command to get the image:

../my_image.gif

This works great! But what would I do if I had several directories in my www directory?

For example, how would I adjust the command above if I had a directory named jennyw_menu within my www directory that had html and images that are being called upon by a .cgi script?

Hope all is well!
Jenny



mhx
Enthusiast / Moderator

Jun 18, 2001, 12:40 PM

Post #87 of 123 (6089 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny!

Yeah, my weekend was fine, although it has also been quite exertive. I've managed to look in the forum once or twice, but I wasn't sure if I would get that opportunity.
Now, let's go ahead to your questions:

In Reply To
I really want two separate pages for both Subscribing and Unsubscribing. I want to get rid of the radio buttons and just have a submit button for both.
How can I do this?
Do I have to make any adjustments to my .cgi script if I want to make these changes?

Yes, you can do this and no, you've don't even have to make changes. The only thing you'll have to change is in the HTML files. Remove the radio buttons and replace them by

Code
<input type=hidden name="action" value="subscribe">

for your subscribe page and

Code
<input type=hidden name="action" value="unsubscribe">

for your unsubscribe page. That should be all you've got to do.

In Reply To
For example, how would I adjust the command above if I had a directory named jennyw_menu within my www directory that had html and images that are being called upon by a .cgi script?

That's simple. Just use something like

Code
../jennyw_menu/jennyw_pic.gif

Hope that answers your questions, and hope you're doing fine, too.

Bye,
Marcus



JennyW
journeyman

Jun 19, 2001, 6:28 AM

Post #88 of 123 (6079 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus,
Glad to see you池e back!

I値l replace the radio buttons with

SUBSCRIBE
<input type=hidden name="action" value="subscribe">

UNSUBSCRIBE
<input type=hidden name="action" value="unsubscribe">

But what do I do with this piece of code (below)? Do I leave it in the Form?


Code
<input type="submit" value="GO!">


I知 assuming I have to keep it in the Form because of the submit action?

What does input type=hidden mean?

In Reply To
That's simple. Just use something like
../jennyw_menu/jennyw_pic.gif

Thanks! I thought it might be something like that, I just wanted to make sure!

=======================

When I send all the subscribers in my mailing list an email I receive a confirmation email, stating that my message was sent to everyone. However, my name shows up like this (below) in my inbox when I receive that confirmation:


Code
Jenny W themustache@...

But the recipients of my mailing list see my name like this (which is correct)


Code
Jenny W

How can I get

Code
JennyW themustache@

to display the following in my inbox?


Code
Jenny W



This isn稚 a major concern at all. I知 just curious if there痴 a fix for the problem.

Thanks!!
Jenny



mhx
Enthusiast / Moderator

Jun 19, 2001, 7:25 AM

Post #89 of 123 (6077 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi,


In Reply To
But what do I do with this piece of code (below)? Do I leave it in the Form?

Yes, your assumption is right. You need that piece of code for the submit button.

In Reply To
What does input type=hidden mean?

This is simply a hidden field in a HTML form. 'hidden' means it's not visible to the user, but it contains information, in this case what action to perform.
Concerning the email address thing, I don't really understand the problem yet. Can you tell me which script is responsible for sending this confirmation email and where I can find it? I'm sure there's a solution.

Bye,
Marcus



JennyW
journeyman

Jun 19, 2001, 8:25 AM

Post #90 of 123 (6076 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus,

Do you need any more info., regarding my explanation of the email problem?

I believe the first script sends the confirmation email, but I added two others in case I知 wrong.

http://jennyw2.netfirms.com/002_mail-admin.txt

http://jennyw2.netfirms.com/001_cfg.txt

http://jennyw2.netfirms.com/003_maillist.txt

If there痴 anything else you need, then let me know~!

Thanks,
Jenny



mhx
Enthusiast / Moderator

Jun 19, 2001, 11:38 AM

Post #91 of 123 (6072 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

yeah, I got it...
The problem is here

Code
sub process_complete { 
open (MAIL, "|$mailprog") or &error("Unable to open the mail program");
print MAIL "To: $yourmail\n";
print MAIL "From: $yourmail<Mailing List $version>\n";
print MAIL "Subject: Message has been sent to all subscribers! Mailing List $version\n";
print MAIL "Message has been sent to all subscribers!\n";
close(MAIL);
}

Remove the part in red and try again, I guess it should work then.

Bye,
Marcus



JennyW
journeyman

Jun 19, 2001, 7:01 PM

Post #92 of 123 (6063 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hey Marcus,

I always wanted to ask you

What does 芭hx mean?

Your help is invaluable! Both of your solutions worked wonders!

I adjusted the portion in red and my name showed up as Jenny W in my inbox!

Thanks to your help, I also have two separate pages for subscribing and unsubscribing! I adjusted the code as you directed and it worked great!

Here are my new pages

http://jennyw2.netfirms.com/mailing_list_subscribe.htm

http://jennyw2.netfirms.com/mailing_list_unsubscribe.htm

I have another question for you

If you enter an email address in one of the url痴 above you will receive one of several messages.
For example, try just entering the following in the Form

&

Now, press GO!

You値l receive a message that says

Unable to subscribe your email address
Please don't use weird symbols


I don稚 like where this text is located in the browser window (ignore the text that痴 yellow (in the browser) it痴 not in the perl script and doesn稚 have anything to do with this question).

I would like the text to be further away from the left side of the browser window. I don稚 want it centered, I just want to move it to the right a 鼠il bit.

In the code, I tried applying a <font> tag (below) within the print line.

I applied the following <html> (in purple) to the print line

print "<font color="#000000">iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii</font>
<h2>Unable to subscribe your email address<h2>\n";

The background of my page is black, which is why I made the i痴 black. I thought that would push the Unable to subscribe your email address line over a bit, but it didn稚. When I did this my script wouldn稚 work. My browser displayed 的nternal Server Error. I took the font tags out and the script worked again.

I then tried adding the following, but was unsuccessfull

if ($form{'address'}=~ tr/;<>*|`&$!#()[]{}:'"//) {
&dheader;

print "<font color=\"#000000\";
print " " x 54;
print "</font>\n";

print "<h2><i>Unable to subscribe your email address</i></h2>\n";
print "Please don't use weird symbols
\n";
&dfooter;
exit;
}


I tried another piece of scripting, but again, I was unsuccessfull

if ($form{'address'}=~ tr/;<>*|`&$!#()[]{}:'"//) {
&dheader;

print qq(
<div style='position:relative;left:200px'>
<h2><i>Unable to subscribe your email address</i></h2>
Please don't use weird symbols</div>
);

&dfooter;
exit;
}

What can I do, to move the text to the left a 鼠il bit?[

Thanks for reading.
Jenny



Pro_4
User

Jun 19, 2001, 7:48 PM

Post #93 of 123 (6061 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

You might have just made this a typo in your post but in the :

Code
print "<font color="#000000">iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii</font>  
<h2>Unable to subscribe your email address<h2>\n";

You forgot to \ out the = sign for color = "#000000".

Sooooo, it would look like this:

Code
print "<font color=\"#000000">iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii</font> 
<h2>Unable to subscribe your email address<h2>\n";

Hope that helps :)

P.S. If that is confusing i am sure mhx will have a brilliant solution.



Yes i am a palm tree. What are you plantist or something!?


mhx
Enthusiast / Moderator

Jun 19, 2001, 11:13 PM

Post #94 of 123 (6060 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

first of all, to answer your most important question Wink:

In Reply To
What does 芭hx mean?

I was trying to get an email address from one of germany's freemail providers - GMX - several years ago. Because the domain was just @gmx.de, I wanted to have the account name as short as possible. Since my full name is Marcus Holland-Moritz and GMX accounts had to be three letters at least, I tried mhm@gmx.de first. Unfortunately, someone else got this address. So I was searching for something else and ended up with that mhx thing, because it sounded just like gmx. And from then on, I reuse it wherever I can because it sounds and looks quite ok to me. I hope this makes it clearer...
Regarding your text alignment problem, I don't think pro_4's solution will work better than yours. The problem is that the <Hx> tags always start a new row. If you could have had a look at the output with non-black characters, you would have noticed that your iiiiiiiiiii's were printed above the line you were trying to shift left. As always, there's more than one solution to this. I'll give you the one which I think is the clearest (anyone may of course disagree, but I really like tables...).

Code
if ($form{'address'}=~ tr/;<>*|`&$!#()[]{}:'"//) { 
&dheader;

print q(<table><tr><td width="100px"></td><td>
<h2><i>Unable to subscribe your email address</i></h2>
Please don't use weird symbols</td></tr></table>);


&dfooter;
exit;
}

By changing the green text you can adjust the distance from the left margin in pixels. I hope this works as you expect it to.

Bye,
Marcus



JennyW
journeyman

Jun 20, 2001, 5:55 PM

Post #95 of 123 (6048 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus Holland-Moritz,
I too like the nickname mhx, it sounds good!

The scripting you posted worked well on a few of the cgi generated messages, but I知 having trouble applying your code to three messages the script produces.

For each message:
The original scripting is colored in purple.
My adjustments using your scripts are highlighted in blue.

foreach $list(@list) {
if ($list =~ /$form{'address'}/i) {
&dheader;
print "<h2>Unable to subscribe your email address</h2>\n";
print "The email address \"$form{'address'}\" is already in the database
\n";
#print "Please click <a href=\"$main_page\">here</a> to return to our main page.
\n";
&dfooter;
exit;
}
}


foreach $list(@list) {
if ($list =~ /$form{'address'}/i) {
&dheader;
print q(<table><tr><td width="100px"></td><td>
<h2><i>Unable to subscribe your email address</i></h2>
The email address \"$form{'address'}\" is already in the database</td></tr></table>);
#print "Please click <a href=\"$main_page\">here</a> to return to our main page.
\n";
&dfooter;
exit;
}
}

===============================

&dheader;
print "
\"$form{'address'}\" was successfully removed from the database
\n";
#print "Please click <a href=\"$main_page\">here</a> to return to our main page.
\n";
&dfooter;
exit;
}
}

&dheader;
print q(<table><tr><td width="100px"></td><td>
\"$form{'address'}\" was successfully removed from the database</td></tr></table>);
#print "Please click <a href=\"$main_page\">here</a> to return to our main page.
\n";
&dfooter;
exit;
}
}


===============================

&dheader;
print "
\"$form{'address'}\" was not found in the database
\n";
#print "Please click <a href=\"$main_page\">here</a> to return to our main page.
\n";
&dfooter;
}


&dheader;
print q(<table><tr><td width="100px"></td><td>
\"$form{'address'}\" was not found in the database</td></tr></table>);
#print "Please click <a href=\"$main_page\">here</a> to return to our main page.
\n";
&dfooter;
}


I tried adding quotes and < br > tags within the updated script, but I had no luck, the script still wouldn稚 show the email address submitted through the Form.

Do you know what could be wrong?

Thanks,
Jenny



mhx
Enthusiast / Moderator

Jun 21, 2001, 1:30 AM

Post #96 of 123 (6045 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

yes, I do know what is wrong Smile.
The problem is that I used 'non-interpolative' or single quoting on the string using the q() operator. Hmmm, I guess I've got to tell you about the difference between single and double quoting...
Ok. If (in Perl) you want a string to appear as it is, you put single quotes around it or you use q(). If you have any variable names in the string, e.g. $form{'address'} this name (and not its content) will appear in the string. If instead you want the content of variables to appear inside the string, you use double quotes or qq() for so-called interpolative quoting. Then, each variable inside the string is replaced by its content. Now, here are some examples to make this clearer:

Code
$name = "Jenny"; 
print 'Hello $name!'; # prints: Hello $name!
print q(Hello $name!); # prints: Hello $name!
print "Hello \$name!"; # prints: Hello $name!
print "Hello $name!"; # prints: Hello Jenny!
print qq(Hello $name!); # prints: Hello Jenny!
print qq(Hello "$name"!); # prints: Hello "Jenny"!
print "Hello \"$name\"!"; # prints: Hello "Jenny"!
print "Hello "$name"!"; # is an error !!!
print 'Hello "$name"!'; # prints: Hello "$name"!

Now, perhaps you may have realized where the problem is. I've used q(), so no variable interpolation is done. If you use qq() instead, the code should work as far as I can see right now. You can also remove the backslashes before the double quotes, because you don't have to escape them inside a qq(). I'd guess that's all you've got to do to solve your problem, just turn q into qq.
BTW: You should have noticed that, instead of the address, \"$form{'address'}\" was printed out in the HTML?

Bye,
Marcus



JennyW
journeyman

Jun 21, 2001, 7:47 PM

Post #97 of 123 (6032 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Marcus!

In Reply To
You should have noticed that, instead of the address, \"$form{'address'}\" was printed out in the HTML?

Yep, I sure did notice! Thanks for mentioning though.

I followed the steps you posted today and adjusted my maillist.pl script. Everything worked great!
I added a q and deleted the backslashes ( \ ) to the three segments of script that required changes.

I知 sure you致e heard this before, but you are a really good teacher. I致e been on quite a few of these technical forums and you are by far the best and most straight forward teacher that I致e come across.

Like usual I have another question for you.

As you know, after I press the GO! Button to subscribe or unsubscribe an email address I知 brought to a new results page generated by a .cgi script.

Instead of going to a whole new page I was wondering if I could generate a popup window with the results of my subscription or unsubscription.

Basically, I知 want the script to do the same thing it痴 doing right now, except instead of going to a whole new cgi page, I would like a popup window instead.

Here痴 the code for a simple popup window

<a href="popup_test.htm" onClick="window.open('popup_test.htm','popup','scrollbars=no,resizable=0,width=320,height=132'); return false">Jenny痴 Popup Test</a>

Is it possible to do this?

Thanks again and again!
Jenny



mhx
Enthusiast / Moderator

Jun 22, 2001, 5:53 PM

Post #98 of 123 (6023 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,


In Reply To
I知 sure you致e heard this before, but you are a really good teacher. I致e been on quite a few of these technical forums and you are by far the best and most straight forward teacher that I致e come across.

Thanks a lot. Perhaps I have the wrong occupation? Wink
The popup window shouldn't be a problem, I think. But what do you want to happen besides a windows popping up that notifies the user he has been added to / removed from the mailing list? Do you want to stay on the subscribe/unsubscribe page? Do you want to go somewhere else?
Please tell me what exactly you want to happen and I'll try my very best to help you. But now I've got to get some sleep, it's 3 am. Time passes by so quickly in front of a computer...

Bye,
Marcus



JennyW
journeyman

Jun 23, 2001, 5:25 AM

Post #99 of 123 (6020 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi mhx!! It痴 Saturday!!

In Reply To
But what do you want to happen besides a windows popping up that notifies the user he has been added to / removed from the mailing list? Do you want to stay on the subscribe/unsubscribe page? Do you want to go somewhere else?

That痴 a good question. It annoys me that I didn稚 think of it. Thanks.

SUBSCRIBE
I want the Subscribe page to stay on the subscribe page (so I don稚 want this page to transfer anywhere).

UNSUBSCRIBE
I want the Unsubscribe page to transfer to another page after the popup window appears. Let痴 say, my index page.

In the future I can obviously configure which page I want to transfer to right?

Will it be difficult to change if at a later date I decide I want the SUBSCRIBE page to actually make a transfer to another page?


Thanks for keeping me on my toes!
Jenny



mhx
Enthusiast / Moderator

Jun 23, 2001, 8:54 AM

Post #100 of 123 (6017 views)
Re: Perl beginner - I need help please [In reply to] Can't Post

Hi Jenny,

I really, really hate to say that, but I don't have an answer for you this time. Frown
I've been thinking about the problem for some time now and didn't find a simple solution. I'm sure there is a solution, but it could mean an awful lot of work to modify the script. Perhaps I'm wrong and there is a simple solution, but if so, it didn't come to my mind yet. Perhaps because I didn't sleep that much. Wink
So, I'm not going to stop thinking about it and if I got an idea, be sure I'll tell you. But it may be that you'll have to live with you current script...
Sorry, no help this time. Anyway, I wish you a nice weekend.

Bye,
Marcus


First page Previous page 1 2 3 4 5 Next page Last page  View All
 
 


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

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