RE: Mail::Send question
Yep, if you want to bring that book home - drink some protein shakes, take your vitamins, and work out for a month before you buy it. - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -Original Message- From: Andrew Brosnan [mailto:[EMAIL PROTECTED] Sent: Monday, August 04, 2003 11:20 AM To: Camilo Gonzalez; [EMAIL PROTECTED] Subject: Re: Mail::Send question On 8/4/03 at 11:06 AM, [EMAIL PROTECTED] (Camilo Gonzalez) wrote: I sometimes wonder if all this shielding of intricacies is necessarly a good thing. Shouldn't I know how to use sendmail? I guess I'm a DIY kind of guy and I want to know how sendmail works. Fine, if a module makes it all easier, I'll certainly use it. But I want to know how the abstraction occurs. What happens if the module I'm using in lieu of sendmail is buggy and I have no idea why or how to circumvent the problem? Do I have control issues? Fine, go get the SendMail book, rent a truck to bring it home in, spend the next six years reading it, the next six after that trying to understand it, an additional two years familiarizing yourself with any updates, and then you will be ready to begin writing the code that someone else has already written ;-) Seriously, it has an arguably well earned reputation as being a bit, uhmm...difficult to master, and unless you really *want* to be a sendmail expert I think you will find one of the Mail:: modules will work nicely. Andrew -- The box said 'Windows XP or better' so I chose Mac OS X. -- 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]
Mail::Send question
Is there any way to force Mail::Send to accept a From name, as opposed to simply sending and using the hostname by default? I don't see anything in the docs about setting the From field in the headers. (of course, I can just open a pipe to sendmail, but I want to see if there's a way to pull this off first...) example: #!/usr/bin/perl -w require Mail::Send; my $mailbody = blah blah blah; my $to = '[EMAIL PROTECTED]'; my $from = '[EMAIL PROTECTED]'; my $msg = new Mail::Send; # $msg-from($from) # doesn't work and mail # doesn't get sent if you # use it $msg-to($to); $msg-subject('Mail from SomeBusiness.com'); my $fh = $msg-open; print $fh $mailbody; $fh-close; # When this mail comes in, it comes from # mywebaccountuserID@mywebhostdomain - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Mail::Send question
That did the trick. Thanks! Scot R. inSite -Original Message- From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED] Sent: Friday, August 01, 2003 7:59 PM To: Scot Robnett Cc: [EMAIL PROTECTED] Subject: Re: Mail::Send question Scot Robnett wrote: Is there any way to force Mail::Send to accept a From name, as opposed to simply sending and using the hostname by default? I don't see anything in the docs about setting the From field in the headers. (of course, I can just open a pipe to sendmail, but I want to see if there's a way to pull this off first...) Definitely avoid this if possible, there are numerous mail message modules, one of them is bound to provide what you need. example: #!/usr/bin/perl -w require Mail::Send; my $mailbody = blah blah blah; my $to = '[EMAIL PROTECTED]'; my $from = '[EMAIL PROTECTED]'; my $msg = new Mail::Send; # $msg-from($from) # doesn't work and mail # doesn't get sent if you # use it It appears that 'from' isn't one of the proper header methods, you should try using the 'set' or 'add' methods to add the header you want. For instance: $msg-set('From' = $from); $msg-to($to); $msg-subject('Mail from SomeBusiness.com'); my $fh = $msg-open; print $fh $mailbody; $fh-close; # When this mail comes in, it comes from # mywebaccountuserID@mywebhostdomain If this doesn't suffice you might try one of the other mail modules that is slightly more robust. http://danconia.org -- 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]
RE: PHP vs Perl
A language which I need to fight a lot with in order to find the right syntax for doing something is not a very clear and easy to use programming language. What are you fighting with? I don't really understand this point - if you want to talk about languages that place a lot of restrictions on you and *require* you to do things in one way and one way only, try C++ or Java. One of Perl's huge bonuses (and also a huge down-side), is that there are so many ways to get the job done. If you think that having 10 different ways to accomplish the same task makes it not very clear, I guess you're right...but I like the flexibility. I also like that there are some prebuild packages that contain Apache, MySQL and PHP configured in such a way that they all work very nice. There is no such a thing for Perl. Of course there is. The web hosts I work with all have Perl, MySQL, and DBI installed. Works beautifully. It is not very easy to install support for SSL, Net::SSLeay or the library for creating images for perl Image::Magick ... Teddy, Teddy's Center: http://teddy.fcc.ro/ Email: [EMAIL PROTECTED] - Original Message - From: Scot Robnett [EMAIL PROTECTED] To: Octavian Rasnita [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Sunday, July 27, 2003 8:35 PM Subject: RE: PHP vs Perl I think there are a couple of myths that need to be cleared up from that post. First, the idea that PDF manipulation and secure payment modules don't work very well in Perl. If one has had difficulty in making the modules work for them, it does not necessarily mean that the module is at fault - in some cases it might be, but typically I've found that when a module isn't working for me, I've usually missed something. Second, the idea that most of the new work can be found in PHP and ASP is not necessarily the case. The tech industry has taken a hit over the past few years, and if you're looking at the job boards like Monster, maybe most of what you *see* is slanted toward Microsoft technology. PHP and ASP are pushed at corporations because somebody at a high level in the chain has been told these are the widgets they should use. Trust me, I worked for one of the major telecom players for 6 years, and I've seen how the buzzwords work themselves into the hiring process. However, in my business (I deal with small to medium-sized companies), they're not concerned about what technology I use as long as it works. So far, the language that makes most of my projects work is Perl. -Original Message- From: Octavian Rasnita [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 1:38 PM To: [EMAIL PROTECTED] Subject: Re: PHP vs Perl I think the reason why PHP is used more and more much than Perl is that for CGI related programs it is much simpler to use than perl. For example it has a set of libraries for the most used functions in a CGI program, for example SSL support, a module for reading and creating PDF files, modules for accessing some payments operators for shopping carts, etc. Those modules can be created in perl, but even if some of those modules exists for perl, they don't work very well. I've tried to use the modules for creating a PDF document under Windows, but with no success. It is pretty hard to install some of the perl modules under Windows because most of them need to be compiled, need a compiler to be installed, etc. With PHP it is much simpler to work and I can see this even though I don't know PHP at all yet. The motivation for new perl learners is not very big because most of the jobs can be found in PHP/ASP and only after that in perl/Cold Fusion. I hope Perl 6 will have much more standard modules and the modules from CPAN will be able to be installed without compiling them with a local compiler. We should keep in mind that even if the most web servers are running under Unix/Linux, most computer users and possibly web developers are working under Windows and the CPAN modules should be all compatible with Windows also, and not only with Linux. Teddy, Teddy's Center: http://teddy.fcc.ro/ Email: [EMAIL PROTECTED] - Original Message - From: Todd W. [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, July 24, 2003 11:26 PM Subject: Re: PHP vs Perl [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] One of the coolest answers is at: http://us2.php.net/manual/en/faq.languages.php#faq.languages.perl where it notes that Perl is a complicated language that comes from a time before the web whereas PHP was built specifically for the web side of the game... Great! Interesting read, though this still rings true for me PHP is easier to integrate into existing HTML than Perl. They see it as a bonus, I see it as a hinderance for a multiple person operation. Situation.. I was thinking the same thing when I read
RE: Another Regex question.
#!/usr/bin/perl -w my $TS = THIS INPUT IS IN ALL CAPS; my $lc_ts = lc($TS); my @words = split(/\s+/, $lc_ts); my @letters = (); foreach my $word(@words) { chomp($word); if($word =~ /^(\w{1})(\w*)/) { print uc($1) . $2 . ; } else { die Something is seriously wrong here...; } } # OUTPUT I GOT FROM THIS: This Input Is In All Caps - Scot Robnett inSite Internet Solutions Square West Center 454 West Jackson Street Woodstock, IL 60098 (815)206-2907 office (815)790-9687 mobile [EMAIL PROTECTED] http://www.insiteful.tv http://www.mawebcenters.com/insite2000 -Original Message- From: Sara [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 23, 2003 11:59 AM To: org Subject: Another Regex question. $TS = THIS INPUT IS IN ALL CAPS; $TS_cont = lc $TS; $TS now prints out this input is in all caps What If I want first letter in caps for every word in string? which should be This Input Is In All Caps TIA, Sara. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Regex problem
This is similar to Wiggins, except it checks to make sure that A. We have a two word sequence B. We don't have a comma These are still very basic levels of processing, though - Wiggins is right that we would need to see a more thorough example of data ranges to know exactly what to offer. Tested, the results of this were that the program printed SD and exited as expected. Case sensitivity/insensitivity matching isn't required since \w will match either upper or lower case characters. my $name = SARA DEILY; if (($name =~ /\w+\s+\w+/) and ($name !~ /,/)) { chomp($name); if ($name =~ /^(\w{1})\w*\s+(\w{1})\w*$/) { my $initials = join (, $1 . $2); print $initials . \n; } else { print Something\'s wrong here: $!\n; } } else { # do more processing on different types of entries print Doh!; exit; } -Original Message- From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED] Sent: Sunday, July 20, 2003 7:10 PM To: Sara Cc: org Subject: Re: Regex problem Sara wrote: $name = SARA DEILEY; how its possible to grasp only initials for First and Last name i.e $name =SD?? Depends on how standardized your data is, something simple like this should work for the above: my $name = 'SARA DEILEY'; my $initials; if ($name =~ /^(\w)\w*\s+(\w)\w*/) { $initials = $1 . $2; print Initials: $initials\n; } else { die Can't determine initials: $name; } But this presents a number of problems, for instance people with 2 first names, and you will have to decide what to do with names like McDonald, or if your data can be entered by humans, what if someone enters: Deiley, Sara, etc. You might also consider using 'split' and 'substr' instead of using a regex. Either way you need to provide more info about your possible data set range if the above is not sufficient. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: CGI Module Reference
Online docs --- perldoc CGI O'Reilly books -- CGI Programming with Perl CGI Cookbook - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -Original Message- From: Shaw, Matthew [mailto:[EMAIL PROTECTED] Sent: Monday, July 07, 2003 1:44 PM To: [EMAIL PROTECTED] Subject: CGI Module Reference Hi all, Could someone direct me to a reference that contains all of the available methods in the CGI module? I'm both new to using mod CGI and HTML in general so I'm just looking for a good rosetta stone between the two. I got hung up recently trying to implement $query-Tr and didn't realize that it's Tr rather than tr. Maybe I'm asking for the wrong thing -- Any help appreciated. Would prefer documentation freely available but recommended commercial books would be acceptable as well. Thanks in advance for any help Matt -- 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]
Packages, run modes, and scopes, oh my
I was wondering if anyone can point me to newbie-type tutorials on any of the following (including but not limited to which perldocs I can read): - Definition of 'lexical' and 'canonical' - Differences between 'my' and 'local' - Good overview of packages and namespaces - How to build modules - Effective re-use (building subroutines for efficiency and portability) - Why do I '@_ = shift;' on subroutines? I already have: - Learning Perl - Perl in a Nutshell - Teach Yourself Perl in 21 Days - The obvious: perldocs, CPAN, etc. I'm not so good at grasping abstract data, I learn better by building, breaking, and fixing until I get it right. Thanks in advance for any pointers, especially for tutorial-type info with program building exercises. - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Doing time/date calculations
How would one go about determining if something is 3 days old, 3 months old, 1 year old, etc., based on the following scenario? The date that a user subscribes to our site is stored in a MySQL database in the DATE format -mm-dd. So column 'SubscribeDate' looks like 2003-06-18, for instance. When I pull that value out of the column, how do I do a measurement to determine its age? !-- snip -- # Get username from form selection my $subscriber = $q-param('user'); # Connect to DB my $dbh = DBI-connect(DBI:mysql:db_name:localhost,usr,pass) or die Could not connect to DB: $!; # Prepare and execute statement my $sth = prepare(SELECT SubscribeDate FROM UserData WHERE UserName = ?); $sth-execute($subscriber); while(my($data) = $sth-fetchrow_array) { my $subscription_age = # HOW WOULD I DETERMINE THIS? print qq($subscriber\'s account is $subscription_age old.\n); } $sth-finish(); !-- /snip -- Scot R. inSite -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: array/split/join question
Seems like the same results would be achieved by not opening it at all the first time through. You're right, I commented out the extra slurpage, moved close(OUT) and close(IN) and it still worked. So basically you have a very elaborate and expensive no-op. Story of my life. ;-) If you really want the whole document to appear to be slurped (which it isn't currently) then rather than pushing to the array @cleandoc, concatenate to a scalar with '.='. Along the lines of while() { my $doc .= $_; } # ? really depends on your purposes (aka do you ever need the file in memory at once?) and the size of your files (difficult to slurp a 2 GB file into 1 GB of RAM)... It's always an HTML file under 200K, so there should never be that problem You might also be better off using an HTML parser, in general it will do a better (and often faster) job than a whole list of regex's which are almost guaranteed to mess up oddly structured HTML. There are several available on CPAN. I looked at HTML::Parser and I'd have to teach it about the funky WordPerfect-generated tags. This file is a newsletter that is published in exactly the same format, exactly the same way, with no alterations in the structure. The only thing that changes is the content of the articles, so the homemade regex seems to work fine on any of the newsletters it gets fed. In general, point well-taken, though. http://danconia.org #!/usr/bin/perl -w use strict; $/ = ''; # Let's slurp in paragraph mode to begin with my $inputfile= '/path/to/DU051503USBZ.htm'; my $outputfile = '/path/to/out.htm'; my @cleandoc = (); # Rather than printing the whole document to the new file # a line at a time, we'll build an array and simply print # the array to the document. Whether this saves any CPU or # not is beyond me... # Clean the crud out of the uploaded file and print to a new, clean file open(IN, $inputfile) or die qq(Couldn\'t open $inputfile: $! \n); open(OUT, $outputfile) or die qq(Couldn\'t open $outputfile: $! \n); while(IN) { chomp; $_ =~ s/\/*html//ig; # We'll be printing our own headers $_ =~ s/\/*head//ig; $_ =~ s/title(.*?)\/title//ig; $_ =~ s/\/*body(.*?)//ig; $_ =~ s/(p align=\center\)(U.S. BUSINESS JOURNAL)//ig; $_ =~ s/(p align=\center\)*(\(The Nation\'s Oldest Daily Business E-Newspaper\))//ig; $_ =~ s/strong/b/ig; $_ =~ s/\/*u//ig; # Icky, Netscape doesn't like u $_ =~ s/br wp=(.*?){1,}//ig; # Get rid of bizarre WordPerfect sludge! $_ =~ s/\r{2,}//g; $_ =~ s/\n{2,}//g; # Probably not necessary with chomp $_ =~ s/\^M//ig;# Windows can't be trusted push(@cleandoc, $_); } print OUT @cleandoc; close(OUT); close(IN); # Now let's slurp in whole document mode and print each of the sections, # split on p align=center, to the outfile so each section is on a # line of its own. We'll use this again later to open the cleaned-up file # in line mode and print the results to our database. undef $/; open(OUT, $outputfile) or die qq(Couldn\'t open $outputfile: $! \n); foreach my $section(@cleandoc) { chomp($section); my $chunk = join \n, split /p align=\center\/, $section; print OUT $chunk; } close(OUT); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Question about regexing/splitting results into array
I was wondering why this array that I am attempting to create at line 21 seems to be empty. If I want to put chunks separated by p align=center into the array, how could I do this differently to make it work? ## #!C:\Perl\bin\perl.exe -w $/ = ''; # slurp in paragraph mode my $inputfile = 'C:\path\to\file.htm'; my $outputfile = 'C:\path\to\OUT.html'; open(INFILE,$inputfile) or die Could not open IN: $! \n; open(OUTFILE,$outputfile) or die Could not open OUT: $! \n; my @sections = (); while(INFILE) { chomp; $_ =~ s/\r{3,}/\r/g; # change multiple carriage returns to single \r $_ =~ s/\n{3,}/\n/g; # change multiple newlines to \n (may not be necessary) $_ =~ s/\/*html//g;# these $_ =~ s/\/*head//g;# are $_ =~ s/\/*title//g; # pretty $_ =~ s/\/*body.*?//g; # obvious $_ =~ s/(br wp=.*?)+//g; # get rid of weird WordPerfect schneck @sections = split /p align=\center\/, $_; # these are the chunks I want print OUTFILE $_; } print OUTFILE \n\n; # add a couple of newlines to separate results foreach my $section(@sections) { chomp($section); print OUTFILE $section \n\n\n; # why is this printing nothing? } close(OUTFILE); close(INFILE); 1; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Question about regexing/splitting results into array
I think the escaping is still necessary in that case Maybe something like this would be cleaner: my @ary = split /qr{p align=center/}/, $_; That would work unless I was trying to interpolate into the pattern, because I set $/ = '' and read into memory in paragraph mode. I believe that the solution you show allows me to act on the match as $1, but in this case it wouldn't matter because it's only one pattern to match, not multiple patterns or sections of a pattern. If () autoescapes the special characters I'll just shut my mouth (or keyboard) then. :-) Scot R. inSite - Kristofer Hoch wrote: - split /p align=\center\/, $_ instead of matching p (space) a,l,i,g,n,=, \,c,e,n,t,e,r\ embrace it in parenthesis...no escaping neccessary... split /(p align=center)/, $_ At least I think that I am reading this book properlyh --- Scot Robnett [EMAIL PROTECTED] wrote: I was wondering why this array that I am attempting to create at line 21 seems to be empty. If I want to put chunks separated by p align=center into the array, how could I do this differently to make it work? ## #!C:\Perl\bin\perl.exe -w $/ = ''; # slurp in paragraph mode my $inputfile = 'C:\path\to\file.htm'; my $outputfile = 'C:\path\to\OUT.html'; open(INFILE,$inputfile) or die Could not open IN: $! \n; open(OUTFILE,$outputfile) or die Could not open OUT: $! \n; my @sections = (); while(INFILE) { chomp; $_ =~ s/\r{3,}/\r/g; # change multiple carriage returns to single \r $_ =~ s/\n{3,}/\n/g; # change multiple newlines to \n (may not be necessary) $_ =~ s/\/*html//g;# these $_ =~ s/\/*head//g;# are $_ =~ s/\/*title//g; # pretty $_ =~ s/\/*body.*?//g; # obvious $_ =~ s/(br wp=.*?)+//g; # get rid of weird WordPerfect schneck @sections = split /p align=\center\/, $_; # these are the chunks I want print OUTFILE $_; } print OUTFILE \n\n; # add a couple of newlines to separate results foreach my $section(@sections) { chomp($section); print OUTFILE $section \n\n\n; # why is this printing nothing? } close(OUTFILE); close(INFILE); 1; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] = -BEGIN GEEK CODE BLOCK- Version: 3.12 GIT d s+:++ a C++ UL++ US+ P+++ L++ W+++ w PS PE t++ b+ G e r+++ z --END GEEK CODE BLOCK-- __ Do you Yahoo!? Yahoo! Calendar - Free online calendar with sync to Outlook(TM). http://calendar.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Getting my head round hashes
You're not pulling in the DBI functions, for one thing. Short example of using the hashref function built into DBI is shown below. #!/usr/local/perl -wT use strict; use CGI; use DBI; # need this! my $marker = 5; (or whatever number) my $dbh=DBI-connect(DBI:mysql:database:localhost,user,password); my $sth=$dbh-prepare(SELECT task_ID, priority FROM task_list WHERE priority ?); $sth-execute($marker); while(my($hashref) = $response-fetchrow_hashref) { $hashref-{priority}--; # decrement each priority by 1 } $sth-finish; $dbh-disconnect; Scot R. inSite -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: regexing AND NOT
I don't know if you realize that you just wrote an SQL statement. Have you considered putting all of this in a DB? Use the DB to do the searching and sorting, and Perl to display the results. #!/usr/bin/perl -w # quick DB sample, I know it doesn't use strict, sue me :-) use DBI; # connect $dbh = DBI-connect(DBI:mysql:db_name:localhost,username, password) or die Could not connect to DB: $!; # search terms $searchstring = foo; # you can get this from STDIN, param, etc. $nosearch = bar; # we'll tell our SELECT this is not kosher # build query $statement = END_OF_STATEMENT; SELECT id,text FROM tableName WHERE text LIKE '%?%' AND NOT LIKE '%?%' END_OF_STATEMENT # execute and return results $sth = $dbh-prepare(q{$statement}) or die $dbh-errstr; $sth-execute($searchstring,$nosearch) or die $dbh-errstr; while(($id,$text) = $sth-fetchrow_array) { print $id - $text \n; # prints rows containing foo }# in the 'text' column # finish and disconnect $sth-finish; $dbh-disconnect; -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, June 06, 2003 10:26 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: regexing AND NOT Dear Ted, thank you for answering so quickly. The problem is, I don't want to make the users write regular expressions. Of course, I have to test them with the help of 'eval' in order to prevent that an illegal regular expression is blocking the whole cgi-application. The reason for not using regular expressions is that my search application is meant for searching patterns in a bilingual text (German and Russion), which is displayed in cyrillic and with German umlauts. And it would be a lot easier if I could just search for sun moon AND NOT suns moons So, I appreciate all ideas. Peter --- Zitat von [EMAIL PROTECTED]: perlfaq6: (cut-n-paste to get the final - there) http://www.perldoc.com/perl5.8.0/pod/perlfaq6.html#How-do-I-match-a-pattern- that-is-supplied-by-the-user- How do I match a pattern that is supplied by the user? Well, if it's really a pattern, then just use chomp($pattern = STDIN); if ($line =~ /$pattern/) { } Alternatively, since you have no guarantee that your user entered a valid regular expression, trap the exception this way: if (eval { $line =~ /$pattern/ }) { } [...] Good luck, .ted -- 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]
RE: Difference of $hash, and %hash. (was Getting my head round hashes)
Dave, I highly recommend most of the O'Reilly books, but especially Learning Perl by Randal Schwartz. For spot reference I like SAMS Teach Yourself Perl in 21 Days and IDG's Perl for Dummies, although there are portions of each in which your more militant Perl programmers would say their examples leave something to be desired. For the raw beginner they have some good info, however. I have been in a similar situation, needing help on things that are more basic to the experienced community. I find this list to be helpful, too. Word of caution: I tried getting help on IRC (irc.debian.org) and found the Perl community there to be much less helpful and much more arrogant (if any of you are on this list, I'm definitely generalizing, so please take that with a grain of salt). RTFM is a common response there, even if you -have- RTFM. :-) -Original Message- From: Greenhalgh David [mailto:[EMAIL PROTECTED] Sent: Friday, June 06, 2003 12:05 PM To: drieux Cc: cgi cgi-list Subject: Re: Difference of $hash, and %hash. (was Getting my head round hashes) On Thursday, June 5, 2003, at 11:20 pm, drieux wrote: On Thursday, Jun 5, 2003, at 14:33 US/Pacific, Greenhalgh David wrote: [..] My thanks to both of you. The explanation was clear even to me, much better than the book i am using to learn perl. [..] which book are you trying to learn from? Several books, in fact. Basic learning to crawl stuff from Perl and CGI by Elizabeth Castro and proper stuff from a book that's just called Perl. I managed to leave it at work so i don't recall the author, but that one is very comprehensive and is clearly written for people who know what they are talking about. My /real/ problem is that object oriented code is a foreign language. My job is with microwave comms hardware and I have no need to do software at all, so an explanation which is plain as day to people who speak the language is far from that to a raw beginner like me. Nevertheless, it is by challenging ourselves that we learn and it is by finding patient souls like this list to nurse us through the process that we survive the learning! Dave -- 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]
RE: how to create a submit button in perl?
perldoc CGI -Original Message- From: Annie [mailto:[EMAIL PROTECTED] Sent: Friday, June 06, 2003 3:57 PM To: [EMAIL PROTECTED] Subject: how to create a submit button in perl? hi i need to create a submit button on one of my web page and i need the code to create that in perl? can anyone help me!! - Do you Yahoo!? Free online calendar with sync to Outlook(TM). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to automate the sending of mail
I need my web site to automatically send an email confirmation. I'm using CGI Perl 5.6 on IIS on Win2000. What options are there for doing this? MIME::Lite Mail::Sendmail Win32::OLE -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how to compare to string variables
Or even if you don't want them to be identical but just similar in that they contain the same string somewhere within the variable, i.e. $a2 = 'Lambott'; $a3 = 'fooLambottblah'; if ($a3 =~ /$a2/) { # do something } else { # do something else } or what if you want to match it regardless of case? $a2 = 'Lambott'; $a3 = 'laMboTt'; lc($a2); lc($a3); # Now $a2 eq $a3 because both of # their values are lower-cased to 'lambott'. if ($a2 eq $a3) { # Houston, we have a match # do something; } # Note: We could have done uc($a2); uc($a3); # in which case both values would be 'LAMBOTT' # because uc converts the string to upper case. -Original Message- From: Boon Chong Ang [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 04, 2003 1:33 AM To: Annie; [EMAIL PROTECTED] Subject: RE: how to compare to string variables If($a2 eq $a3) { ...} else {} Is this what you want? Thank you best regards, ABC -Original Message- From: Annie [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 04, 2003 2:31 PM To: [EMAIL PROTECTED] Subject: how to compare to string variables I have two strings which I am receiving from two text fields in a form. I want to compare these... $a2='Lambott' $a3='Lambott' can anyone tell me how i can compare that the string inside a2 and a3 is similar. thanks - Do you Yahoo!? Free online calendar with sync to Outlook(TM). -- 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]
RE: how to compare to string variables
Dennis, I agree, and it's good that they saw both of these e-mails. Your suggestion is faster and also condenses the script(good things of course)...but newbies need the exposure to the whole TMTOWTDI concept too. :) I also like your suggestion better because it just ignores the case of the string, rather than changing the case of the string. -Original Message- From: Dennis Stout [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 04, 2003 1:51 AM To: Scot Robnett; [EMAIL PROTECTED] Cc: Boon Chong Ang; Annie Subject: Re: how to compare to string variables Or even if you don't want them to be identical but just similar in that they contain the same string somewhere within the variable, i.e. $a2 = 'Lambott'; $a3 = 'fooLambottblah'; if ($a3 =~ /$a2/) { # do something } else { # do something else } or what if you want to match it regardless of case? $a2 = 'Lambott'; $a3 = 'laMboTt'; lc($a2); lc($a3); # Now $a2 eq $a3 because both of # their values are lower-cased to 'lambott'. I'd just modify your first case. instead of if ($a3 =~ /$a2/) { I'd say if ($a3 =~ /$a2/i) { They both work. Just tossing out new ideas for folks to play with :) Dennis -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Another regex question
Okay, I've looked at perlre, perlretut, perldoc.com, Learning Perl, and a partridge in a pear tree, and I'm still stupid. :) Does anyone out there have a working example script that does matching over multiple lines, preferably an HTML file? I'm just having a lot of difficulty with this and it would help to see some real-world stuff. I've POD'd myself to death. Scot R. Example: -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Another regex question
I don't understand what you did in that example that I didn't do already...there was a script sample underneath the HTML that does what you're showing, I'm having trouble with the multi line matching and other than changing $/ (which I did), I don't see anything different... -Original Message- From: Andrew Brosnan [mailto:[EMAIL PROTECTED] Sent: Thursday, May 29, 2003 1:45 PM To: Scot Robnett; [EMAIL PROTECTED] Subject: RE: Another regex question On 5/29/03 at 12:27 PM, [EMAIL PROTECTED] (Scot Robnett) wrote: Will the file always be formated as below (with the blank line between articles)? If so you could set the record separator '$/' to paragraph mode to read each of them in: # $/; #default is newline # $/ = ; # paragraph mode (blank line) # undef $/; # slurp mode (the whole file) my @ary; while (FH) { $/ = ; push @ary, $_; } foreach my $thingie(@ary) { #do something with $thingie } btw - call subs like: sub_name(); ### HTML file ### ... p align=centerstrongToday's Headlines:/strong br wp=br1br wp=br2 br wp=br1br wp=br2 pstrongStory Tag Line/strong blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story. br wp=br1br wp=br2 br wp=br1br wp=br2 pstrongStory Tag Line/strong blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story. br wp=br1br wp=br2 br wp=br1br wp=br2 pstrongStory Tag Line/strong blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story. ### /HTML file ### -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Another regex question
Andrew, Thanks for trying to help. Scot -Original Message- From: Andrew Brosnan [mailto:[EMAIL PROTECTED] Sent: Thursday, May 29, 2003 3:05 PM To: Scot Robnett; [EMAIL PROTECTED] Subject: RE: Another regex question Try this: #!/usr/bin/perl #File: use warnings; use strict; #set slurp mode undef $/; my $stuff_i_want; while (DATA) {#read in your file #match up to Today's Headlines (or whatever) if (/Today's Headlines:\/strong/) { $stuff_i_want = $'; #put the rest in $stuff_i_want } else { #deal with this possibility; } } #split on blank line (or whatever) my @articles = split '\n\n', $stuff_i_want; foreach my $thingie(@articles) { #do something with your $thingie print here is a thingie: \n , $thingie, \n\n; } __END__ html head title/title /head body text=#00 link=#ff vlink=#551a8b alink=#ff bgcolor=#ff p align=centerPUBLICATION TITLE p align=center(Publication Subtitle) br wp=br1br wp=br2 p align=center strongMay 20, 2003/strong br wp=br1br wp=br2 p align=center(copyright notice) br wp=br1br wp=br2 br wp=br1br wp=br2 br wp=br1br wp=br2 p align=centerSOME ADVERTISEMENT HEADING br wp=br1br wp=br2 p align=center pblah blah blah advertisment blah blah blah advertisement blah blah blah advertisement blah blah blah advertisement blah blah blah advertisement. br wp=br1br wp=br2 br wp=br1br wp=br2 br wp=br1br wp=br2 p align=centerstrongTip of the Day/strong br wp=br1br wp=br2 p align=centerstrongTip of the Day Subject/strong br wp=br1br wp=br2 pblah blah blah tip of the day blah blah blah tip of the day blah blah blah tip of the day blah blah blah tip of the day blah blah blah tip of the day. br wp=br1br wp=br2 br wp=br1br wp=br2 br wp=br1br wp=br2 p align=centerstrongToday's Headlines:/strong br wp=br1br wp=br2 br wp=br1br wp=br2 pstrongStory Tag Line/strong blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story. br wp=br1br wp=br2 br wp=br1br wp=br2 pstrongStory Tag Line/strong blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story. br wp=br1br wp=br2 br wp=br1br wp=br2 pstrongStory Tag Line/strong blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story blah blah blah story. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help or point to the right documentation?
Can anyone point me to what documentation I should be reviewing to solve the following problem? I have an HTML file and want to look through it for certain comment tags or lines containing particular text strings, then split it up into ads and articles, for instance. Let's say I have a section for an advertisement that looks like this: !-- ad -- # line of HTML # another line of HTML # etc. !-- end ad -- and another section, let's call it the articles section of the HTML newsletter, that starts with a line containing Today's Headlines and looks like this. The client is generating the HTML file with WordPerfect, or as you can see from the looks of this code, WordImperfect: p align=centerstrongToday's Headlines:/strong br wp=br1br wp=br2 br wp=br1br wp=br2 pstrongCompany A/strong reports a 2nd quarter loss of $146 million... br wp=br1br wp=br2 pstrongCompany B/strong sells its fishing business... br wp=br1br wp=br2 pstrongCompany c/strong blah blah blah... What should I be looking at to learn how to parse each of those individual segments (ads and articles) into usable arrays or hashes? Any direction would be great. Thanks! Scot R. inSite -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Removing all \n in a text file.
By writing it this way: open(OUTPUTFILE, . $outputFile); the script thinks that you are trying to open a file called Out_input2.txt with the greater than sign actually being part of the file name. But what you want to do is open Out_input2.txt for writing, in which case the greater than sign, which means open this file for writing, needs to be contained inside the quotes. open(OUTPUTFILE, $outputFile); Scot R. inSite -Original Message- From: Daniel Gross [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 01, 2003 1:07 PM To: 'Scot Robnett' Subject: RE: Removing all \n in a text file. Hi Scot, Thanks for your help. I am not sure in what way this code differs from my previous one. Is the change in the open statement significant wrt to how \n are read and written. Thanks Dani -Original Message- From: Scot Robnett [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 01, 2003 1:42 PM To: Daniel Gross; [EMAIL PROTECTED] Subject: RE: Removing all \n in a text file. What if you made just this small change to your code? my $INPUTFILEHANDLE; my $OUTPUTFILEHANDLE; my $outputFile = Out_input2.txt; # If this is not in the # same directory as your # script, make sure that # you use the full path open (INPUTFILEHANDLE, input.txt); # When in doubt, full path # This is what you had: # open (OUTPUTFILEHANDLE, . $outputFile); # Instead, I think you want open (OUTPUTFILEHANDLE, $outputFile); # overwrites file # open (OUTPUTFILEHANDLE, $outputFile); # would append instead while(INPUTFILEHANDLE) { chomp $_; # just added $_ to make it # explicit what we're chomping print OUTPUTFILEHANDLE $_; } close OUTPUTFILEHANDLE; close INPUTFILEHANDLE; # Scot R. # inSite -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: The very un-useful 'premature end of script headers' error message
Not really. If your form allows uploads, your form allows uploads. That's where DoS comes into play. Disguising the location of your code is a start, but you still have to figure out what you're going to do if someone tries to paste rogue code into your form or hit you with an obnoxiously large upload. CGI.pm does have some provisions for this built in, and I highly recommend its use for web forms as opposed to home-grown CGI. I believe many others on the list recommend the same Scot R. Well, does it help that this code snippet we have been looking at is not in a file with a .cgi or .pl extension, but in a .pm file being used by the actual .cgi file that people would be posting to. Jes' curious.. Thanks 4 All Luke -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: The very un-useful 'premature end of script headers' error message
I was out of the loop on this one for awhile, but isn't that why $CGI::POST_MAX and $CGI::DISABLE_UPLOADS were created? If you need to allow multipart (or any type) of uploads, use POST_MAX and set a size limit. That way, if something is - by your determination - excessively large, your script will exit cleanly with an error message. The answer to your question is: Be afraid, be very afraid. A wiley cracker may be able to run system commands if you allow him/her to upload code. Even without knowing that much, they could simply create a script that generates a big enough upload to cause DoS (denial of service) on your server. My advice is always to err on the side of caution. Never think that would never happen on MY site. - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -Original Message- From: Cool Hand Luke [mailto:[EMAIL PROTECTED] Sent: Monday, March 31, 2003 1:38 PM To: fliptop Cc: [EMAIL PROTECTED] Subject: Re: The very un-useful 'premature end of script headers' error message just because you don't need to parse any binaries doesn't mean your users won't try to submit one. don't forget anyone can create any kind of form that posts to your cgi. so there's nothing stopping me from creating a form like this: form method=post action=http://coolhandlukesite/cgi-bin/script.cgi; enctype=multipart/form-data input type=file name=hugefile input type=submit /form Good point, I hadn't thought of that. My only question is now, what will happen? Is there a security risk I should worry about? Is this really dangerous? Thanks 4 the help. Luke -- 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]
CPAN/Matt's???
Is anyone else seeing Matt's script archive when they try to go to CPAN? Scot R. inSite -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: CPAN/Matt's???
Ugh, completely forgot what day it was. Egg + face = me. - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -Original Message- From: Hughes, Andrew [mailto:[EMAIL PROTECTED] Sent: Monday, March 31, 2003 8:11 PM To: '[EMAIL PROTECTED] ' Subject: RE: CPAN/Matt's??? doh! -Original Message- From: Kevin Meltzer To: Hughes, Andrew Cc: [EMAIL PROTECTED] Sent: 3/31/2003 8:07 PM Subject: Re: CPAN/Matt's??? Some places around the world, it is April 1 ;-) On Mon, Mar 31, 2003 at 07:47:47PM -0500, Hughes, Andrew ([EMAIL PROTECTED]) said something similar to: I just got it as well. If you click on the MSA logo, it takes you to this page http://www.cpan.org/index2.html What's going on? Andrew -Original Message- From: Scot Robnett [mailto:[EMAIL PROTECTED] Sent: Monday, March 31, 2003 7:44 PM To: [EMAIL PROTECTED] Subject: CPAN/Matt's??? Is anyone else seeing Matt's script archive when they try to go to CPAN? Scot R. inSite -- 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] -- [Writing CGI Applications with Perl - http://perlcgi-book.com] Jazz is not dead...it just smells funny. -- Beebop tango introduction -- Frank Zappa -- 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]
RE: Replacing/deleting text in a text file, part deux
Anything I can do to make this an easier question? No responses...maybe I didn't ask the question the right way or made it confusing as to what I am trying to do? Would it help to split it up? Thanks for any advice... Scot R. -Original Message- From: Scot Robnett [mailto:[EMAIL PROTECTED] Sent: Thursday, March 27, 2003 4:26 PM To: [EMAIL PROTECTED] Subject: Replacing/deleting text in a text file, part deux Looking at the code below, can anyone help me figure out how to compare the e-mail addresses in @addresses with the e-mail addresses in @emails and print out to the new file as shown, but minus the matching addresses? Scot R. inSite #!/usr/bin/perl -w use CGI; use CGI::Carp qw(fatalsToBrowser); $q = new CGI; $datafile = '/usr/apache/htdocs/path/to/.tracker'; $datafile2 = '/usr/apache/htdocs/path/to/.tracker2'; $company = $q-param('customercomp'); # scalar comes from form param @addresses = $q-param('customeremail'); # list comes from form param $/ = '*'; # split file records on '*' print $q-header; open(FILE,$datafile) or die Couldn\'t open data file.; @records = FILE; close(FILE); open(FILE2,$datafile2) or die Couldn\'t open data file 2.; foreach $record(sort(@records)) { chomp($record); ($comp,$addr) = split(/\|/, $record); @emails = split /:/, $addr; # Right here, I want to see if any of the addresses # in @addresses match an address in @emails for this # particular $record. # Now, if $comp eq $company, I want to print join ':' # the e-mail addresses MINUS any $address[$_] that # matched $emails[$_]. print FILE2 $comp\|; print FILE2 join(':', @emails); # minus any matching $address[$_] print FILE2 $/; } close(FILE2); -- 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]
RE: Replacing/deleting text in a text file, part deux
Ahhh, the famous 'map' function - haven't tried it, so I guess it's about time to give it a try. I wasn't too familiar with 'exists' either...thanks for the advice. - Scot Robnett -Original Message- From: Bob Showalter [mailto:[EMAIL PROTECTED] Sent: Friday, March 28, 2003 2:23 PM To: 'Scot Robnett'; [EMAIL PROTECTED] Subject: RE: Replacing/deleting text in a text file, part deux Scot Robnett wrote: Anything I can do to make this an easier question? No responses...maybe I didn't ask the question the right way or made it confusing as to what I am trying to do? Would it help to split it up? Thanks for any advice... ... foreach $record(sort(@records)) { chomp($record); ($comp,$addr) = split(/\|/, $record); @emails = split /:/, $addr; # Right here, I want to see if any of the addresses # in @addresses match an address in @emails for this # particular $record. Turn @addresses into a hash (do this ouside the loop of course): my %addresses = map ($_, 1), @addresses; Then, to remove entries in @emails that exist in @addresses: @emails = grep !exists($addresses{$_}), @emails; -- 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]
RE: Printing all values except. . .
This is untested my $query = new CGI; my %names = $query-Vars; foreach my $key(keys(%names)) { print $key\: $names{$key}\n if (($key eq 'name') or ($key eq 'email')); } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Replacing/deleting text in a text file, part deux
Looking at the code below, can anyone help me figure out how to compare the e-mail addresses in @addresses with the e-mail addresses in @emails and print out to the new file as shown, but minus the matching addresses? Scot R. inSite #!/usr/bin/perl -w use CGI; use CGI::Carp qw(fatalsToBrowser); $q = new CGI; $datafile = '/usr/apache/htdocs/path/to/.tracker'; $datafile2 = '/usr/apache/htdocs/path/to/.tracker2'; $company = $q-param('customercomp'); # scalar comes from form param @addresses = $q-param('customeremail'); # list comes from form param $/ = '*'; # split file records on '*' print $q-header; open(FILE,$datafile) or die Couldn\'t open data file.; @records = FILE; close(FILE); open(FILE2,$datafile2) or die Couldn\'t open data file 2.; foreach $record(sort(@records)) { chomp($record); ($comp,$addr) = split(/\|/, $record); @emails = split /:/, $addr; # Right here, I want to see if any of the addresses # in @addresses match an address in @emails for this # particular $record. # Now, if $comp eq $company, I want to print join ':' # the e-mail addresses MINUS any $address[$_] that # matched $emails[$_]. print FILE2 $comp\|; print FILE2 join(':', @emails); # minus any matching $address[$_] print FILE2 $/; } close(FILE2); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: MIME::Lite
404 file not found errors don't result from permission problems. The script apparently can't locate your file, but I can't tell from your description if you're getting the 404 in your browser or if the script is returning an error that tells you it can't find Lite.pm in INC. Can you be more specific? - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -Original Message- From: Horace Franklin Jr. [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 26, 2003 10:30 AM To: [EMAIL PROTECTED] Subject: MIME::Lite Clear DayHello, I use this line in my script: use MIME::Lite I received a file not found error. I have found a lite.PM file. When I upload this file what permission should I use? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Replacing/deleting line in a text file
Cool idea...thanks! - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -Original Message- From: Bob Showalter [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 26, 2003 1:38 PM To: 'Scot Robnett'; [EMAIL PROTECTED] Subject: RE: Replacing/deleting line in a text file Scot Robnett wrote: I have a delimited file that is formatted like this: Altech|[EMAIL PROTECTED]:[EMAIL PROTECTED] Specialties Steel Corp. |[EMAIL PROTECTED] Specialty Steel Corp. [EMAIL PROTECTED]|[EMAIL PROTECTED]:[EMAIL PROTECTED] burton.com* Starwood|[EMAIL PROTECTED] foods|[EMAIL PROTECTED]:[EMAIL PROTECTED] starwood|[EMAIL PROTECTED]:[EMAIL PROTECTED] Authentic Fitness Corp.|[EMAIL PROTECTED] Basically that's one continuous line; there are no line breaks. Don't ask me, I just inherited the file. The records are delimited by * and then each individual record is split as company/email by a pipe | character. If more than one person wants to track a particular company, their e-mail address is appended to the first with a colon and split on same for processing. Here's a simple example that splits each record out, removes an address, and spits the file back out #!/usr/bin/perl use strict; $/='*'; # input lines delimited by '*' while () { chomp; # strip the trailing '*' my ($comp, $addr) = split /\|/; my @addr = split /:/, $addr; # now you can adjust the @addr list to add or remove addresses # for example, remove addresses containing 'mrbill.com' @addr = grep !/mrbill\.com/, @addr; # put everything back together and print it out print join('|', $comp, join(':', @addr)), $/; } -- 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]
RE: Premature end of script headers
Kim, If you're trying to get the results to print in a browswer, you have to send the content type to the browser in the headers. Did you do either of these things prior to whatever routine prints your results? use CGI; $query = new CGI; print $query-header; or print Content-type: text/html\n\n; - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Premature end of script headers
Kim, It appears to be the header issue I mentioned before. Before print EndHTML; You should print the text/html header. print Content-type: text/html\n\n; print EndHTML; or use CGI; $q = new CGI; print $q-header; print EndHTML; # etc. - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Premature end of script headers
Yes, but it's not correct, there's your premature end of script header right there. You have: print Content-type:text/html\n\n; It should be: print Content-type: text/html\n\n; - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Good Perl cgi book?
These all helped me... - Learning Perl - Perl/CGI Cookbook - CGI Programming with Perl - Standard POD documentation - http://www.perldoc.com Scot Robnett inSite Internet Solutions -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Getting a STDOUT value
Wow! Quite a detailed response...thank you. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, March 07, 2003 9:25 AM To: Scot Robnett Cc: [EMAIL PROTECTED] Subject: RE: Getting a STDOUT value Remember to include the list in your replies, so that everyone can help and be helped. On Fri, 7 Mar 2003 08:52:04 -0600, Scot Robnett [EMAIL PROTECTED] wrote: Thanks - but I don't understand how that redirect works. I've read about open, select, and filehandles and I still don't get the STDERR or STDOUT redirect. Essentially the process being called needs to know how to handle this type of interaction so using regular opens/filehandles is not likely to work. However, since you are calling a process using backticks or you can use the IPC::Open3 mechanism then either in the former case the process will be the shell, which does understand how to do redirects, etc. or in the latter that is the very reason for Open3. I don't see any examples of working code with the 21 functionality and I don't know in what context that gets used. 21 are parameters that are parsed by the shell and instructs it how to handle the outputs of the process it is about to run. Because backticks gets its information from the shell, specifically STDOUT (of the shell) then if you tell the shell to redirect the stderr of the process into the stdout (which is what 21) does then the STDERR will show up on the STDOUT channel, which will be caught by the backticks. The only context where you need to watch out for this is when the process is *NOT* shelled out, which I believe only occurs in the multiple argument version of 'system' (please list correct me if I have this backwards). I am able to get the pid with IPC::Open2, but I want to display the results of the process, not the ID of the process. Sorry I should have been more specific on this, I believe Open2 will not accomplish what you need since it only works for STDOUT/STDIN. Open3 should be able to handle it however as it handles STDIN/STDOUT/STDERR. You will *NOT* want to use the 21 construct with an Open3!! Check the docs for info on getting the output, but essentially you call Open3 on the command giving it filehandles where it should send the output, then you should just read from those file handles like a normal 'open'd file handle. Here's what it looks like using a standard filehandle, but the results aren't being saved into my variable and therefore not displaying in the browser. What should this code look like with the missing link added? #!/usr/bin/perl -w use strict; use CGI::Carp qw(fatalsToBrowser); my $cmd = `perl -c myscript.cgi`; Change the above to: my @output = `perl -c myscript.cgi 21`; Then you will want to test $? for the return code, on a failed return code (likely anything but 0) then you will want to step through the @output array and print the stderr. Check in: perldoc perlop Under the section qx/STRING/ for examples and further description. open(STDERR,$cmd); # No idea how to redirect 21 here while($line = STDERR) { print $line; } close(STDERR); Here if my understanding is correct you are re-opening your own STDERR using the command's STDOUT (which doesn't have anything on it). Then reading your own STDERR and printing on own STDOUT. Which won't print anything because there is nothing on your own STDERR because there is nothing on the processes STDOUT... but then you really don't want to do things this way, at least outside of the context of an obfuscated Perl contest :-). HTH, http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Getting a STDOUT value
Does anyone know how I capture the value of an operation that defaults to STDOUT? For instance if I want to do something like #!/usr/bin/perl -w use strict; my $value = `perl -c someapp.cgi`; # prints to STDOUT print Content-type: text/html\n\n; print Result: $valueBR; This obviously won't work because 'perl -c' directs the output away from my variable and into STDOUT. I'm thinking I might be able to capture that return value using IO::Handle or something of that nature but I'm not sure how. Can anyone help? Scot R. inSite [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DBI question
I have a script which is supposed to e-mail a user their username/password info as long as their e-mail address is in the database. The following code works if the address is in the database (it prints the approval page and sends the mail with the correct information), but if the address is -not- in the database I get a 500 error. Error logs say premature end of script headers, and if I use the die statement and send fatalsToBrowser, I can see that it's dying at the 'next' statement. The question is why. I'm doing exactly the same thing in another script, and that one works. I also know that if I comment out the 'next' directive and evaluate the results of the SELECT statement, it is always selecting the e-mail address from the first table row and going no further. So if I chose the first e-mail address, it would go through, but any other entered addresses obviously don't match the address in the first row. Can anyone help me figure out what I'm doing wrong here? #!/usr/bin/perl use strict; use CGI qw(:all); use CGI::Carp qw(fatalsToBrowser); use DBI; require Mail::Send; my $q = new CGI; my $email = $q-param('forgotten_password_email'); my $dbh = DBI-connect(DBI:mysql:credmgr_usbz:localhost,credmgr,lyR1c978) or die Database error: $!; my $statement = END_OF_STATEMENT; SELECT EmailAddress,UserName,UserPass FROM UserData END_OF_STATEMENT my $sth = $dbh-prepare($statement) or die Could not prepare statement: $!; $sth-execute or die Could not execute statement: $!; my $useremail = ; my $username = ; my $userpass = ; while(($useremail,$username,$userpass) = $sth-fetchrow_array) { next unless($email eq $useremail) or die Couldn\'t \next\ here: $!; if($email eq $useremail) { print_header; print_approval; send_subscriber_mail; print_footer; exit; } else { print_header; print_denial; print_footer; exit; } } $dbh-disconnect; # These are the routines but I'll spare you # the huge HTML here docs # sub print_header # sub print_footer # sub print_approval # sub print_denial # sub send_subscriber_mail -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: lower casing email address
Myself, I'd go with $lowercase_email = lc($email); - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -Original Message- From: David Gilden [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 1:13 PM To: [EMAIL PROTECTED] Subject: lower casing email address Quick question here, which one is better for lowercasing an email address? ($email= param('email')) =~ tr/A-Z/a-z/; ($email= param('email')) =~ s/(.+)/\L$1/g; Thanks! Dave Now taking the CGI course @ http://users.easystreet.com/ovid/cgi_course/ -- 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]
RE: NULL insertion
This assumes MySQL is your DB. I know there are other people on this list that can offer more efficient solutions or pick this one apart...so feel free. :) *** #!/usr/bin/perl use strict; use CGI qw(:all); use CGI::Carp qw(fatalsToBrowser); use DBI; my $q = new CGI; # new CGI object my %formdata = $q-Vars; # NV pairs, use caution though because # items with multiple values will have # be called with references. # Let's assume that %formdata looks like this: # %formdata = (name = Joe, #phone = 888-555-1212, #fax = 888-555-1313); # Connect to the database. my $value = ; # Have to declare variables if we use strict. my $dbh = DBI-connect(DBI:mysql:database_name:localhost,username,password) or die I could not connect to the database: $!; # Prepare the SQL statement(s) for execution, then execute them. foreach my $key(%formdata) { $value = $formdata{$key}; my $sth = $dbh-prepare(qq|INSERT INTO contactData(Firstname,PhoneNo,FaxNo) VALUES ($value,NULL,NULL)|) if($key eq name); my $sth = $dbh-prepare(qq|INSERT INTO contactData(Firstname,PhoneNo,FaxNo) VALUES (NULL,$value,NULL)|) if($key eq phone); my $sth = $dbh-prepare(qq|INSERT INTO contactData(Firstname,PhoneNo,FaxNo) VALUES (NULL,NULL,$value)|) if($key eq fax); $sth-execute; } # Commit the changes. $dbh-commit; # Disconnect from the database. $dbh-disconnect; 1; - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -Original Message- From: T. Murlidharan Nair [mailto:[EMAIL PROTECTED] Sent: Monday, February 24, 2003 4:55 PM To: [EMAIL PROTECTED] Subject: NULL insertion Hi!! I need to insert NULL into the database using a perl CGI . So if a variable is to be made NULL in perl and it needs to be used in an sql statement what is best way to do it. Do I assign ' \N' to it or 'NULL' ? Thanks and Cheers always!! Murli -- 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]
RE: ISP won't install Perl modules
Rene, If it is a pure perl module (I believe Email::Valid is), you can put it in one of your directories and push/unshift it into @INC. In some cases you may have to do that push or unshift inside a BEGIN so that the interpreter sees that action before reading @INC. Another option is to find a web host that willingly installs modules for you. I'm working with one now that is great about this. If you'd like more info, e-mail me offline from the list. Thanks! - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -Original Message- From: Rene Verharen [mailto:[EMAIL PROTECTED]] Sent: Friday, January 17, 2003 8:19 AM To: Beginners-CGI List Subject: ISP won't install Perl modules Hi all, My ISP won't install some Perl modules I want to use (Email::Valid and Mail::Address). Is there a way to install these modules in some directory I have access to so I'll be able to use them ? Kind regards, Rene Verharen Please DO NOT reply to me personally. I'll get my copy from the list. -- 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]
RE: Confusion on @array vs $array[] vs $array
I don't know that I'd agree with the assessment @ = ordered list % = unordered list That's a bit confusing. It's true that a hash (or associative array) uses its own sort order unless you use the 'sort' option. But an array is a simple list of elements, whereas a hash is an associative array, meaning each element (value) is associated with a unique key. @list = ('one','two','three','four'); # scalar $list[1] gives you two #key#value %list = ('key0' = 'one', 'key1' = 'two', 'key2' = 'three', 'key3' = 'four'); # $list{'key2'} gives you three # You can't have another key2 key, # but the same -value- can be # associated with multiple keys if # desired. - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 18, 2002 1:36 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: Confusion on @array vs $array[] vs $array In a message dated 12/18/2002 12:13:38 PM Eastern Standard Time, [EMAIL PROTECTED] writes: Anyway, perhaps one of you syntactical thought police could give me some insights to the rational. I find it very confusing that the $ and @ characters are supposed to be used interchangeably to denote arrays, particularyly when I'm trying to fathom the relation to other issues such as scalar or list context. As I recall, hashes arso use % and @ interchangeably. This about it like this: The $ refers to a single piece of information. The @ refers to a list. The % refers to an unordered list. So, if you want to referrer to a specific part of an array, or hash, you have to use a $, or scalar. So if your array is @array = qw(something something2 something3) Then $array[0] is a scalar value of the first element of the ordered list, something. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: html redirect using CGI.pm
You might want to just use redirect(), check perldoc CGI - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -Original Message- From: Admin-Stress [mailto:[EMAIL PROTECTED]] Sent: Monday, December 09, 2002 2:42 PM To: perl cgi Subject: html redirect using CGI.pm Hi, Could someone check my code below? I need to redirect to a html using CGI.pm perl module. But when I executed, I got blank page. If I commented out $cgi-start_html ... it's working fine, but no redirection. $cgi = new CGI; sub Error { my ($msg) = @_; print BRBRBRBRBRBRBRBRBRBR; print TABLE border='0' width=500 align=center bgcolor=#C7D7F3; print TRTH align=center bgcolor=#FFfont color=#FF Error /font; print TRTHnbsp; print TRTH align=center$msg; print TRTHnbsp; } $upassword = $cgi-param('password'); if ($password ne $upassword) { print $cgi-header; print $cgi-start_html(-head=meta({-http_equiv = 'Refresh', -content = '5', -url = 'http://mydomain.homelinux.net/login.html'})); Error Wrong password.; exit(0); } __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- 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]
RE: html redirect using CGI.pm
First thing, if you are generating a redirect, then you can print the content-type header within the same space using an array ref like below. Your method looks like it should work, although I think you might want to put the time and the URL within the content space. With my host I'm getting an error saying that main::meta is undefined, so I'm not sure if we're running an older version of CGI.pm or missing supporting files. According to the CGI.pm documentation you should be able to do something like this though. print start_html(-head=[ meta({-http_equiv = 'Content-Type', -content= 'text/html'}), meta({-http_equiv = 'refresh', -content= '5;URL=http://mydomain.homelinux.net/login.html'}) ]), p('Redirecting to login page'), end_html; - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -Original Message- From: Admin-Stress [mailto:[EMAIL PROTECTED]] Sent: Monday, December 09, 2002 3:45 PM To: perl cgi Subject: RE: html redirect using CGI.pm print $query-redirect(-uri='http://somewhere.else/in/movie/land', -nph=1); I found the example, but I dont know how to put the 'seconds', like will be redirected after 5 seconds. --- Scot Robnett [EMAIL PROTECTED] wrote: You might want to just use redirect(), check perldoc CGI - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -Original Message- From: Admin-Stress [mailto:[EMAIL PROTECTED]] Sent: Monday, December 09, 2002 2:42 PM To: perl cgi Subject: html redirect using CGI.pm Hi, Could someone check my code below? I need to redirect to a html using CGI.pm perl module. But when I executed, I got blank page. If I commented out $cgi-start_html ... it's working fine, but no redirection. $cgi = new CGI; sub Error { my ($msg) = @_; print BRBRBRBRBRBRBRBRBRBR; print TABLE border='0' width=500 align=center bgcolor=#C7D7F3; print TRTH align=center bgcolor=#FFfont color=#FF Error /font; print TRTHnbsp; print TRTH align=center$msg; print TRTHnbsp; } $upassword = $cgi-param('password'); if ($password ne $upassword) { print $cgi-header; print $cgi-start_html(-head=meta({-http_equiv = 'Refresh', -content = '5', -url = 'http://mydomain.homelinux.net/login.html'})); Error Wrong password.; exit(0); } __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- 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] __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- 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]
Upload (probably a stupid question)
How do I make my script only send the filename rather than the full path when I use the CGI.pm upload function? For example, when I upload the document test.xls On the remote server, it's being named with the full path of where I sent it from, like this C:\Documents and Settings\SRobnet\Desktop\test.xls How can I get it to just leave the filename as test.xls on the remote server without appending my entire local path to it? - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Was: 5.005_03 vs. 5.8, should be pure perl
If I don't have to be root or do a make install, why am I not able to get modules like Expat to install successfully, and why does their documentation tell me that's what I have to do? It seems like if there's another option, the pod docs or readme should tell me so. If there's another alternative it would be great to know what it was; can you please post a link to any help docs? Thanks. Scot R. inSite -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 04, 2002 11:55 AM To: Scot Robnett; Octavian Rasnita Cc: [EMAIL PROTECTED] Subject: RE: 5.005_03 vs. 5.8 On Wed, 4 Dec 2002 11:03:37 -0600, Scot Robnett [EMAIL PROTECTED] wrote: snip Modules that are not pure perl have some sort of compiled supporting file associated with them True. and must be installed by root using a 'make install'. False, at least in most cases, though there may need to be other steps taken, like updating LD_LIBRARY_PATH, etc. http://danconia.org -- 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]
RE: 5.005_03 vs. 5.8
Thanks to all for your input on this. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: 5.005_03 vs. 5.8
Thanks again everyone. Based on your input, reading the docs, and doing some evaluation of our own needs, we decided on Red Hat 8.0, which comes with Perl 5.8.0, Apache 2.0, and with the mod_perl package. It all goes on a Dell PowerEdge 2600 144 GB (108 usable) RAID 5 with a 512 MB Xeon. Sweeet. New toys! As they might say in California, like, I'm so stoked! Scot R. inSite -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Creating and Using Libraries
#1.) I guess the answer to question one is simply to create a directory somewhere within my user access/document tree, and then give it the proper access permissions. I prefer to put them in a directory that is not in the HTML document tree if at all possible. Some hosts make this easy and others don't. For instance, many Linux hosts will give you /path/to/account/ as the base and /path/to/account/www/ as the default root directory of your web site. If it's a possibility, I keep the modules above the /www/ directory, especially if they contain references to config files that may contain compromising information in unencrypted ascii. I don't know if this is the standard or even preferred approach, so more feedback from this list would be great. #2.) Then to list the path to the library in the module calls, like this: use lib '/user/public_html/cgi-bin/library'; In some cases I have to use BEGIN { unshift(@INC, path); } because by the time 'use lib' is evaluated, @INC has already been evaluated and the extra module directory isn't found, causing the script to break. Here's an example, if your user module directory is located in /user/home/will/bin/ and you have Template.pm in /user/home/will/bin/HTML/Template.pm and you have DBLogin.pm in /user/home/will/bin/DBLogin.pm snip #!/usr/bin/perl BEGIN { unshift(@INC, '/user/home/will/bin'); } use HTML::Template; use DBLogin; /snip #3.) The third thing is that I am still unclear on how to put CPAN modules into the library. On Windows with ActivePerl, use ppm. On UNIX, use CPAN.pm. If you prefer to just gunzip or untar them, I suppose it doesn't matter much which machine you do it on as long as the files end up in the right places. IMHO you are less likely to get that screwed up if you expand the files on the machine that will be housing them. Scot R. inSite -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
5.005_03 vs. 5.8
I am working with a university on a web project which entails setting up a new server. We're going with Red Hat Linux on Dell hardware (RAID 5 configuration), but I am not sure which version of Perl to recommend. I am very used to 5.005_03, but 5.8 is the current release. Do I have a large learning curve associated with going the 5.8 route as opposed to 5.005_03? If I want to port scripts, will they need to be rewritten? Are there significant benefits to using 5.8? On one hand, I want to keep up with the Joneses and take advantage of the most available power, but on the other hand, I'm used to one flavor and you know what they say about fixing things that ain't broke. Opinions, comments, suggestions? - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: tutorials
Always look to O'Reilly first, they usually have something not only relevant to your request, but well-written and comprehensive as well. Try CGI Programming with Perl. It's the one with the mouse on the cover. I don't have this one, but I hear The Perl Cookbook is supposed to be good also. - Scot Robnett inSite Internet Solutions Square West Center 454 West Jackson Street Woodstock, IL 60098 (815)206-2907 office (815)790-9687 mobile [EMAIL PROTECTED] http://www.insiteful.tv -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Saturday, November 23, 2002 4:26 PM To: [EMAIL PROTECTED] Subject: tutorials does anybody have any really good sites or books that deal just with CGI as in applications to web programming. Almost all i have found in the book area is how to code perl in the command line interface. I looking for just web based stuff. Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Unable to run cgi script
I don't think that's it; with the ScriptAlias set it should call the script through a relative or full path as easily as it does via that full HTTP call. I'm curious what the document root is...if it is /home/kelvin, then technically you *should* just be able to write it as form action=/cgi-bin/myscript.cgi. Or, if you want to try the HTTP call, form action=http://localhost/cgi-bin/myscript.cgi;. It sounds to me like .cgi or .pl may already have file associations with an external application (since the scripts are opening in your editor), and for some reason those are overriding your AddHandler directive in Apache. Did you try troubleshooting it by using an either/or approach? By this I mean simply adding a handler for either .cgi or .pl but not both, and trying it that way. What are the results you get when you run the script via the command line or run a perl -c on it? Another quick question: I noticed that you called the configuration file httpd.config. Since its actual name is httpd.conf, I wonder if it's as simple as renaming your configuration file? If you already have it named httpd.conf, then never mind this question. :) - Scot Robnett inSite Internet Solutions Square West Center 454 West Jackson Street Woodstock, IL 60098 (815)206-2907 office (815)342-6480 mobile [EMAIL PROTECTED] http://www.insiteful.tv -Original Message- From: David T-G [mailto:davidtg-perl-beginners;justpickone.org] Sent: Monday, November 11, 2002 7:58 AM To: perl beginners cgi Cc: Kelvin McWha Subject: Re: Unable to run cgi script Kelvin -- and then Kelvin McWha said... % % form method=post action=/home/kelvin/cgi-bin/myscript.cgi I *think* you have to qualify this, as action=http://localhost/home/kelvin/cgi-bin/myscript.cgi; Certainly worth a try... HTH HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, Science and Health http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Form-mail blues
You should really separate the header printing process from the HTML printing process. The first thing you want to do is tell the browser that HTML is coming, -then- write the HTML. A couple different ways of accomplishing this: use CGI; $q = new CGI; print $q-header; or print Content-type: text/html\n\n; The first option is the preferred method, as you can easily add more arguments to the header block. Do a 'perldoc CGI' for the documentation. If you decide to use the second method because it seems easier to you for one reason or another, make sure that you get the case, punctuation, and spacing correct. - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -Original Message- From: Ramon Hildreth [mailto:ramon;ramonred.net] Sent: Saturday, November 02, 2002 2:49 PM To: [EMAIL PROTECTED] Subject: Form-mail blues Hi, I don't have access to the error logs on my hosting account, and I am trying to troubleshoot formail script. It runs okay from the commandline. It also sends the info collected in the form correctly to the email address I have specified. It also gives internal server error. I am guessing that this part of the script is making the trouble, but I don't know what it could be. - Use CGI qw(:standard); -- #show thank you screen print header EOF; HTML HEAD TITLEThank You/TITLE /HEAD BODY H1Thank You for your submission/H1 preturn to a href=http://www.subudusa.org/concept.html;Subud Enterprises Services/a./p /BODY /HTML EOF --- TIA. Ramon Hildreth --- [ www.subudusa.org ] [www.subudseattle.org [ www.ramonred.net ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Using MySQL
I use MySQL on both Win2K and FreeBSD. The module you want is DBI, and you can get all the information you need about DBD and DBI in DBI::FAQ. That's available here: http://search.cpan.org/author/TIMB/DBI-1.30/lib/DBI/FAQ.pm The MySQL documentation on their site is comprehensive and will tell you a lot about what you need to know. http://www.mysql.com/documentation/mysql/bychapter/ To learn the SQL/MySQL ropes, I'd say the first stop I'd make is at your local bookstore (or one of the discount bookstores online) to pick up MySQL (Other New Riders) and MySQL and Perl for the Web by Paul DuBois, and the O'Reilly book Programming the Perl DBI is always a good reference point. - Scot Robnett inSite Internet Solutions Square West Center 454 West Jackson Street Woodstock, IL 60098 (815)206-2907 office (815)342-6480 mobile [EMAIL PROTECTED] http://www.insiteful.tv -Original Message- From: Octavian Rasnita [mailto:[EMAIL PROTECTED]] Sent: Monday, October 14, 2002 11:27 PM To: [EMAIL PROTECTED] Subject: Using MySQL Hi all, I want to start learning MySQL. I've downloaded MySQL for Windows, because I will use it under Win 2k. Can you tell me what else do I need to use MySQL databases? What DBI, DBM, DBD, etc modules I need to be able to use it? With MySQL I am at the level 0 for the moment, I don't know anything. Thank you very much for your hints. Teddy's Center for the blind: http://teddy.fcc.ro/ Email: [EMAIL PROTECTED] -- 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]
RE: pop-up window with database access
Avoid Javascript is a pretty far-reaching statement. If you want to launch a popup window, Perl isn't going to do that, Javascript is. It only takes one or two lines of client-side code. There are easy-to-follow Javascript primers at http://javascript.internet.com and http://www.htmlgoodies.com/primers/jsp/jsp_toc.html With regard to the database functionality, Perl and MySQL are powerful tools if you have the time and inclination to learn them. Good reading: 'Learning Perl', 'Perl in a Nutshell', 'CGI Programming with Perl' and 'Programming the Perl DBI' (all O'Reilly books). There is also an O'Reilly MySQL book but I forget the name of it. Actually the documentation that comes with the MySQL distribution is quite good. http://www.mysql.com/doc/en/index.html I also like the SAMS series of SQL books ('Teach Yourself SQL in ...'). This is really a time and learning curve issue. If you don't have much time, maybe an off-the-shelf CGI is the answer. But I think you'll probably get more benefit in the long run if you go through the steps of building it yourself. HTH, Scot R. inSite -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of zentara Sent: Monday, September 30, 2002 10:02 AM To: [EMAIL PROTECTED] Subject: Re: pop-up window with database access On Fri, 27 Sep 2002 14:43:50 -0400, [EMAIL PROTECTED] (Jim Lundeen) wrote: Hello, I'm creating a web site for our department at my school. We have a sign-up form for a society that people can join. I want to create a MySQL database of university names and allow the user to click on a Lookup button on the sign-up form when they get to the field University Affiliation and the pop-up window would then go out and get a list of universities in the database and allow them to select the university they are with, then the selected value would be put in the correct text box on the main page form. I would guess that JavaScript is involved, but I don't know. Any help (detailed help!) would be very much appreciated by many students and professors from around the world! If you have limited perl knowledge, it will take you some time to develope this yourself, maybe a month? You might be better off buying an existing package which does this.for instance http://www.gossamer-threads.com/scripts/dbman/index.htm P.S. Avoid javascript. It will cause you headaches. :-) -- 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]
RE: pop-up window with database access
Define a lot of people. I use Pop-Up Stopper myself, but when there is a popup window that I *want* to see, I can CTRL-click the link. I don't have to turn Javascript off. Most browsers are preconfigured to allow Javascript and the user or the company has to explicitly turn it off. I agree that it's probably going to cover more ground if he keeps the user experience within the main browser window. 95% of the clients I deal with still have Javascript enabled. But 100% of them can see what's going on in their browser, so you have a point. I guess it depends how important the pop-up function is to the project. Perl and MySQL are quite capable of handling the back end, but they're not going to manage this function. Scot R. inSite -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of zentara Sent: Monday, September 30, 2002 11:30 AM To: [EMAIL PROTECTED] Subject: Re: pop-up window with database access On Mon, 30 Sep 2002 10:28:51 -0500, [EMAIL PROTECTED] (Scot Robnett) wrote: Avoid Javascript is a pretty far-reaching statement. If you want to launch a popup window, Perl isn't going to do that, Javascript is. It only takes one or two lines of client-side code. There are easy-to-follow Javascript Yeah, you are right. But alot of people keep javascript disabled, so if you design your site expecting people to use it, you will be dissapointed. I've turned off pop-up javascript windows in my mozilla preferences because there are so many annoying pop-ads now. -- 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]
RE: Hotmail.com vs. MIME:Lite
It sounds like you solved the problem already by sending text/plain messages to Hotmail accounts. For some reason I've never had an issue with that, though - maybe it's because I don't actually attach the image that is placed inline; I import it from a location on my website. You could also try forcing base64 or quoted-printable encoding. For example: #!/usr/bin/perl -w use strict; use MIME::Lite; my $msg = MIME::Lite-new( From ='[EMAIL PROTECTED]', To ='[EMAIL PROTECTED]', Subject ='Hello again', Type ='multipart/related', Encoding ='base64' # or #Encoding ='quoted-printable' ); $msg-attach(Type = 'text/html', Data = qq{ BODY BGCOLOR=#FF H2This is a header./H2 PThis is another test./P BR IMG SRC=http://path/to/the/image.gif; # not attached /BODY }# but imported ); # from website $msg-send(); # - # Scot R. # inSite # P.S. You're going to try to wrestle Microsoft? # (they own Hotmail) # See where it got the Justice Department? grin -Original Message- From: Sven Bentlage [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 18, 2002 5:02 AM To: [EMAIL PROTECTED] Subject: Hotmail.com vs. MIME:Lite Hi everyone, (thanks for your tips, Scot). I managed to get my script working. It sends a HTML mail via MIME::Lite, with a.txt attachment. All mail clients I tested worked just fine. The only problem is Hotmail.com!! Hotmail.com neither displays the HTML mail, nor am I able to download the txt attachment. Hotmail.com tells me, there is a virus in the txt attachment.. ??? Hotmail.com does display plain text messages. I got no idea what to do or how to solve it. (RIght now I`m using a little sub checking whether it's a hotmail address and sending only plain text to hotmail, while sending html to all others) Does anyone have an idea how to solve that problem? Thanks for your help, Sven On Montag, September 16, 2002, at 06:48 Uhr, Scot Robnett wrote: Yes, you can send text attachments. It's all documented at the link I included in the last message... Scot R. -Original Message- From: Sven Bentlage [mailto:[EMAIL PROTECTED]] Sent: Sunday, September 15, 2002 7:42 AM To: [EMAIL PROTECTED] Subject: SMTP/HTML/TEXT Hi everyone, I encountered another problem with my mailscript. Hotmail.com users and some people who use strange mail clients don't get anything displayed at all. is there anyway to send a html mail via MIME::Lite with an attached text part of it? Thanks for your help. Sven On Donnerstag, September 12, 2002, at 01:46 Uhr, Scot Robnett wrote: #!/usr/bin/perl -w # Link for Sven: # http://search.cpan.org/author/ERYQ/MIME-Lite-2.117/lib/MIME/Lite.pm # Send HTML document with inline images # MIME::Lite a purely perly sorta thing, so # if it's not installed in @INC we can put # it there without problems BEGIN { unshift(@INC,/path/to/our/own/modules); } use strict; use MIME::Lite; # Create a new MIME Lite object my $msg = MIME::Lite-new( From='[EMAIL PROTECTED]', To ='[EMAIL PROTECTED]', Subject ='Hi', Type='multipart/related'); # Add the body to your HTML message $msg-attach(Type = 'text/html', Data = qq{ BODY BGCOLOR=#FF H2Hi/H2 P ALIGN=left This is an HTML message. /P P ALIGN=left A HREF=http://foo123.com/;Here's a link/A. /P P ALIGN=middle IMG SRC=cid:img.jpg; /P /BODY }); # Attach the image $msg-attach(Type = 'image/gif', Id = 'img.gif', Path = '/path/to/img.gif'); # Send it $msg-send(); - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] http://www.insiteful.tv -- 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: :SMTP / HTML
#!/usr/bin/perl -w # Link for Sven: # http://search.cpan.org/author/ERYQ/MIME-Lite-2.117/lib/MIME/Lite.pm # Send HTML document with inline images # MIME::Lite a purely perly sorta thing, so # if it's not installed in @INC we can put # it there without problems BEGIN { unshift(@INC,/path/to/our/own/modules); } use strict; use MIME::Lite; # Create a new MIME Lite object my $msg = MIME::Lite-new( From='[EMAIL PROTECTED]', To ='[EMAIL PROTECTED]', Subject ='Hi', Type='multipart/related'); # Add the body to your HTML message $msg-attach(Type = 'text/html', Data = qq{ BODY BGCOLOR=#FF H2Hi/H2 P ALIGN=left This is an HTML message. /P P ALIGN=left A HREF=http://foo123.com/;Here's a link/A. /P P ALIGN=middle IMG SRC=cid:img.jpg; /P /BODY }); # Attach the image $msg-attach(Type = 'image/gif', Id = 'img.gif', Path = '/path/to/img.gif'); # Send it $msg-send(); - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] http://www.insiteful.tv -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ending a script
If you are on a UNIX system, often you can run the script suid, so that it is running as an authenticated user rather than nobody or httpd. In most cases, it's a simple matter of: Step 1: chmod 4711 scriptname.cgi Step 2: Change the shebang line to #!/usr/bin/perl -U However, this will only work if the web server is configured to support running scripts suid. That's probably the most effective way to do it. You can try authenticating based on an IP address or domain, but those environment variables can be spoofed. You can still add this checking to keep unsophisticated hackers from bothering you; just know that it isn't foolproof. my $good_referer = 'my.domain.com/form.html'; my $good_address = '??.??.???.???'; # your IP my $real_referer = $ENV{'HTTP_REFERER'}; my $real_address = $ENV{'REMOTE_ADDR'}; if($real_referer ne $good_referer) or ($real_address ne $good_address) { # boot 'em } else { # do your thing } - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] http://www.insiteful.tv -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: real beginners stuff
Try printing the content type before your HERE doc, not within it. Scot R. inSite -Original Message- From: Jimmy George [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 13, 2002 2:03 AM To: cgi Subject: real beginners stuff Hello World If I logon to the web via (say) server_a and then start this script in server_b which has the code in its cgi-bin folder #! /usr/bin/perl -w # use CGI qw(:standard); #use strict; # print END_of_file; Content-type: text/html html headtitleServer Environment/title/head body h2This server is:/h2brbr Server Name:$ENV{SERVER_NAME} Port Number:$ENV{SERVER_PORT} Server Software:$ENV{SERVER_SOFTWARE} /body/html END_of_file should I get to see the %ENV details of server_a? I am getting a 500 error. Permissions are set to 711 for the script and 701 for the folder. cheers Jimmy George -- 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]
RE: How to find the remote time?
You can use Javascript to pull the time off their system clock, assuming their clock is set correctly. Server-side, you can use an ARIN search on their IP to get their location, but in that case you're relying on the IP not being spoofed and/or all of the lookups actually working, which is not a real world scenario. Scot R. inSite -Original Message- From: John Pitchko [mailto:[EMAIL PROTECTED]] Sent: Monday, August 12, 2002 8:32 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: How to find the remote time? Uh probably not with CGI because that is all executed server side, so I don't think you can access anything on the individual clients unless they expressly submit data to the server. Maybe try some JavaScript? John Pitchko Data Services Saskatchewan Government Insurance Octavian Rasnita [EMAIL PROTECTED] 08/11/02 08:29am Hi all, How can I find the local time of the web page visitors? Using localtime function shows me the localtime from the location where is the server. I couldn't find any environment variable for this either. Thank you for any hint. Teddy's Center: http://teddy.fcc.ro/ Mail: [EMAIL PROTECTED] -- 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]
RE: Creating a shopping cart
Your APIs are going to vary depending on the gateway. I would suggest looking at the Perl API documentation for Verisign/Cybercash (http://www.verisign.com/support/cyberCash/supportDocs.html), Authorize.net (https://www.authorize.net/docs/developersguide.pml), or you could even use PayPal.com if you're looking for a quick and easy approach (https://www.paypal.com/html/shopping_cart.pdf). PayPal is remotely hosted only, there is no API...you use their site to generate tags, then copy them and plug them into your HTML pages. It is the gateway that will do the actual authorization and transaction processing for you - this is the communication point, or middle tier, between your shopping cart and the credit card company. If you are looking for a simple validation operation that shows you whether or not it is a legitimate card number (but does not approve or decline a transaction), you can try the Business::CreditCard module. In order to do any of this (with the exception of PayPal), you or your client need to have a merchant account. The merchant will tell you which gateways they support. For example, www.charge.com is a popular one. There are hundreds of others. As far as shopping carts go, probably the best place to start would be to find a Perl shopping cart that has functionality similar to what you'd like to build, spend some time studying it, and break down what makes things tick. Maybe you'll find one that works for you, or maybe you'll build a better one. In most cases, I've found that my clients invariably need some customization that isn't available in a canned shopping cart script. Authorize.net has a huge list of Authorize.net-compatible shopping carts here: http://www.authorizenet.com/alliances/carts_list.php - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] http://www.insiteful.tv -Original Message- From: Octavian Rasnita [mailto:[EMAIL PROTECTED]] Sent: Monday, August 12, 2002 6:31 AM To: [EMAIL PROTECTED] Subject: Creating a shopping cart Hi all, I have a question, not about Perl, but about CGI. Can you give me some hints where should I go to learn how to create a shopping cart? I don't think I have a problem with the Perl code, but I don't know how to validate a credit card, how do the transactions work, etc, to be able to write a code for that. Are there any books or online tutorials, free shopping carts, etc? Thank you. Teddy, Mail: [EMAIL PROTECTED] -- 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]
RE: Finding the country
I'm assuming your best bet would be to find the IP using the first line of a ping or traceroute and regex-ing out the extraneous stuff, then using 'whois -a' (which does an ARIN search) and extracting the 4th line to get the country. Anybody have any easier/faster ideas? Scot R. inSite -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Running CGIs offline
Although these are good suggestions, I think they miss the original intention. We were looking for something that we could distribute on CD and have it run, regardless of whether the user had Perl or a web server installed on their workstation. And then Bob Showalter said: -Original Message- From: Bob Showalter Sent: Monday, July 22, 2002 1:13 PM Subject: RE: Running CGIs offline HTTP::Daemon, part of Bundle::libwww Scot R. inSite -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 23, 2002 4:36 AM To: [EMAIL PROTECTED] Subject: RE: Running CGIs offline Not sure what you're after, but to run CGI's offline, you can just: 1) Install a Perl distribution (Indigo Perl or Active Perl are simple) 2) Whack Apache on your box (comes as binary for most OS's) - I found the Bindows version simple to install and run. - Just tell it where your perl install is, etc. It was all so simple I can't really remember exactly and away you go: 'http://localhost/cgi-bin/script.pl' Never look back. Obviously there are still a few differences between running locally and on a live webserver, but it's a step closer... HTH someone, TommyGun. -Original Message- From : Scot Robnett [EMAIL PROTECTED] To : David T-G [EMAIL PROTECTED]; perl beginners cgi [EMAIL PROTECTED] CC : Bob Showalter [EMAIL PROTECTED]Date : 22 July 2002 19:48:17 Subject : RE: Running CGIs offline Just a note to throw in my own WOOOH :) Gotta try it. Scot R. inSite -Original Message- From: David T-G [mailto:[EMAIL PROTECTED]] Sent: Monday, July 22, 2002 1:22 PM To: perl beginners cgi Cc: Bob Showalter Subject: Re: Running CGIs offline Bob, et al -- and then Bob Showalter said... % % -Original Message- % From: David T-G [mailto:[EMAIL PROTECTED]] % You know, it never hurts to check CPAN; maybe someone has % already written % a little web server in perl :-) % % HTTP::Daemon, part of Bundle::libwww Way cool. Awesome. I should have looked myself :-) but it only occurred to me as I was answering him. Can't wait to install this sucker; this'll be good. Thanks! HAND :-D -- David T-G * It's easier to fight for one's principles (play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie (work) [EMAIL PROTECTED] http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Personalised email by http://another.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Running CGIs offline
I have been interested in this sort of thing for awhile also. Looking forward to any helpful info! Scot R. inSite -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Monday, July 22, 2002 12:06 PM To: [EMAIL PROTECTED] Subject: Running CGIs offline I'm interested in taking a website, composed of HTML and perl cgis and moving it offline. I want to burn it to a CD that will run on Mac and PC, Explorer and Navigator. Are there tools to do this sort of thing? A browser-based perl interpreter? A CGI faker? Thank you for whatever you say! -- 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]
RE: Running CGIs offline
Just a note to throw in my own WOOOH :) Gotta try it. Scot R. inSite -Original Message- From: David T-G [mailto:[EMAIL PROTECTED]] Sent: Monday, July 22, 2002 1:22 PM To: perl beginners cgi Cc: Bob Showalter Subject: Re: Running CGIs offline Bob, et al -- and then Bob Showalter said... % % -Original Message- % From: David T-G [mailto:[EMAIL PROTECTED]] % You know, it never hurts to check CPAN; maybe someone has % already written % a little web server in perl :-) % % HTTP::Daemon, part of Bundle::libwww Way cool. Awesome. I should have looked myself :-) but it only occurred to me as I was answering him. Can't wait to install this sucker; this'll be good. Thanks! HAND :-D -- David T-G * It's easier to fight for one's principles (play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie (work) [EMAIL PROTECTED] http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: redirect()
A common mistake is to print a header and then do a redirect, which slows the process down because essentially you have a script and a page competing to generate a header. When using redirect(), do not do this: #!/usr/bin/perl use CGI; my $q = new CGI; print $q-header(); # don't need this if redirecting! print $q-redirect('http://www.whatever.com'); Do this instead: #!/usr/bin/perl use CGI; my $q = new CGI; print $q-redirect('http://www.whatever.com'); Or another option: #!/usr/bin/perl my $url = 'http://whatever.com'; print Location: $url\n\n; HTH, Scot R. inSite -Original Message- From: Jonathan [mailto:[EMAIL PROTECTED]] Sent: Sunday, July 14, 2002 7:35 AM To: [EMAIL PROTECTED] Subject: redirect() After complaints that my CGI takes too long, I traced it down to the redirect() function. Why does it take so long? Is there an alternative? Jonathan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: redirect()
Do you think the clients browser goes and Posts the form again to the new URL? No, I don't think that is what's happening. Once you post the info, the script is processing it and doing the redirect, but I don't think it is posting the entire string of nv pairs again. If this is what is happening, is the solution to use: print Location: $url\n\n; I don't really know that it is 'the' solution, but I think it accomplishes what you want. Whether or not it's any faster, you would just have to test it and see. Will this work for all browsers? I believe so, but I defer the official answer to that question to people on the list who are better qualified than I to answer it. Thanks Jonathan A common mistake is to print a header and then do a redirect, which slows the process down because essentially you have a script and a page competing to generate a header. When using redirect(), do not do this: #!/usr/bin/perl use CGI; my $q = new CGI; print $q-header(); # don't need this if redirecting! print $q-redirect('http://www.whatever.com'); Do this instead: #!/usr/bin/perl use CGI; my $q = new CGI; print $q-redirect('http://www.whatever.com'); Or another option: #!/usr/bin/perl my $url = 'http://whatever.com'; print Location: $url\n\n; HTH, Scot R. inSite ___ After complaints that my CGI takes too long, I traced it down to the redirect() function. Why does it take so long? Is there an alternative? Jonathan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Username Password Question
I might have suggested doing authentication a little bit differently, as it appears that you are using a plain text file with unencrypted username/password data. But if you just want to redirect based on what you've got and you're not extremely concerned about security in this instance, this should work. #!/usr/bin/perl use CGI qw/:standard/; my $q = new CGI; my $username = param(USERNAME); my $password = param(PASSWORD); open(FILE, data.txt) || die The database could not be opened; while(FILE) { @data = split(/\n/); foreach $entry (@data) { ($name, $pass) = split(/,/, $entry); if($name eq $username) { $userverified = 1; if ($pass eq $password) { $passwordverified = 1; } } } } close(FILE); if ($userverified $passwordverified) { accessgranted; } elsif ($userverified !$passwordverified) { wrongpassword; } else { accessdenied; } sub accessgranted { $q-redirect('http://www.whatever.com'); } sub wrongpassword { print header; print TITLEAccess Denied/TITLE; print FONT FACE=Arial SIZE=2 COLOR=RedSTRONG; print You entered an invalid password.br ; print Access has been denied./STRONG/FONT; exit; } sub accessdenied { print header; print TITLEAccess Denied/TITLE; print FONT FACE=Arial SIZE=3 COLOR=RedSTRONG; print You were denied access to this server.; print /STRONG/FONT; exit; } # Scot R. # inSite --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Disabling file uploads?
Thank you. I've seen that buffer overflow term on many lists, and I know it is something bad, but I don't know what it is unfortunately. Cheers. Octavian, maybe these definitions will help. # buffer -- N: A region of memory reserved for use as an intermediate repository in which data is temporarily held while waiting to be transferred between two locations, as between an application's data area and an input/output device. A device or its adapter may in turn use a buffer to store data awaiting transfer to the computer or processing by the device. V: To use a region of memeory to hold data that is waiting to be transferred, especially to or from input/output devices such as disk drives and serial ports. overflow 1 - N: The condition that occurs when data resulting from input or processing requires more bits than have been provided in hardware or software to store the data. Examples of overflow include a floating-point operation whose result is too large for the number of bits allowed for the exponent, a string that exceeds the bounds of the array allocated for it, or an integer operation whose result contains too many bits for the register into which it is to be stored. 2 - N: The part of a data item that cannot be stored because the data exceeds the capacity of the available data structure. # Regards, Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] http://www.insiteful.tv --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: DBI in CGI's
Can you telnet or SSH into your server? Do they have the CPAN module installed? If the answers to those 2 questions are yes, try perl -MCPAN -e 'install Bundle::DBI' I don't *think* this module is of the pure perl variety, so my suspicion is that it has to be installed by whoever is root. If your web host won't do that, you may have to look at other alternatives. There may be information in the DBI FAQ also. perldoc DBI::FAQ Scot R. inSite -Original Message- From: Barry Jones [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 03, 2002 2:31 PM To: Beginner-CGI (E-mail) Subject: DBI in CGI's I need to access a database run by my service provider. They provide the database administration tools via the web, and Perl is available for CGI's (which I've abused abundantly), but if I so much as say use DBI; I get an internal server error. Is there anyway that I can sort of hack my way around this and still use the DBI even if it's not available on the server? Where can I get the MySQL drivers? Barry Jones DATABUILT, Inc. The Global AEC Information Company 1476 Fording Island Rd. Bluffton, SC 29910 (843) 836-2166 office Life is like a dogsled team; if you ain't the lead dog, the scenery never changes. - Lewis Grizzard -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Executing cgi from html
You can do what you are saying, with the exception that you will not be able to keep the .html extension without a reconfiguration of the web server. Most likely, you will have to change it to .shtml or .shtm, depending on your web server and OS. Check out this documentation on server side includes: http://hoohoo.ncsa.uiuc.edu/docs/tutorials/includes.html Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -Original Message- From: Rafael Cotta [mailto:[EMAIL PROTECTED]] Sent: Sunday, June 30, 2002 11:17 PM To: [EMAIL PROTECTED] Subject: Executing cgi from html Hi all, I have a dynamic page, with server side includes on it, but I would like to keep this with the .html extension and execute a small cgi to record the referrer and some other informations, once the hosting service I use offers CGI but not stats. Is it possible? I have already seen something about a !--EXEC-- or the like. Does it offer this kind of functionality? Thanks in advance, Rafael -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: cgi probs
Ian, Which version of Apache? 1.3.x, or 2.x? Here is where to find the documentation: http://httpd.apache.org/docs-project/ Most changes you would need to make in Apache are in the 'httpd.conf' file. Like Randal said, though, it's ultimately up to the browser how to process the file if there is not a handler for it on the server. If you have the browser set to display text/plain docs in the browser, there's not much you can do to change that situation on the server. One trick you can try is to put it in a zip file; most browsers will prompt you to either save or open that type of file. You might want to read the Apache documentation for the 'AddHandler' directive as well; this may provide some assistance. http://httpd.apache.org/docs/mod/mod_mime.html#addhandler HTH, Scot R. inSite -Original Message- From: Ian Rogers [mailto:[EMAIL PROTECTED]] Sent: Sunday, June 30, 2002 9:27 AM To: [EMAIL PROTECTED] Subject: RE: cgi probs yes it is, but i am not sure if it is setup right. like i say i have installed linux, but haven't done anything with apache. What do i need to do to configure and run apache, as that could well be my problem. thanks Ian Scot Robnett [EMAIL PROTECTED] wrote: I hate to ask the obvious, but is your web server running on that box? Scot R. -Original Message- From: Ian Rogers [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 27, 2002 5:19 PM To: [EMAIL PROTECTED] Subject: cgi probs Hi I have set up my machine running suse linux, and i am now trying to get cgi working. I have written a html for to post the data and a basic cgi script to read in and print out the results. I have written cgi code on other machines so the code is correct, but i am having trouble on my machine. When i press the submit button it comes up with a message to confirm if i want to send the data, but when i click on ok, nothing happens, just like it can't find the script, but i have put the correct path for the script in the form action. is there anything i need to do apart from i! nstalling perl? i have placed my cgi script in my cgi-bin directory, and the htlm file in the www/public_html directory. I am not sure what i am doing wrong any help would be fully apreciated thanks Ian - Relive the FIFA World Cup goals with exclusive video highlights! http://fifaworldcup.yahoo.com/fc/en Relive the FIFA World Cup goals with exclusive video highlights! http://fifaworldcup.yahoo.com/fc/en --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: CGI.pm v/s roll-your-own [WAS:] Displaying Problems
Picky, picky. :) You're right, my bad. use CGI; my $q = new CGI; my %params = $q-Vars; SR -Original Message- From: Felix Geerinckx [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 27, 2002 2:16 AM To: [EMAIL PROTECTED] Subject: RE: CGI.pm v/s roll-your-own [WAS:] Displaying Problems on Thu, 27 Jun 2002 02:54:10 GMT, [EMAIL PROTECTED] (Scot Robnett) wrote: Its pretty hard to make it more simple than: use Form; my %input = Form(); Let me try. use CGI; %params = $q-Vars; Try again. Your code throws the following error: Can't call method Vars on an undefined value ... -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: CGI.pm v/s roll-your-own [WAS:] Displaying Problems
I haven't seen the rest of your module, so I'm not so sure that the point really stands. It might. But, adding one line to initialize the CGI object is really not that big a deal considering the kind of power you have associated with that object. How much extra work do I have to do to utilize the keys and values in your hash vs. the CGI.pm hash? The data structure you get back from CGI.pm is: - Called in a scalar context, a tied hash reference. - Called in a list context, a standard hash containing key/value pairs. - Keys/params with multiple values are returned as a packed string separated by \0. Scot R. inSite -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 27, 2002 10:44 AM To: Scot Robnett; [EMAIL PROTECTED] Cc: Felix Geerinckx Subject: Re: CGI.pm v/s roll-your-own [WAS:] Displaying Problems my point stands :) So out of curiosity, what kind of data structure do you get back with this? If its as I would imagine, then its very close to my own. %hash = ( 'a_name' = 'value', # for single name value pairs 'b_name' = [multiple, values, for, this], # for single name muli-value sets 'c_name' = { 'original_name' = 'filename.jpg', 'size' = '23554', 'location' = '/tmp/fileupload/tmpfile-10028983-88.57.192.3-2783-298374-927837' } # for files ); Of coarse I know the image information is not in there the same way. David - Original Message - From: Scot Robnett [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: Felix Geerinckx [EMAIL PROTECTED] Sent: Thursday, June 27, 2002 8:29 AM Subject: RE: CGI.pm v/s roll-your-own [WAS:] Displaying Problems Picky, picky. :) You're right, my bad. use CGI; my $q = new CGI; my %params = $q-Vars; SR -Original Message- From: Felix Geerinckx [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 27, 2002 2:16 AM To: [EMAIL PROTECTED] Subject: RE: CGI.pm v/s roll-your-own [WAS:] Displaying Problems on Thu, 27 Jun 2002 02:54:10 GMT, [EMAIL PROTECTED] (Scot Robnett) wrote: Its pretty hard to make it more simple than: use Form; my %input = Form(); Let me try. use CGI; %params = $q-Vars; Try again. Your code throws the following error: Can't call method Vars on an undefined value ... -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: CGI.pm v/s roll-your-own [WAS:] Displaying Problems
True. Whew, my hand hurts from all that extra typing. ;) Scot R. -Original Message- From: John Brooking [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 27, 2002 1:50 PM To: Scot Robnett; [EMAIL PROTECTED] Cc: Felix Geerinckx Subject: RE: CGI.pm v/s roll-your-own [WAS:] Displaying Problems See?! Your version just expanded by 50% !! ;-) --- Scot Robnett [EMAIL PROTECTED] wrote: Picky, picky. :) You're right, my bad. use CGI; my $q = new CGI; my %params = $q-Vars; = Now it's over, I'm dead, and I haven't done anything that I want; or, I'm still alive, and there's nothing I want to do. - They Might Be Giants, http://www.tmbg.com __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: cgi probs
I hate to ask the obvious, but is your web server running on that box? Scot R. -Original Message- From: Ian Rogers [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 27, 2002 5:19 PM To: [EMAIL PROTECTED] Subject: cgi probs Hi I have set up my machine running suse linux, and i am now trying to get cgi working. I have written a html for to post the data and a basic cgi script to read in and print out the results. I have written cgi code on other machines so the code is correct, but i am having trouble on my machine. When i press the submit button it comes up with a message to confirm if i want to send the data, but when i click on ok, nothing happens, just like it can't find the script, but i have put the correct path for the script in the form action. is there anything i need to do apart from installing perl? i have placed my cgi script in my cgi-bin directory, and the htlm file in the www/public_html directory. I am not sure what i am doing wrong any help would be fully apreciated thanks Ian - Relive the FIFA World Cup goals with exclusive video highlights! http://fifaworldcup.yahoo.com/fc/en
RE: HTML form another web site
You need to check out the LWP module. http://search.cpan.org/doc/RSE/lcwa-1.0.0/lib/lwp/lib/LWP.pm Scot R. inSite Internet Solutions [EMAIL PROTECTED] http://www.insiteful.tv -Original Message- From: Fred Sahakian [mailto:[EMAIL PROTECTED]] Sent: Monday, June 24, 2002 9:49 AM To: Subject: HTML form another web site Is there an easy way to display the HTML from another website on your page without a redirect? for example, the below CGI just forwards you: #!/usr/local/bin/perl print Location:http://thecgibin.com/quickcode/redirect.shtml\n\n;; I would mlike a CGI to just get the HTML from another page without the forward. thanks, Fred --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how to change my password throught cgi
Assuming you are on UNIX, run your script suid. For example, if your script was called auth.cgi, here is what you would do: 1st, at the command line: chmod 4711 auth.cgi 2nd, change your shebang line in your script to include the -U (run as user) flag: #!/usr/bin/perl -U Now the script should be running as you rather than 'www' or 'httpd'. Scot R. inSite Internet Solutions [EMAIL PROTECTED] http://www.insiteful.tv -Original Message- From: Pavel Koutn [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 13, 2002 10:01 AM To: [EMAIL PROTECTED] Subject: how to change my password throught cgi Hi there, I have Perl script for changing password of current user, but how to do this through web ??? If I access my script through web-browser, current user is always www. After Apache authentication user remains still web. I need to solve this problem, please help me! Pavel --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Object oriented variable question
You are trying to assign a static value to something that comes from the form. If you create a field called comments (or anything you want to call it, that's just what I chose) on your form and then type your test string, it will work with the following change to your code: == #!/usr/bin/perl -wT use CGI; use CGI::Carp 'fatalsToBrowser'; use strict; my $q = new CGI; my $test = $q-param('comments'); # Dynamic value rather # than a static one print $q-header(text/html), $q-start_html, $q-p(Hello! . $test . Did it work?), $q-end_html; = Now, on your form, type This is a test! into your comments box and see what results you get. Betcha it works this time. If you wanted $test to always have a static value (I'm not sure why you would, but then again I don't know your application), you could have just set my $test = This is a test!; Scot R. inSite Internet Solutions [EMAIL PROTECTED] http://www.insiteful.tv -Original Message- From: Hughes, Andrew [mailto:[EMAIL PROTECTED]] Sent: Monday, June 24, 2002 10:20 AM To: [EMAIL PROTECTED] Subject: Object oriented variable question When using cgi.pm object oriented method, how do I assign a static value to a variable and then output it? The test script that I listed below prints all of the html tags with Hello!Did it work? (without the quotes) in the paragraph tags. Also, in my error log there is the following error: index.cgi: Use of uninitialized value in concatenation (.) or string at index.cgi line 9. == #!/usr/bin/perl -wT use CGI; use CGI::Carp 'fatalsToBrowser'; use strict; my $q = new CGI; my $test = $q-param(This is a test!); print $q-header(text/html), $q-start_html, $q-p(Hello! . $test . Did it work?), $q-end_html; = Thanks for your help! Andrew -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: What editor for Perl do you recommend?
emacs is a good one. I also like TextPad (www.textpad.com). Scot R. inSite Internet Solutions [EMAIL PROTECTED] http://www.insiteful.tv -Original Message- From: Jonathan Gines [mailto:[EMAIL PROTECTED]] Sent: Monday, June 24, 2002 11:19 AM To: Francesco Scaglioni; [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: What editor for Perl do you recommend? definitely go with emacs and use perl-mode then font-lock-mode if you want syntax highlighting. At 03:51 PM 6/24/02 +, Francesco Scaglioni wrote: From: Octavian Rasnita [EMAIL PROTECTED] Subject: What editor for Perl do you recommend? Date: Mon, 24 Jun 2002 08:06:40 +0300 Hi all, Can you recommend me a good editor for Perl scripts that runs under Windows? It should: 1. Save the text with Unix end of lines. 2. Write somewhere the current line I am in. 3. Not necessary but it would be wonderful to have a hotkey to jump from subroutine to subroutine, or to list the subroutines in a combo or list and to be able to choose the one I want from there. With all the success of Perl, I am wondering why isn't there any accessible good and proffessional editor for Windows. Thank you. Teddy Center for the blind: http://teddy.fcc.ro/ Mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Emacs - will do all that you ask Regards F -- 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] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: number
Sorry, that was hasty...shoulda been something more like my $file = '/path/to/file'; open(THEFILE,$file); my @ary = THEFILE; close(THEFILE); for my $line(@ary) { if($line !~ /^\d/) { } } -Original Message- From: Bo Mangor [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 20, 2002 1:17 PM To: [EMAIL PROTECTED] Subject: number Hi there I'm a new bird to Perl - and I have a little problem. I have a file input where I split the file into an array and that works fine, but there is some spam in the beginning of the file I want to get rid of - the problem is that I never know how many lines there is with this spam! Therefore I want to make a check that excludes all lines there doesn't start with a number in other languages I would make a check like If (! isNaN(string)) { . } How do I make this check In Perl? I haven't been able to find something similar in Perl, but I know that it should be possible. Best regards Bo -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: number
if($string =~ /^[0-9]/) checks to see if the string starts with 0. If it doesn't, it checks if the string starts with 1. If it doesn't, it checks if the string starts with 2, and so on until the condition is true. If the condition is never true, then it will do whatever is in your else {} (or elsif). The ^ character means starts with in a regex. Scot R. inSite -Original Message- From: Bo Mangor [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 20, 2002 1:49 PM To: [EMAIL PROTECTED] Subject: SV: number Hi again Great thanks to all the quickly answers! I tried a couple of them and - yes it works - thanks! But how does it work? if(string =~/^[0-9]/) The part string =~/^[0-9]/ - does it split the string into single numbers and check if each of them is a part of the list [0-9] ?? I want to be scour that I have understood the Principe correct. Best regards Bo -Oprindelig meddelelse- Fra: Christopher G Tantalo [mailto:[EMAIL PROTECTED]] Sendt: 20. juni 2002 20:25 Til: Bo Mangor Emne: Re: number Bo Mangor wrote: Hi there I'm a new bird to Perl - and I have a little problem. I have a file input where I split the file into an array and that works fine, but there is some spam in the beginning of the file I want to get rid of - the problem is that I never know how many lines there is with this spam! Therefore I want to make a check that excludes all lines there doesn't start with a number in other languages I would make a check like If (! isNaN(string)) { } How do I make this check In Perl? if(string =~/^[0-9]/) { # do something # number at start of string... } else { # do something else } that should work I haven't been able to find something similar in Perl, but I know that it should be possible. Best regards Bo -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- --- Just Your Friendly Neighborhood _SPIDEY_ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Uploading Help
Unless you run your own server, this may not work because the web host may not have decided to update their version of Perl or CGI.pm yet. For instance, my hosting service is still using Perl 5.005_03 with CGI.pm version 2.46. So I tried the preferred upload method with no success. The previous method for reading uploaded files might have been slightly convoluted, but it still works... Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] http://www.insiteful.tv There are only two things in life, but I forget what they are. - John Hiatt --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Having problems with login
You might want to think about crypting those passwords. Plain text still leaves the information somewhat vulnerable, especially if you have them in a flat text file that is being written to in a directory chmod'd 777. Two suggestions: - Check out Lincoln Stein's Crypt::CBC module on CPAN and implement it if it makes sense in your script. - If you're on a UNIX system and want to make that a little easier, you can just system('crypt') the passwords. - If you're on a UNIX system you can run your scripts suid (chmod'd 4711 and #!/usr/bin/perl -U). At any rate, you want to avoid these two things: - Leaving the password in plain text - Leaving the directory world-writeable Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] http://www.insiteful.tv -Original Message- From: Ben Huyghebaert [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 13, 2002 10:43 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Having problems with login It worked! I had to correct some syntax problems I had but after that I got it rolling. Thank you very much! I'll try suggestions next time before I just assume that they won't work. I'm still confused by it but I'll study it maybe understand why it works. LOL On Wed, 12 June 2002, David vd Geer Inhuur tbv IPlib wrote: I think this will work : foreach $i(@access) { chomp $i; ($un,$pw) = split(/\|/, $i); $username = $FORM{'username'}; $password = $FORM{'password'}; if (($username ne $un) || ($password ne $pw)) { print NoPass; (block of html for invalid username/passwordscreen) NoPass } else { print YesPass; (block of html for Account manager screen) YesPass } } # End foreach Regs David --- I'm starting to make a perl/cgi/html based multi-player game called 3MF (Massive Multiplayer Medieval Frolic). So far I've made an account creation screen that writes the data to two flat file db's one of them holds the usernames passwords, while the other holds all the user information. Now I'm working on the login screen but I've run into some problems. It only lets the last user account I create gain access. For any others it sends them to the invalid username and password screen I created. Here is the code I'm using right now. I open up the file with the usernames and passwords and throw it all into @access and then do this foreach $i (@access) { chomp($i); ($un,$pw) = split(/\|/,$i); } $username = $FORM{'username'}; $password = $FORM{'password'}; if ($username ne $un or $password ne $pw){ print NoPass; (block of html for invalid username/passwordscreen) NoPass } else { print YesPass; (block of html for Account manager screen) YesPass } So what do I need to fix to be able to match any username and password and not just the last one created? and by the way all the data is being written to the files and each entry is a new line. If anyone is interested in hearing more about my game concept and helping out with any more problems I run into (there will be many) then let me know. Thanks - Sign up for ICQmail at http://www.icq.com/icqmail/signup.html -- 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] William move your heead! Look at the size of that boys heeead! It's like an orange on a toothpeck! HAD MOVE! - Sign up for ICQmail at http://www.icq.com/icqmail/signup.html -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Am I doing something wrong?
What you are doing is not commenting; you're creating POD documentation. To comment out lines in Perl, use the # character. #!/usr/bin/perl -w print Hello, world! \n; # This is a comment where you # can write about what you're # doing in a particular block # so other programmers won't # be confused by your code. -Original Message- From: Octavian Rasnita [mailto:[EMAIL PROTECTED]] Sent: Friday, June 07, 2002 4:40 AM To: [EMAIL PROTECTED] Subject: Am I doing something wrong? Hi all, I use: =start; . =cut I use this statement to comment out more lines. However, I have seen in Lama Book that there is no block comment in Perl. I thought this statement is used to comment more lines. What is this statement used for, and is it something wrong if I use it just for commenting? Thank you. Teddy, [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.368 / Virus Database: 204 - Release Date: 5/29/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.368 / Virus Database: 204 - Release Date: 5/29/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Perl/CGI mysql book
Programming the Perl DBI http://www.oreilly.com/catalog/perldbi/ SAMS Teach Yourself SQL in 10 Minutes (It's a lie but it's still a helpful book) http://www.amazon.com/exec/obidos/ASIN/0672321289/qid=1023301413/sr=1-1/ref= sr_1_1/002-4842183-8613640 -Original Message- From: Maureen E Fischer [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 05, 2002 1:12 PM To: [EMAIL PROTECTED] Subject: Perl/CGI mysql book I am writing my first CGI application and after analysis of the data structure that is required I determined that a DBM file would not be sufficient. Mysql was suggested to me. Unfortunately I could not find A book that seemed based on Perl and sql. Everything I found connected Mysql to PHP -- which I know nothing about. Since I am new to almost Everyting except some ancient languages and systems I didn't want to Bite off yet another learning experience just yet. I did find and purchase Writing CGI Applications with Perl, which did have a chapter on sql, but since I am having trouble with my first connect I think I will need more Help then the brief chapter can give me. Any suggestion would Be very welcome. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.368 / Virus Database: 204 - Release Date: 5/29/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.368 / Virus Database: 204 - Release Date: 5/29/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Perl/CGI Website Ideas
The best place to start is with the books Learning Perl and CGI Programming with Perl (you can find them on www.oreilly.com). Check out this site, www.pm.org to find a Perl Mongers user group near you. You can see what other people have done (so you can do it better) at sites like http://www.cgi-resources.com/Programs_and_Scripts/Perl/ and http://www.scriptsearch.com/Perl/Scripts_and_Programs/ And stay on this list, of course. :) Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] [EMAIL PROTECTED] -Original Message- From: John Pitchko [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 05, 2002 3:17 PM To: [EMAIL PROTECTED] Subject: Perl/CGI Website Ideas Hello, I am somewhat of a newbie to Perl and CGI. I have written several scripts for use on a corporate website with great success. However, I am interested in designing an entire website with Perl CGI, but I do not really know where to begin or any inspiration for it. Does anyone know where I can find some information about designing websites with Perl CGI? Thanks, John Pitchko Saskatchewan Government Insurance --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.368 / Virus Database: 204 - Release Date: 5/29/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.368 / Virus Database: 204 - Release Date: 5/29/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Replacing with Regular expressions
He said he wanted to replace all nonalphanumerics, and I was assuming that meant white space as well, regardless of where in the string it is located. Scot -Original Message- From: Janek Schleicher [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 04, 2002 8:51 AM To: [EMAIL PROTECTED] Subject: RE: Replacing with Regular expressions Scot Robnett wrote at Tue, 04 Jun 2002 05:13:13 +0200: $foo =~ s/\W*/_/g; http://www.oreilly.com/catalog/regex/ ... I want to allow only the a-z, A-Z, and 0-9 characters and I want to replace all others with _ when writing the file to the server. Can you tell me what would be this regular expression? The regexp should be $foo =~ s/\W/_/g; \W* matches every zero length, so e.g. $a = 'x := y'; $a =~ s/\W*/_/g; print $a; prints _x__y_; (first matches 0-length before 'x', then ' := ' after x, then 0-length between ' := ' and 'y', then 0-length after 'y' ) Instead my solution would print xy Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.368 / Virus Database: 204 - Release Date: 5/29/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.368 / Virus Database: 204 - Release Date: 5/29/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: What is used htpasswd for?
'htpasswd' is an Apache web server function rather than a Perl function. It originated on UNIX but is also available for Win32. On Win32, usernames and passwords are limited to 255 characters. I'm not sure that's really a limit to be concerned about though...when was the last time you saw a 255-character username? Although it appears to create a different password even when you enter the same one, what is really different is the encryption string that is created. htpasswd encrypts passwords so that password sniffers can not scan a system and find the username:password pairs in plain text. It is used in conjunction with a file in the protected directory (typically called .htaccess, but not always) and another file on the server, preferably a file that is not located within your HTML document root (usually something like /usr/apache/htdocs/username). The process goes like this: 1. Create a file in the directory that you wish to password protect. For our purposes we'll just call it the default .htaccess 2. Type the following to create a new password protected account: htpasswd -c /path/to/.htaccess username Note: The -c flag is only needed when you create the new user. If the user already exists, -c is not necessary. Just think of it as -c equals create. 3. Your .htaccess file will look similar to this. Please consult the Apache documentation to see what the options are. This is the most basic configuration. (Apache: www.apache.org) AuthUserFile /path/outside/htmldocroot/passwordfile AuthName Subscribers AuthType Basic Limit GET POST require valid-user /Limit 4. Now create the password for the user. htpasswd username password IMPORTANT: It is not considered a secure practice to keep web password files within your HTML document root. You don't want the file located anywhere that is accessible with a browser via HTTP. For full documentation, look here: http://httpd.apache.org/docs-2.0/programs/htpasswd.html Or in your local Apache administration guide. Regards, Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] [EMAIL PROTECTED] -Original Message- From: Octavian Rasnita [mailto:[EMAIL PROTECTED]] Sent: Sunday, June 02, 2002 2:06 AM To: [EMAIL PROTECTED] Subject: What is used htpasswd for? Hi all, Please tell me what is used the htpasswd program for. I've seen that if I try to create a password file with the same password and the same username, it creates different crypted passwords. I've tried to use some switches to see if it works fine with some of them but with the same results. 1. Example 1: htpasswd -mc file teddy It resulted 2 different strings for the same username and password: teddy:$apr1$Mq3.$j8QQNRoh7YaKtBt.wzTsF. teddy:$apr1$er3.$mM28Rf52RLUDVhJVVAuRt0 2. Example 2, the same: htpasswd -c file teddy teddy:$apr1$4w3.$MVCVlvqfYLsxFxod0u433. teddy:$apr1$cx3.$UTrNklcyZvkObvMQOmbBK1 3. Example 3, the same: htpasswd -cd file teddy teddy:$apr1$G14.$7TFByMvUiwU15y4M2IDbv. teddy:$apr1$/34.$87.InozPs7UF8PfCYpdCF. I've seen that the htdigest program creates the same string but what is used htpasswd for in this case? Thank you. Teddy, [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.365 / Virus Database: 202 - Release Date: 5/24/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.365 / Virus Database: 202 - Release Date: 5/24/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: HTML in E-mail
I don't personally share the 'HTML e-mail is evil' philosophy. And even if you're in the ascii-only camp, HTML mail isn't going anywhere anytime soon. People will ask how to generate and parse it, and there are plenty of Perl tools and modules to do so. I see that it was said only a really cool mail reader can handle MIME messages. I guess that's true if Outlook, Outlook Express, Netscape Mail, Eudora Light, Eudora Pro, recent versions of Lotus, popular 'web-based' mail readers such as Yahoo, Hotmail, Webmail, and most other popular mail readers would be considered really cool. The only mail readers I have seen that don't handle MIME messages very well are older copies of CCmail, Z-mail, and Pine. If you want to create HTML mail or other MIME mail, the most effective way I've found to do it is to use the MIME::Lite module. It can also be used to send HTML mail or various types of attachments. If interested in learning more about it, just go to CPAN and search the module documentation. Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] [EMAIL PROTECTED] -Original Message- From: Camilo Gonzalez [mailto:[EMAIL PROTECTED]] Sent: Monday, June 03, 2002 3:49 PM To: 'David T-G'; perl beginners cgi Cc: Camilo Gonzalez; 'Fred Sahakian' Subject: RE: HTML in E-mail David, I admire your principles. This is something that has come up before and after some trial and error, what I proposed to him seemed to work. I too feel HTML email is evil but some of us are stuck being prostitutes to keep the wolves from our door. -Original Message- From: David T-G [mailto:[EMAIL PROTECTED]] Sent: Monday, June 03, 2002 3:11 PM To: perl beginners cgi Cc: Camilo Gonzalez; 'Fred Sahakian' Subject: Re: HTML in E-mail Fred, Camilo, et al -- .and then Camilo Gonzalez said... % % Fred, % % Thank Jah this problem was recently successfully solved! Try this: % % open(MAIL,|$mailprog -t); % print MAIL Content-Type: text/html\n; % print MAIL To: $comm\@courts.state.ny.us\n; . Note that, although he's posted to the CGI list, he's asking about email. In this case you've stuck on a lovely C-T: header (missing an extra newline, though) as though you were spitting out to a web page, but that's not what he's doing. What he *wants* is to output something like To: ... From: ... Subject: ... Content-Type: multipart/related; boundary=HTML-email-is-really-bad This is a MIME message. Only a really cool mailreader can see this. --HTML-email-is-really-bad Content-Type: text/html; Here is your boldfreakin'/bold HTML mail. --HTML-email-is-really-bad which properly describes the message body in the headers, leaves a blank line to identify the header end and the body begin, and then lays out the body pieces. No, I don't know how to write it in perl. I think I'd feel dirty if I did; this is bad enough ;-) I'm sure there's a module, though. HTH HAND :-D -- David T-G * It's easier to fight for one's principles (play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie (work) [EMAIL PROTECTED] http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.365 / Virus Database: 202 - Release Date: 5/24/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.365 / Virus Database: 202 - Release Date: 5/24/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: HTML in E-mail
Does PINE do anything well? ducks Wait! I'm thinking. Is this a trick question? ;) Scot R. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.365 / Virus Database: 202 - Release Date: 5/24/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: URL for security issue?
I don't know if this was one of the retransmissions you were looking for, but here you go just in case. - I usually do a combination of things. * You can check domains, but they can be spoofed, so that in itself is not a cure. It's a start. * Does the site have a static IP? You can set the script only to run if called from that IP. Once again 'spoofable' but less than a domain on its own. * Use the CGI.pm module's built-in data limit function. You can set POST_MAX to a reasonable level to avoid buffer overflow issues, or just set DISABLE_UPLOADS = 1 if no files are going to be uploaded. * Are you on UNIX? Most of my sites are on some flavor of *NIX and I run my scripts suid. You can explicitly tell the script that it can run -only- as the user, not even as the httpd daemon. (#!/usr/bin/perl -U with the script directory chmod'd 4711) Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] [EMAIL PROTECTED] -Original Message- From: David T-G [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 30, 2002 11:53 AM To: Beginners CGI Cc: John Brooking Subject: Re: URL for security issue? John, et al -- and then John Brooking said... % % Gang, Hello! % %A week or three ago, someone referred to a page % that discussed security issues when using CGI input to % send out to a web page. I thought I had bookmarked the % page or saved the email, but I can't find it now. % Could whoever posted it please do so again, or maybe % just email it to me privately? Thanks! Actually, I'd appreciate such a thing, too. I just went back through my list mailbox looking for cgi and security in the body and don't see anything relating to a pointers page; the closet is Ovid's response to Fred Sahakian outlining some things to check when looking at a CGI script. % % - John HTH HAND :-D -- David T-G * It's easier to fight for one's principles (play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie (work) [EMAIL PROTECTED] http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg! --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.365 / Virus Database: 202 - Release Date: 5/24/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: URL for security issue?
John, Thanks for that link. Good reading/advice. Scot R. -Original Message- From: John Brooking [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 30, 2002 12:02 PM To: David T-G; Beginners CGI Subject: Re: URL for security issue? Actually, I may have just found it. I think it was Preventing Cross-site Scripting Attacks at http://www.perl.com/pub/a/2002/02/20/css.html. In any case, that's good reading, and if anyone has any others to pass along, feel free. If I get enough, I'll publish a links page of them for future reference. --- David T-G [EMAIL PROTECTED] wrote: Actually, I'd appreciate such a thing, too. I just went back through my list mailbox looking for cgi and security in the body and don't see anything relating to a pointers page; the closet is Ovid's response to Fred Sahakian outlining some things to check when looking at a CGI script. = Now it's over, I'm dead, and I haven't done anything that I want; or, I'm still alive, and there's nothing I want to do. - They Might Be Giants, http://www.tmbg.com __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.365 / Virus Database: 202 - Release Date: 5/24/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.365 / Virus Database: 202 - Release Date: 5/24/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to match next line?
I am concatenating several e-mail lists into one, and some of the addresses are on multiple lists. I need to be able to print out a full, alphabetically sorted list of all the names without printing duplicates. How would I alter the following to make that happen? This gets close; it *will* remove a duplicate address if there are only two of the same address. But it won't work if there are three or four of the same address, for example. I'm also sure this could be shortened or cleaned up; suggestions welcome #!/usr/bin/perl -w use strict; my $infile = '/path/to/.biglist.list'; my @slurped = (); open(IN,$infile); while(IN) { @slurped = IN; # Pull addresses into an array } close(IN); my @sorted = sort(@slurped); # Create a sorted list my $i; my $j; foreach ($i = 0; $i = @sorted; $i++) { chomp($i); $j = $i++; # Only finds 1 address beyond $i if ($sorted[$i] =~ /$j/) # Compare this line w/next line { next; # If it matches, skip it } else { print Address = $sorted[$i] \n; } } Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] [EMAIL PROTECTED] --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to match next line?
Tagore, Good points, and well taken. I was definitely planning to modify case using tr/[A-Z]/[a-z]/ but just hadn't gotten that far yet. I hadn't considered the hash idea but it makes a hell of a lot more sense than what I was doing. Thanks. Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] [EMAIL PROTECTED] -Original Message- From: Tagore Smith [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 22, 2002 1:16 PM To: cgi Subject: Re: How to match next line? BTW, one thing you might consider is that there may be duplicate email addresses that differ only in case. You might want to check for that. Tagore Smith -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: regular expression
Regular expressions are overkill for what you're trying to do. It seems like using 'split' should do exactly what you need. #!/usr/bin/perl -W use strict; open(IN,/path/to/file) or die Could not open file; my @list = IN; close(IN); for(@list) { chomp; my($field,$value) = split(/=/,$_); # split each line on '=' print Your $field is $value. \n; } Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] [EMAIL PROTECTED] -Original Message- From: ChaoZ Inferno [mailto:[EMAIL PROTECTED]] Sent: Friday, May 17, 2002 11:38 AM To: [EMAIL PROTECTED] Subject: Re: regular expression Actually, the content of the file looks something like:- name=john id=12345 password=12345 colour=blue I am trying to grab the value field of each line and assigned it to be a variable. I tried the regular expressions, but seems like the syntax is wrong or something, @file = filehandle; #small file anyway $file[0] is equal to 'name=john' but i just wanna extract john to be my scalar variable. like print $name but returns john only and the same extraction method for the rest of the other 3 fields as well. kindly advice!... million thanks! - Original Message - From: David Gray [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: 'ChaoZ InferNo' [EMAIL PROTECTED]; 'Shawn' [EMAIL PROTECTED] Sent: Friday, May 17, 2002 10:16 PM Subject: RE: regular expression code ... for(@text) { /(d+)$/; # Match only the numbers at the end of the string ^^ this should actually be (\d+) I would actually conditionally print also, like so: print $1 if /(\d+)$/; And depending on the size of the file, instead of reading the whole thing into memory with my @text = (FILE); I would do: while(FILE) { print $1 if /(\d+)$/; } # and store them in '$1' to be printed out on the # next line followed by a new line character ... @text # contains values of a phone directory $text[0] contains john=012345678 $phone1 = ? let say i wanted to grab just the values'012345678'. how should i go on truncating the values? Cheers, -dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]