Re: 500 Internal Server Error
I really might help if you share a little code with the group. Just paste some into your email. Mark Bergeron -Original Message- From: Paul Burkett[EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: Mon Jun 25 12:59:08 PDT 2001 Subject: 500 Internal Server Error Everything I try I get the same error! I've tried using 'use CGI' but still nothing. I found a command that works it's called HTTP Command 204 but how do I implement this into the script? And where do I put the Content: line in? /~_. _ | _ _ _ _ \_/|(_||| | |(_)| | _| ___ GO.com Mail Get Your Free, Private E-mail at http://mail.go.com
Some Advice plz :))
hi yall, yup, i'm an old country boy... loli'm strugling here to learn perl on my own and with help from(maybe yall)lol so plz bare with me... i need some advice on an issue here... i'm creating, well trying to create, a ranking system for my online pals... i've accomplished user signup, print info to flatfile database... send confirmation of account and a search for lost userid and pwd... now, i got to thinking... if say a user wants to update their info( change pwd, name, etc...)i'm just completely lost here... does anyone have a good explanation or some code snippets i can look at? tx again RD Sr.
SORRY... i didn't know guys :((
my god, i don't recall asking for you to write my F* code Pierre Smolarek all i asked for was advice to point me in that direction... if being a programmer is ganna make me a SMART***, i think i better quit now... sorry casey i won't post no more like this RDWest Sr.
RE: Some Advice plz :))
Wow, your response to Mr. Smolarek was a bit harsh, even though is response to you was harsh as well. Hmm Anyway, you'll have to read each line in and parse it and write it out, modifying the appropriate line. You already have the parsing done or you'd not be able to send the confirmation and search for lost passwords. You read each line, parse it, inspect it to see if it is the appropriate line to modify and modify it accordingly, then write it out to a temp file. Keep doing that until you've gone through all of the lines, then remove the original file and move the temp file into its place. hth Chris -Original Message- From: RDWest Sr. [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 27, 2001 9:12 AM To: [EMAIL PROTECTED] Subject: Some Advice plz :)) hi yall, yup, i'm an old country boy... loli'm strugling here to learn perl on my own and with help from(maybe yall)lol so plz bare with me... i need some advice on an issue here... i'm creating, well trying to create, a ranking system for my online pals... i've accomplished user signup, print info to flatfile database... send confirmation of account and a search for lost userid and pwd... now, i got to thinking... if say a user wants to update their info( change pwd, name, etc...)i'm just completely lost here... does anyone have a good explanation or some code snippets i can look at? tx again RD Sr.
Re: Crypt function
James == James Kelty [EMAIL PROTECTED] writes: James Can anyone point out a good book that details the functionality James of perl and crypt()? I would like to have a cgi page that James allows new member to sign up, hold the info in a flat file, but James I would like to have the passwords encrypted. Any help would be James much appreciated! Thanks alot! The basic strategy is: my $username = randal; my $cleartext = guessme; # this is the password you want to protect ... adding user to password file my $encrypted = crypt($cleartext, zz); open PASSWORDFILE passwd or die; print PASSWORDFILE $username:$encrypted\n close PASSWORDFILE; ... time passes my $username = param('username'); # randal my $guess = param('password'); # testing to see if it's guessme my $encryptedpassword; open PASSWORDFILE, passwd or die; while (PASSWORDFILE) { chomp; my ($u, $e) = split /:/; next if $u ne $username; $encryptedpassword = $e; last; } die missing user unless defined $encryptedpassword; die mismatch password unless crypt($guess, $encryptedpassword) eq $encryptedpassword; .. he's good! That last line is the big one. You store the *output* of crypt into the file. You then compare the result of running crypt *again* to what's in the file. As for that salt parameter, ignore it. I just use zz or something. In this day and age with fastcrypt implementations, having a varying salt really doesn't add much to security. Hope this helps... it took me a few minutes to compose. :) -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Re: Re: Some Advice plz :))
Oh boy... here we go! This should fire up some creativity. This first book should be the Random House Dictionary of the English Language (-; Followed by the Llama book. Followed by a great list of resources for solving this type of problem easily. my 2 cents early, Mark Bergeron -Original Message- From: Chris Mulcahy[EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: Wed Jun 27 08:21:46 PDT 2001 Subject: Re: Some Advice plz :)) Wow, your response to Mr. Smolarek was a bit harsh, even though is response to you was harsh as well. Hmm Anyway, you'll have to read each line in and parse it and write it out, modifying the appropriate line. You already have the parsing done or you'd not be able to send the confirmation and search for lost passwords. You read each line, parse it, inspect it to see if it is the appropriate line to modify and modify it accordingly, then write it out to a temp file. Keep doing that until you've gone through all of the lines, then remove the original file and move the temp file into its place. hth Chris -Original Message- From: RDWest Sr. [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 27, 2001 9:12 AM To: [EMAIL PROTECTED] Subject: Some Advice plz :)) hi yall, yup, i'm an old country boy... loli'm strugling here to learn perl on my own and with help from(maybe yall)lol so plz bare with me... i need some advice on an issue here... i'm creating, well trying to create, a ranking system for my online pals... i've accomplished user signup, print info to flatfile database... send confirmation of account and a search for lost userid and pwd... now, i got to thinking... if say a user wants to update their info( change pwd, name, etc...)i'm just completely lost here... does anyone have a good explanation or some code snippets i can look at? tx again RD Sr. /~_. _ | _ _ _ _ \_/|(_||| | |(_)| | _| ___ GO.com Mail Get Your Free, Private E-mail at http://mail.go.com
Re: Crypt function
On Wed, Jun 27, 2001 at 08:49:55AM -0700, James Kelty wrote: Can anyone point out a good book that details the functionality of perl and crypt()? I would like to have a cgi page that allows new member to sign up, hold the info in a flat file, but I would like to have the passwords encrypted. Any help would be much appreciated! Thanks alot! I normally use Digest::MD5 for this kind of thing. The module, like most others, is available from CPAN. #!/usr/bin/perl -w use Digest::MD5 qw(md5_hex); use strict; my $secret_password=foobarqux; my $digest=md5_hex($secret_password); This is not really encryption as it's a one-way function. You can't reverse the procedure to find the password from the digest so to authorise your users you will need to perform the digest function on the password they've supplied and compare it with the stored string. Be wary of passing passwords over http as they can be sniffed, https would be preferred. There's probably better ways of authenticating users. I would be glad to learn them from any of the real programmers on the list. :) Regards. EbGb.
RE: Help with Download
Thanks for the help ... I got a little further but still get : ... ... ... tar: CGI.pm-2.752/CGI.pm - cannot create tar: CGI.pm-2.752/README - cannot create tar: CGI.pm-2.752/cgi_docs.html - cannot create tar: CGI.pm-2.752/Makefile.PL - cannot create tar: CGI.pm-2.752/cgi-lib_porting.html - cannot create Results of gunzip tar: SUN1ls CGI.pm-2.752 CGI_pm_tar SUN1ls -l .. total 0 drwxrwxrwx 3 usract admin 96 Jun 27 14:25 CGI SUN1 -Original Message- From: fliptop [mailto:[EMAIL PROTECTED]] Sent: June 27, 2001 13:01 To: Moon, John Cc: CGI Beginners Subject: Re: Help with Download Moon, John wrote: I have downloaded http://stein.cshl.org/WWW/software/CGI/CGI.pm.tar.gz (to pc then ftp to Unix as binary to directory when I want to install ) but am not familiar with the tar processor... When I tried : SUN2tar xvf *.tar you need to unzip it first: gunzip *.gz or, maybe (on a sun os): gzip -d *.gz then run a tar -xvf *.tar
RE: Help with Download
Thanks again for the help ... needed to change my default mask to allow tar to create dirs with correct permissions ... I was/am not use to what tar does ... now the make ... -Original Message- From: Moon, John [mailto:[EMAIL PROTECTED]] Sent: June 27, 2001 14:30 To: CGI Beginners Subject: RE: Help with Download Thanks for the help ... I got a little further but still get : ... ... ... tar: CGI.pm-2.752/CGI.pm - cannot create tar: CGI.pm-2.752/README - cannot create tar: CGI.pm-2.752/cgi_docs.html - cannot create tar: CGI.pm-2.752/Makefile.PL - cannot create tar: CGI.pm-2.752/cgi-lib_porting.html - cannot create Results of gunzip tar: SUN1ls CGI.pm-2.752 CGI_pm_tar SUN1ls -l .. total 0 drwxrwxrwx 3 usract admin 96 Jun 27 14:25 CGI SUN1 -Original Message- From: fliptop [mailto:[EMAIL PROTECTED]] Sent: June 27, 2001 13:01 To: Moon, John Cc: CGI Beginners Subject: Re: Help with Download Moon, John wrote: I have downloaded http://stein.cshl.org/WWW/software/CGI/CGI.pm.tar.gz (to pc then ftp to Unix as binary to directory when I want to install ) but am not familiar with the tar processor... When I tried : SUN2tar xvf *.tar you need to unzip it first: gunzip *.gz or, maybe (on a sun os): gzip -d *.gz then run a tar -xvf *.tar
FW: IS THERE A PLATFORM FOR PERL DEVELOPERS?
I want to start developing perl applications in a windows 95 environment where and how do I about obtaining a compiler of some sort to accomplish this. Additionally how do I cater the software to my environment. -Original Message- From: [EMAIL PROTECTED]%internet [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 26, 2001 12:33 PM To: [EMAIL PROTECTED]%internet Subject: beginners-cgi Digest 26 Jun 2001 16:32:24 - Issue 28 beginners-cgi Digest 26 Jun 2001 16:32:24 - Issue 28 Topics (messages 748 through 777): Re: If I could get just one Perl Book what should it be? 748 by: Mel Matsuoka 749 by: RTaylor.thermeon.com 750 by: RTaylor.thermeon.com 751 by: Chris Hedemark Re: ? embed scalars in the sql 752 by: Francesco Scaglioni 753 by: Sage, Christian 756 by: mark crowe (JIC) 758 by: Francesco Scaglioni 759 by: PURMONEN, Joni 762 by: Francesco Scaglioni 764 by: Sage, Christian 765 by: mark crowe (JIC) 768 by: Curtis Poe 770 by: Maxim Berlin 774 by: mark crowe (JIC) 777 by: Maxim Berlin Unsubscribing 754 by: Derek Harding 755 by: Cochrane, Paul 760 by: Lucy 767 by: Mark Bergeron why perl - idc - htx - won't work in PWS 757 by: Frederick Alain Ang Yap 766 by: Kris Cook HTTP headers/Mime types 761 by: Gary Stainburn 763 by: Hasanuddin Tamir Re: Code Review 769 by: Aaron Craig 771 by: Curtis Poe 773 by: Aaron Craig Different reply-to? 772 by: Curtis Poe 776 by: Aaron Craig Mainting State On IIS 4 Without Cookies/Hidden Fields 775 by: David Simcik Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] --
Including other files
Can you include say a header and footer .cgi file that is just a subroutine? The reason I ask, is that it seems to me that it might make things (on a larger application) easier if all you had to do was mess with the middle content of the pages. Does this make sense at all? -James
Re: Including other files
On Wed, 27 Jun 2001, James Kelty wrote: Can you include say a header and footer .cgi file that is just a subroutine? The reason I ask, is that it seems to me that it might make things (on a larger application) easier if all you had to do was mess with the middle content of the pages. Does this make sense at all? Include where? Include head and footer subs in a main CGI script? You can certainly do that, if you properly create a a module and import the subroutines. If you are talking about using SSI in HTML, you can do that also, if your server supports SSI. You might want to take a look at Mason: http://masonhq.com. It's a Perl-based component framework for building web applications, and can accomplish what you want to do, and much more on top of that. -- Brett http://www.chapelperilous.net/btfwk/ Breeding rabbits is a hare raising experience.
Re: Including other files
Sorry about the confusion. I did mean in the body of the main cgi and subsequent cgis later. Not SSIs. Sorry about that. -James Brett W. McCoy wrote: On Wed, 27 Jun 2001, James Kelty wrote: Can you include say a header and footer .cgi file that is just a subroutine? The reason I ask, is that it seems to me that it might make things (on a larger application) easier if all you had to do was mess with the middle content of the pages. Does this make sense at all? Include where? Include head and footer subs in a main CGI script? You can certainly do that, if you properly create a a module and import the subroutines. If you are talking about using SSI in HTML, you can do that also, if your server supports SSI. You might want to take a look at Mason: http://masonhq.com. It's a Perl-based component framework for building web applications, and can accomplish what you want to do, and much more on top of that. -- Brett http://www.chapelperilous.net/btfwk/ Breeding rabbits is a hare raising experience.
Re: Including other files
On Wed, 27 Jun 2001, James Kelty wrote: Sorry about the confusion. I did mean in the body of the main cgi and subsequent cgis later. Not SSIs. Sorry about that. Well, yes, you can do that. In fact, from a design standpoint, it's definitely a good idea to take out the common elements of your webpages and include them in the parts that change. Again, take a look at Mason. -- Brett http://www.chapelperilous.net/btfwk/ Huh?
Problem with my code
I can't get any response from the location I am trying to contact. I can reach an external location like www.yahoo.com without any problem. When I use my web browser I have no problem receiving a response from the CGI even if I give bad information to the POST. I know I am not using a proxy. Please pardon my email program for the wordwrap... use LWP::UserAgent; $ua = LWP::UserAgent-new; my $req = HTTP::Request-new(POST = 'http://www.informatics.jax.org/searches/homology_report.cgi'); $req-content_type(application/x-www-form-urlencoded); $john = qw(order=symbolinclude=*limit=0_Species_key=op:symname=begins); $john .= qw(symname=abl1); $jonh.=qw(symnameBreadth=CWScmp_Species_key=); my $res = $ua-request($req); print $res-code,'\n'; Thank you, Greg Touchton\\ /=| 540-552-5967 \\ // =| 338 Shenandoah Cir \// =|
Re: Problem with my code
First you should always use strict. It'll help catch things like your misspeling of jonh. The request you are sending is for a POST, which means that the form data has to be passed in the body of the request, which you forgot to do. So just add: $req-content($john); Correct the spelling mistake, use strict, my all your variables, and it should work fine.. except that your query isn't understood by their cgi. I used this query for testing: my $john = qq|order=symbolinclude=selected*limit=500_Species_key=1op%3Asymname=beginssymname=symnameBreadth=CWSop%3Achromosome=%3Dchromosome=op%3AcytogeneticOffset=beginscytogeneticOffset=op%3A_primary=begins_primary=refid=id=cmp_Species_key=op%3Acmp_chromosome=%3Dcmp_chromosome=op%3Acmp_cytogeneticOffset=beginscmp_cytogeneticOffset=|; p.s. interesting project :) -- my edited version: use strict; use LWP::UserAgent; my $ua = LWP::UserAgent-new; my $req = HTTP::Request-new(POST = 'http://www.informatics.jax.org/searches/homology_report.cgi'); $req-content_type(application/x-www-form-urlencoded); my $john = qq|order=symbolinclude=selected*limit=500_Species_key=1op%3Asymname=beginssymname=symnameBreadth=CWSop%3Achromosome=%3Dchromosome=op%3AcytogeneticOffset=beginscytogeneticOffset=op%3A_primary=begins_primary=refid=id=cmp_Species_key=op%3Acmp_chromosome=%3Dcmp_chromosome=op%3Acmp_cytogeneticOffset=beginscmp_cytogeneticOffset=|; $req-content($john); # print $req-as_string(); my $res = $ua-request($req); print $res-code,'\n'; print $res-content(); Greg Touchton wrote: I can't get any response from the location I am trying to contact. I can reach an external location like www.yahoo.com without any problem. When I use my web browser I have no problem receiving a response from the CGI even if I give bad information to the POST. I know I am not using a proxy. Please pardon my email program for the wordwrap... use LWP::UserAgent; $ua = LWP::UserAgent-new; my $req = HTTP::Request-new(POST = 'http://www.informatics.jax.org/searches/homology_report.cgi'); $req-content_type(application/x-www-form-urlencoded); $john = qw(order=symbolinclude=*limit=0_Species_key=op:symname=begins); $john .= qw(symname=abl1); $jonh.=qw(symnameBreadth=CWScmp_Species_key=); my $res = $ua-request($req); print $res-code,'\n'; Thank you, Greg Touchton\\ /=| 540-552-5967 \\ // =| 338 Shenandoah Cir \// =| -- Perl, because 600 billion oysters can't be wrong Canadian Consulting Services' pet perl hacker David Labatte [EMAIL PROTECTED]
correction
sorry, the next installment will be Step 7, not 8.
Re: Including other files
Hi, I have a similar situation in my project. I have created a file like mylib.pl and I put all my subroutines into it. In every page which I use i just add a line require mylib.pl IT works fine for me. I would like to know 1. if this approch is Good 2. Is their any performance problem compared to writing the subs directly in main. 3. Is there any better approch. with regards Rajeev Rumale ~~~ Rajeev Rumale MyAngel.Net Pte Ltd.,Phone : (65)8831530 (office) #04-01, 180 B, The Bencoolen, Email : [EMAIL PROTECTED] Bencoolen Street, Singapore - 189648 ICQ: 121001541 Website : www.myangel.net ~~~ - Original Message - From: Mark Bergeron [EMAIL PROTECTED] To: James Kelty [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, June 28, 2001 8:01 AM Subject: Re: Including other files Yes you can. -Original Message- From: James Kelty[EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: Wed Jun 27 15:18:23 PDT 2001 Subject: Including other files Can you include say a header and footer .cgi file that is just a subroutine? The reason I ask, is that it seems to me that it might make things (on a larger application) easier if all you had to do was mess with the middle content of the pages. Does this make sense at all? -James /~_. _ | _ _ _ _ \_/|(_||| | |(_)| | _| ___ GO.com Mail Get Your Free, Private E-mail at http://mail.go.com
Re: Crypt function
Randal L. Schwartz [EMAIL PROTECTED] writes: my $encrypted = crypt($cleartext, zz); . As for that salt parameter, ignore it. I just use zz or something. In this day and age with fastcrypt implementations, having a varying salt really doesn't add much to security. Having a better salt (the two characters zz) helps prevent casual or accidental browsing (say, by the sysadmin) from revealing that two users have the same password. While this only adds minimal security, it's worth the minimal effort to avoid that problem. You can use the first (or last) two characters of the username for a simple salt: my $encrypted = crypt($cleartext, substr($username, -2, 2)); The brief documentation for crypt is available (among other places) at: http://www.perl.com/pub/doc/manual/html/pod/perlfunc/crypt.html [EMAIL PROTECTED] adds: I normally use Digest::MD5 for this kind of thing. The module, like most others, is available from CPAN. #!/usr/bin/perl -w use Digest::MD5 qw(md5_hex); use strict; my $secret_password=foobarqux; my $digest=md5_hex($secret_password); This is not really encryption as it's a one-way function. You can't reverse the procedure to find the password from the digest so to authorise your users you will need to perform the digest function on the password they've supplied and compare it with the stored string. I'll second this recommendation. To avoid the same password issue described above, it's slightly better to append the username when computing the hash, as in: my $digest = md5_hex($secret_password . $username); You may want to require a minimum password length or check for obvious passwords. Also, consider using SSL for the CGI script to prevent the password from being sniffed during transmission to your server. Consult with a security expert if you need more than basic security on your site. + Richard J. Barbalace
Re: reg cgi pgm running
i think this is exclusively for cgi programming.. that too for beginners.. as a beginner i have to configure iplannet in my system then only i can run my cgi program . right???.. then what is wrong in asking abt it??? if it is still out of question.. i am sorry for posted this question. Thanx Regards nila --- Hal Wigoda [EMAIL PROTECTED] wrote: 'This is not the list for iplanet help. At 05:17 AM 6/27/01 -0700, you wrote: hi i am configuring iplannet webserver to run cgi scripts. i dont know how to run my program.. can anyone tell me how to run my hello world program? It wudbe really helpful to me if some one can show me the pointer. Thank you Regards nila __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/
Re: Different reply-to?
I thought that the moderators had asked for these threads to be ceased. The number of emails on this topic, along with the ones on unsubscribing is getting unbelievable - I know, I've just $cout++'d this. I am on more lists than is good for me, and while some do add a prefix to the subject other don't. It doesn not make any differece to me. *NONE* of them have 'reply-to-list' set. This also does not cause me a problem. Almost every mail client has filtering built in - even MS ones. Use the 'To or CC' filter as every mail you receive from this list will have 'beginners@' or 'beginners-cgi@' in one of these fields. The fact that I receive duplicate replies to my posts is also not annoying - it makes it more likely that I see it. Please please PLEASE can we now stop these threads and let the list get on with what it's supposed to do which is help perl beginners get on with productive stuff. Gary On Wednesday 27 June 2001 1:11 pm, Kris Cook wrote: I'm compelled to add my voice to Al's on this. The other lists I've been member of have all had the group as the Reply-to address, not the individual sender. The monitors need to think this through. People will become annoyed with the duplicates, and ask to be removed from the list. The community will lose good interactive communication, and be deprived of a wealth of potential resources. Who's served by that? -Original Message- From: Al Hospers [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 26, 2001 3:20 PM To: [EMAIL PROTECTED] Subject: RE: Different reply-to? although I *have* gotten into the habit of using reply-all instead of reply-to, thus getting my mail out to its intended recipient, I receive multiple copies of the same post from other people who use reply-all and don't take out everybody's name from the To: field. I have received as many as three copies of every message in a thread at times. No wonder I download 200+ messages a day from these two lists alone. If the list must be set to not mess with the reply-to field, could list members at least make sure that they cut out addresses from the To: field before sending their mail? uncloaking I think that this topic was chopped off in mid-stream on beginners. in fact I unsubscribed because when I was active I was getting many doubled posts a day from that list, on top of the normal traffic. very annoying! I don't care what emailer you are using, there is no EASY way to filter out the double postings it is entirely too easy to do. IMHO both lists are set up backwards from the myriad other lists I belong to. most lists have the Reply field to be the reply to the list, Reply All has the list AND the poster's address. thus you hit Reply post back to the list ONLY - which is what most people want to do and what most posters want you to do. if you really WANT to reply to the poster directly, something that is often not desired, you click Reply All dump the list address. the way the list is configured now, if you click reply you will NOT reply to the list at all. thi=us depriving the list members of seeing the dialog. if you click Reply All, unless you make the effort to delete the poster's address, they are going to get double postings. I do not understand the reluctance of the monitors to make this change. sigh Al Hospers CamberSoft, Inc. alatcambersoftdotcom http://www.cambersoft.com A famous linguist once said: There is no language wherein a double positive can form a negative. YEAH, RIGHT -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
Re: Different reply-to?
On Wed, Jun 27, 2001 at 01:18:37PM +0100, Gary Stainburn wrote: : I thought that the moderators had asked for these threads to be ceased. Yes, we have. This will be the last and final message on the subject. :) : The number of emails on this topic, along with the ones on unsubscribing is : getting unbelievable - I know, I've just $cout++'d this. : : I am on more lists than is good for me, and while some do add a prefix to the : subject other don't. It doesn not make any differece to me. *NONE* of them : have 'reply-to-list' set. This also does not cause me a problem. As I have voiced in the beginners-workers group, we all have to remember that the beginners lists are set up exactly the same way as the 100+ other Perl lists on perl.org. We will not be helping anybody, especially the beginners that want to explore further, by changing the way these lists work. The beginners-workers folks have decided that the best solution is education. We are going to be documenting how to filter @perl.org mailing lists for as many MUAs as we can get our hands on. Please, if you feel like doing this, send your documentation to [EMAIL PROTECTED] : Please please PLEASE can we now stop these threads and let the list get on : with what it's supposed to do which is help perl beginners get on with : productive stuff. Amen. It is finished. :) Casey West -- Shooting yourself in the foot with Pascal Same as Modula-2 except that the bullet is not the right type for the gun and your hand is blown off.
ENV $HOME
Hello, Adam Theo here; i am looking for a way my perl program can automatically get the home directory of the user. i have come accross the ENV module, and think it will work, but wish to know if it is a standard module with all perl distributions? linux, windows, mac, etc? also, what does ENV do for windows and mac users, since those are not typically milti-user OSes? and finally, while i have found the ENV, does anyone know of a better way to do this? thank you for your time. -- /\ Theoretic Solutions (www.Theoretic.com): //\\'Activism, Software, and Internet Services' //--\\ Personal Homepage (www.Theoretic.com/adamtheo/): ][ 'Personal history, analysis, and favorites' ][ Birthright Online (www.Birthright.net): 'Keeping the best role-playing game alive' Email Jabber: Other: -Professional: [EMAIL PROTECTED] -AIM: AdamTheo2000 -General: [EMAIL PROTECTED] -ICQ: 3617307 -Personal: [EMAIL PROTECTED] -Phone: (850)8936047
Re: Re: types of datas
On Wed, Jun 27, 2001 at 01:15:05PM +0800, Exile wrote: The problem is that when I compare the first and the second value: If they're really equals, the program say they are'nt. Notice really equals. I will be getting back to it. Is ther a function to convert a value into an integer ? You're comparing $a to $b using the regex operator. Well, it's not all right, but half. Not $a to $b only, but $b to $a also. In case, I suppose everybody should know use eq to compair string... I just suggest another way, which not costing too much line. As a CGI comparing habit, input a data twice is mostly in PASSWORD or E-MAIL, use double =~ is visually help. I can't really make this out. As far as I can tell, you're trying to say you need to compare $a to $b, as well as $b to $a. Reversing the order of the operands in an eq comparison gains nothing; reversing the order of operands in a =~ comparison changes the meaning around entirely. I don't understand the paragraph about CGI at all. $a eq $b is not equivalent to $a =~ $b, or $b =~ $a, or even both. What if $a = [f] and $b = f? Remember what I pointed out above, with him wanting really equals? Your comparison, $a =~ $b $b =~ $a would state $a and $b are equal. Now, what if $a = (foo? Suddenly, your comparison causes a fatal error. int is not for converting a string to an integer. Anybody mension that value in terms of a string? Couldn't it be a real number? You're right, he didn't mention that the value was a string. It could be a real number. The likelihood, however, that he would neglect to mention this detail is pretty low. Generally, converting from a float to an integer is called rounding not converting. In case, if a string is visually an interger number / real number , there is no need to convert, right? $x = 10.5; print ($x - 10) will output as 0.5, right? Yes, it will. There are two conversions involved here; one from the string 10.5 to the float 10.5, then from the number 0.5 to the string 0.5. I'm not sure what your point is, though. Unless returning an ASCII sort, I don't think there is any needs to convert a string to integer, right? You can't subtract the number 10 from the string 10.5, one value has to be converted to the other value's type, or they both have to be converted to some common type. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com --
Re: ENV $HOME
On Wed, Jun 27, 2001 at 02:37:55AM -0400, Adam Theo wrote: i am looking for a way my perl program can automatically get the home directory of the user. There is, of course, the HOME environmental variable. There is also (getpwuid $)[7], which gets the home directory from the password database, using the current UID. There are variations, such as (getpwnam $ENV{LOGNAME})[7] and (getpwnam $ENV{USER})[7]. i have come accross the ENV module, and think it will work, but wish to know if it is a standard module with all perl distributions? It is. Env.pm is just a way for turning environmental variables into global variables. You can get to the values through the %ENV hash. linux, windows, mac, etc? also, what does ENV do for windows and mac users, since those are not typically milti-user OSes? and finally, while i have found the ENV, does anyone know of a better way to do this? thank you for your time. I know Windows has environmental variables, and Perl can get to them. I'm not sure if $ENV{HOME} will have a sane value, or any value at all. There is no real concept of a home directory anyways, unless you count the primary hard drive, aka C. You could probably get away with checking $^O for some variation on Win32 and hard-coding your home directory based on that. I can't help you with Mac, though Mac also doesn't have a concept of home directory (AFAIK), so doing the bit with $^O would probably work there as well. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com --
compare the size of some files ...
I want to do this : - get the size of some files with stat - compare these sizes with some variables - copy the good files if the size doesn't match ...
Re: Variable scope
I think I see where Geraint is coming from, but a my'd variable is the only type of variable that is NOT a global, using the term as it is used in official perl documentation. Must have missed that part - you learn something new every minute with this list ; )
Re: Debugging the CGI - Application
Simple approach: sub Debug($) { my($sMessage) = @_; open(DEBUG, debug.txt) || die(Couldn't open debug file $!); print $sMessage\n; close DEBUG; } Debug(This is a debug message); then you can read your messages after you've run the program. I do that a lot when developing websites, as I do a lot of dynamic generation of pages that make heavy use of style sheets and positioning, etc. Debugging prints to the browser screw up the look, which is sometimes the thing I'm trying to get debugged, or they may break the page altogether. At 12:02 27.06.2001 +0800, Rajeev Rumale wrote: Thanks again. Thats a very Nice piece of information ? But unfortunatelly I am using IIS on Win2k platform. I still condsider it as a very useful and important piece of information on this list. with regards Rajeev Rumale ~~~ Rajeev Rumale MyAngel.Net Pte Ltd.,Phone : (65)8831530 (office) #04-01, 180 B, The Bencoolen, Email : [EMAIL PROTECTED] Bencoolen Street, Singapore - 189648 ICQ: 121001541 Website : www.myangel.net ~~~ - Original Message - From: Me [EMAIL PROTECTED] To: Rajeev Rumale [EMAIL PROTECTED]; 'Beginner Perl' [EMAIL PROTECTED] Sent: Wednesday, June 27, 2001 11:13 AM Subject: Re: Debugging the CGI - Application Any more suggestion ? If you are allowed to modify your web server's setup, then: http://www.masonhq.com/docs/manual/Mason.html and prepare for your world to be turned upside down... Aaron Craig Programming iSoftitler.com
Re: removing white space
Has anyone used the whitespace module. I downloaded it from CPAN but I couldn't get it to work for me at all. YM
Re: Finding @INC
Hello Dennis, Tuesday, June 26, 2001, Dennis Fox [EMAIL PROTECTED] wrote: DF My difficulty is that I don't understand how to modify @INC to DF include the non-standard locations, so that I don't have to have the user DF supply commandline arguments each time the script is needed. example: if ( $OS ne NT ) { BEGIN { unshift(@INC,/usr/local/etc); } require config.backup.pl; } Best wishes, Maximmailto:[EMAIL PROTECTED]
Re: checking groups on unix
Hello Joni, Wednesday, June 27, 2001, PURMONEN, Joni [EMAIL PROTECTED] wrote: PJ I need to check the group status on numerous files/directories, and haven't PJ been able to fing out the best way to do it with perl. I simply need to see PJ if some directories do not have certain group set on them. PJ Can anyone give any pointers? if i correctly understand, you need 'stat' function. ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat($filename); perldoc -f stat Best wishes, Maximmailto:[EMAIL PROTECTED]
Re: checking groups on unix
How to build @files is left as an exercise for the reader. code foreach my $file (@files) { #getgrpid returns the group file entry for a given group id. my $groupname = (getgrgid((stat($file))[5]))[0]; if ($groupname != groupname) { print $file has bad groupname: $groupname\n; } } /code On 27 Jun 2001 09:59:07 +0100, PURMONEN, Joni wrote: Hi ya, I need to check the group status on numerous files/directories, and haven't been able to fing out the best way to do it with perl. I simply need to see if some directories do not have certain group set on them. Can anyone give any pointers? Cheers, Joni Ps. I only have learning perl and some other fairly simple books which didn't seem to have anything useful in them -- Today is Pungenday, the 32nd day of Confusion in the YOLD 3167 This statement is false.
Re: Finding @INC
On Wed, 27 Jun 2001, Maxim Berlin [EMAIL PROTECTED] wrote, Hello Dennis, Tuesday, June 26, 2001, Dennis Fox [EMAIL PROTECTED] wrote: DF My difficulty is that I don't understand how to modify @INC to DF include the non-standard locations, so that I don't have to have the user DF supply commandline arguments each time the script is needed. example: if ( $OS ne NT ) { BEGIN { unshift(@INC,/usr/local/etc); } require config.backup.pl; } The BEGIN blocks always execute first no matter where you put them. #!/usr/bin/perl -w print __LINE__, : Am I the first?\n; if (1) { BEGIN { print __LINE__, : No, I am the one\n; } print __LINE__, : Then I am the last\n; } __END__ 7: No, I am the one 3: Am I the first? 9: Then I am the last -- s::a::n-http(www.trabas.com)
Windows Background Process
Hello, I need to start an external program from my perl script. This program will need to run in the background so my script can continue doing other things. It also still needs to notify the program when it terminates. I would appreciate any help on how I would do this. My environment is Windows NT 4.0, with Activestate perl 5.6.1. I'm also not sure how Windows runs a background process, so any tips there would be appreciated. Lastly, I've been monitoring this list for a few weeks now. It has been extremely helpful in getting me started with Perl. Thank you to everyone involved. Tina Ouellette __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/
Re: Finding @INC
Please use the the 'use lib' pragma, rather then fiddling with @INC concider: use lib (../foo); rather than: BEGIN: { push @INC, '../foo' } perldoc lib for more info hth Jos Boumans Maxim Berlin wrote: Hello Dennis, Tuesday, June 26, 2001, Dennis Fox [EMAIL PROTECTED] wrote: DF My difficulty is that I don't understand how to modify @INC to DF include the non-standard locations, so that I don't have to have the user DF supply commandline arguments each time the script is needed. example: if ( $OS ne NT ) { BEGIN { unshift(@INC,/usr/local/etc); } require config.backup.pl; } Best wishes, Maximmailto:[EMAIL PROTECTED]
Telnet Tucow's ?
Hi All, I am starting to write bits of easy peasy code today and basically I want to know where to start, I checked the perl web site and they suggest telneting to TUCOW'S, Anyone ever heard of this and whats it like ? Or am I better off just using Unix on my PC ? Thanks, Elaine.
RE: Telnet Tucow's ?
If you're starting to learn Perl. Take a look at this site. It might be a better starting point than trying to write a script to telnet to a website. http://www.netcat.co.uk/rob/perl/win32perltut.html HTH John -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: 27 June 2001 12:06 To: [EMAIL PROTECTED] Subject: Telnet Tucow's ? Hi All, I am starting to write bits of easy peasy code today and basically I want to know where to start, I checked the perl web site and they suggest telneting to TUCOW'S, Anyone ever heard of this and whats it like ? Or am I better off just using Unix on my PC ? Thanks, Elaine. --Confidentiality--. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system.
Re[2]: Finding @INC
Hello Jos, Wednesday, June 27, 2001, Jos Boumans [EMAIL PROTECTED] wrote: JB Please use the the 'use lib' pragma, rather then fiddling with @INC JB concider: JB use lib (../foo); JB rather than: JB BEGIN: { push @INC, '../foo' } JB perldoc lib for more info according to perldoc lib: use lib LIST; is almost the same as saying BEGIN { unshift(@INC, LIST) } For each directory in LIST (called $dir here) the lib mod- ule also checks to see if a directory called $dir/$arch- name/auto exists. If so the $dir/$archname directory is assumed to be a corresponding architecture specific direc- tory and is added to @INC in front of $dir. for my configs, i don't need (and don't have) $dir/$archname/auto directories, so i still use BEGIN { unshift(@INC,/usr/local/etc); } am i wrong? Best wishes, Maximmailto:[EMAIL PROTECTED]
Re: checking groups on unix
Check out the stat function -- it returns a long list of info., which will be of use to you: perl -e ' @list=stat(.); foreach(@list){printf %o \n,$_;} ' The printf %o part prints the value in octal, which is what you're after. The 3rd value in the returned array $list[2] is the mode. on my linux box, I get this output: 1406 644042 40775 27 1046 12 0 4000 7316040631 7315775540 7315775540 1 4 The 3rd element is the mode...775. ls -ald . shows: drwxrwxr-x 23 mcauthor wheel2048 Jun 25 23:02 Hope this helps. perldoc -f stat will give you all the nitty gritty on the rest. Chances are good your script will return much more useful information than you initially thought! Matt --- PURMONEN, Joni [EMAIL PROTECTED] wrote: Hi ya, I need to check the group status on numerous files/directories, and haven't been able to fing out the best way to do it with perl. I simply need to see if some directories do not have certain group set on them. Can anyone give any pointers? Cheers, Joni Ps. I only have learning perl and some other fairly simple books which didn't seem to have anything useful in them __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/
Printf
I can not get the printf to print, using the following relevant line of code: printf sortcode $fields[0],$fields[5],$fields[70],fields[77]; I am missing something in-between; sortcode *$fields[0] I have tried different things but had no luck! PS Your help would be much appreciated. Thanks, GD
Re: Finding @INC
because push @INC is a runtime statement, use lib is a compile time statement meaning you'll be alerted if the dir doesnt exist, or something else goes wrong at the moment you start your script, rather then it dying half way when not findin a file. hth Jos Boumans Maxim Berlin wrote: Hello Jos, Wednesday, June 27, 2001, Jos Boumans [EMAIL PROTECTED] wrote: JB Please use the the 'use lib' pragma, rather then fiddling with @INC JB concider: JB use lib (../foo); JB rather than: JB BEGIN: { push @INC, '../foo' } JB perldoc lib for more info according to perldoc lib: use lib LIST; is almost the same as saying BEGIN { unshift(@INC, LIST) } For each directory in LIST (called $dir here) the lib mod- ule also checks to see if a directory called $dir/$arch- name/auto exists. If so the $dir/$archname directory is assumed to be a corresponding architecture specific direc- tory and is added to @INC in front of $dir. for my configs, i don't need (and don't have) $dir/$archname/auto directories, so i still use BEGIN { unshift(@INC,/usr/local/etc); } am i wrong? Best wishes, Maximmailto:[EMAIL PROTECTED]
RE: Printf
Govinderjit Dhinsa [mailto:[EMAIL PROTECTED]] wrote: I can not get the printf to print, using the following relevant line of code: printf sortcode $fields[0],$fields[5],$fields[70],fields[77]; I am missing something in-between; sortcode *$fields[0] Is sort code a filehandle (i.e. obtained from open)? If not then you need a comma (argument separator) and some prefix to sortcode if it is a variable. Or do you want: printf sortcode $fields[0]$fields[5]$fields[70]fields[77]; ? Richard Cox Senior Software Developer Dell Technology Online All opinions and statements mine and do not in any way (unless expressly stated) imply anything at all on behalf of my employer
Re: Srting matching again
Hasanuddin Tamir wrote: On Tue, 26 Jun 2001, Yvonne Murphy [EMAIL PROTECTED] wrote, snip if ($mymatch =~ m/\'(.+)\;/gis) { #matches anything between the single ^^ snip But the problem occurs when I add this into a bigger code segment, it just goes crazy! And seems to match te complete opposite. And ideas? You seem to be bitten by the greedy match. By default, the quantifiers (such as + and *) will match as many as possible. You need the ? to suppress the greed behaviour. This ? is different form the ? used to optional unit. $_ = 'first; second;; print $1, \n if /'(.+);/; # first; second print $1, \n if /'(.+?);/; # first Btw, /gis seems redundant to me. So do the backslases. hth; __END__ -- s::a::n-http(www.trabas.com) The data in the functions2.log file takes the following format: 'fdecls' = ARRAY(0x80e53c0) 0 'int fibonacci(int degree);' 1 'int towerOfHanoiMoves(int numOfDisks);' 2 'void xyzzy(char* easterEgg);' 3 'char* interesting();' 4 'extern void system_alarm_run(int *alarm);' 5 'extern void system_alarm_pause(int *alarm);' 6 'extern int *system_timer_new( unsigned long tag );' 7 'extern int *system_timer_callback_new( void (*callback_function) (unsigned long tag), unsigned long tag );' 8 'int system_timer_start( int * timer, long time );' 9 'longsystem_timer_pause( int * timer );' 10 'int system_timer_stop( int * timer );' 11 'int system_timer_del( int * timer );' And I need to remove the actual function declaration and assign each of the words to variables, such as, $return_type, $function_name, etc. Is that any clearer? Thanks, YM
Joining variables
Hi Perl guys I have another problem: I have three variables working: $var1 $var2 #and $var3 I want to join these three variables in a new one, with some formar, something like that: $newvar will be $var1-$var2-$var3 for example if: $var1=2000 $var2=08 #and $var3=15 then $newvar=2000-08-15 I hope someone can help me Thanks in advances DiegoM
RE: Joining variables
This wouldn't be homework by any chance??? -Original Message- From: Diego Riaño [mailto:[EMAIL PROTECTED]] Sent: 27 June 2001 13:59 To: [EMAIL PROTECTED] Subject: Joining variables Hi Perl guys I have another problem: I have three variables working: $var1 $var2 #and $var3 I want to join these three variables in a new one, with some formar, something like that: $newvar will be $var1-$var2-$var3 for example if: $var1=2000 $var2=08 #and $var3=15 then $newvar=2000-08-15 I hope someone can help me Thanks in advances DiegoM --Confidentiality--. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system.
Re: PostgreSQL DBD setup
On Wednesday 27 June 2001 2:08 pm, Geraint Jones wrote: I've just spent a frustrating few hours looking for the answer to my problem and have decided to give up and ask you guys. The docs for the Perl module DBD-Pg-1.00 say I should set the following environment variables: POSTGRES_INCLUDE and POSTGRES_LIB. The problem is, being a Linux newbie I don't know where environment variables are stored. Geraint. No worries, just found out! That's my headache gone : ) # export POSTGRES_INCLUDE=path Geraint.
Re: Joining variables
On Wed, Jun 27, 2001 at 02:07:22PM +0100, Pierre Smolarek wrote: $newvar = $var1.-.$var2.-.$var3; or $newvar = $var1-$var2-$var3;
Re: Joining variables
$newvar = $var1.-.$var2.-.$var3; - Original Message - From: John Edwards [EMAIL PROTECTED] To: 'Diego Riaño' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, June 27, 2001 2:01 PM Subject: RE: Joining variables This wouldn't be homework by any chance??? -Original Message- From: Diego Riaño [mailto:[EMAIL PROTECTED]] Sent: 27 June 2001 13:59 To: [EMAIL PROTECTED] Subject: Joining variables Hi Perl guys I have another problem: I have three variables working: $var1 $var2 #and $var3 I want to join these three variables in a new one, with some formar, something like that: $newvar will be $var1-$var2-$var3 for example if: $var1=2000 $var2=08 #and $var3=15 then $newvar=2000-08-15 I hope someone can help me Thanks in advances DiegoM --Confidentiality--. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system.
Re: Srting matching again
Hello Yvonne, Tuesday, June 26, 2001, Yvonne Murphy [EMAIL PROTECTED] wrote: YM But the problem occurs when I add this into a bigger code segment, it YM just goes crazy! And seems to match te complete opposite. can you describe what exctly happened and can you show your bigger code segment? Best wishes, Maximmailto:[EMAIL PROTECTED]
Re: Joining variables
On Wed, Jun 27, 2001 at 02:07:22PM +0100, Pierre Smolarek wrote: $newvar = $var1.-.$var2.-.$var3; or $newvar = $var1-$var2-$var3; or $concat = '-'; $newvar .= $var1; $newvar .= $concat; $newvar .= $var2; $newvar .= $concat; $newvar .= $var3; dude, you should really look this up in a book.. its pre-basic perl
FW: FW: rmdir
-Original Message- From: Porter, Chris Sent: Wednesday, June 27, 2001 9:21 AM To: 'Maxim Berlin' Subject: RE: FW: rmdir Hi, It's working great. Thank you. But one more thing, it's removing all the empty directories but what about directories with files in them. It errors out when it hits a directory with files in it. I have just files in this directory that I don't want to delete. I only want to delete the directories with Capital letters and the files in them. Thank you for any help or ideas. Chris -Original Message- From: Maxim Berlin [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 26, 2001 10:07 AM To: '[EMAIL PROTECTED]' Subject: Re: FW: rmdir Hello Chris, Tuesday, June 26, 2001, Porter, Chris [EMAIL PROTECTED] wrote: PC It's me again, still won't work. Here is the whole script: PC Again, any help would be great. Well, script works correct now. May be you try to rmdir not empty subdirs? c:\perldoc -f rmdir rmdir FILENAME rmdir Deletes the directory specified by FILENAME if that directory is empty. If it succeeds it returns TRUE, otherwise it returns FALSE and sets `$!' (errno). If FILENAME is omitted, uses `$_'. you can avoid many troubles, if you check return codes, like this: rmdir $Name or die $!; PC chdir /u131/tmp or die $!; PC opendir(HERE, '.'); PC @AllFiles = readdir(HERE); PC foreach $Name (@AllFiles) { PCif (-f $Name) {next} PCif ((-d $Name) and ($Name =~ /^[A-Z]+$/)) {rmdir $Name} PCif ((-d $Name)) {print $Name\n} PC} Best wishes, Maximmailto:[EMAIL PROTECTED]
Re: PostgreSQL DBD setup
Had just yesterday the same problem. Did not get DBD::Pg working using it with Suse Linux 7.0 Postgres RPM Distribution. It might be easier to use Postgres source distribution instead of using a RPM distribution. After compiling Postgres as described in the INSTALL file i had to set the environment variables as follows: export POSTGRES_INCLUDE=/usr/local/pgsql/include export POSTGRES_LIB=/usr/local/pgsql/lib In the same terminal session you should run the installation process of DBD::Pg. Good Luck! Ulle - Original Message - From: Geraint Jones [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, June 27, 2001 3:08 PM Subject: PostgreSQL DBD setup I've just spent a frustrating few hours looking for the answer to my problem and have decided to give up and ask you guys. The docs for the Perl module DBD-Pg-1.00 say I should set the following environment variables: POSTGRES_INCLUDE and POSTGRES_LIB. The problem is, being a Linux newbie I don't know where environment variables are stored. Geraint.
Re: Printf
printf has the f on the end because it expects a format string. If you are on a unix box try typing man 3 printf. This shows you the docs for C's printf, but since perl's printf is does a straight pass thorugh to C's printf that shouldn't matter. Try this in your code: printf sortcode %s %s %s %s\n, $fields[0], $fields[5], $fields[70], fields[77]; The big question I have is why are you using printf? Printf should only used when you care very much about how the output is formated (ie printing only two decimal places on a number). snip href=perldoc -f printf Don't fall into the trap of using a printf when a simple print would do. The print is more efficient and less error prone. /snip On 27 Jun 2001 13:11:46 +0100, Govinderjit Dhinsa wrote: I can not get the printf to print, using the following relevant line of code: printf sortcode $fields[0],$fields[5],$fields[70],fields[77]; I am missing something in-between; sortcode *$fields[0] I have tried different things but had no luck! PS Your help would be much appreciated. Thanks, GD -- Today is Pungenday, the 32nd day of Confusion in the YOLD 3167 Frink!
Re: Joining variables
On 27 Jun 2001 14:37:14 +0100, Pierre Smolarek wrote: On Wed, Jun 27, 2001 at 02:07:22PM +0100, Pierre Smolarek wrote: $newvar = $var1.-.$var2.-.$var3; or $newvar = $var1-$var2-$var3; or $concat = '-'; $newvar .= $var1; $newvar .= $concat; $newvar .= $var2; $newvar .= $concat; $newvar .= $var3; dude, you should really look this up in a book.. its pre-basic perl or $newvar = join -, ($var1, $var2, $var3); TMTOWTDI -- Today is Pungenday, the 32nd day of Confusion in the YOLD 3167 Wibble.
To replace a string with another
Hi. I want to replace the String %0A by nothing. I'm using this line: $description=~tr/%0A//; But nothing change. What is my problem ? tks
RE: To replace a string with another
Try escaping the % symbol. $description=~tr/\%0A//; See this link for an explanation. http://www.netcat.co.uk/rob/perl/win32perltut.html#38-Escaping -Original Message- From: Stéphane JEAN BAPTISTE [mailto:[EMAIL PROTECTED]] Sent: 27 June 2001 15:12 To: PERL Subject: To replace a string with another Hi. I want to replace the String %0A by nothing. I'm using this line: $description=~tr/%0A//; But nothing change. What is my problem ? tks --Confidentiality--. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system.
Re: To replace a string with another
On 27 Jun 2001 16:11:56 +0200, Stéphane JEAN BAPTISTE wrote: Hi. I want to replace the String %0A by nothing. I'm using this line: $description=~tr/%0A//; But nothing change. What is my problem ? tks tr is not what you want. tr replaces characters with other characters. You want s: $desc =~ s/%0A//g; -- Today is Pungenday, the 32nd day of Confusion in the YOLD 3167 You are what you see.
Re: To replace a string with another
Stéphane JEAN BAPTISTE a écrit : Hi. I want to replace the String %0A by nothing. I'm using this line: $description=~tr/%0A//; But nothing change. What is my problem ? tks PS: There is'nt only 1 string but a lot.
Re: Re[2]: Finding @INC
Maxim == Maxim Berlin [EMAIL PROTECTED] writes: Maxim for my configs, i don't need (and don't have) Maxim $dir/$archname/auto directories, so i still use BEGIN { unshift(@INC,/usr/local/etc); } Maxim am i wrong? You are typing too much. In a code review, I'd flag that as a warning item, as in why does he open-code a standard use-lib? It's more typing, less functionality, and makes me wonder if there's some reason you *couldn't* have done it the standard way, as in you had an arch directory that you *didn't* want installed. Now, if there's something else inside that BEGIN block, like: BEGIN { $dir = $DEBUG ? /my/private/dir : /usr/local/etc; unshift @INC, $dir; } then you're perfectly entitled to your BEGIN block. But not when it's standalone. That wouldn't be a fatal in a code review (unless it was inside a conditional, as I said in my other message), but it's flagged as a warning fix. Never open-code something... people smell trouble. Sorry, 24 years of professional programming and a half-dozen years before that of tinkering have lead me to some pretty stiff ideas about how people can screw up when maintaining your code, and I'm probably not gonna budge on that. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Re: still: using fetchrow_hashref()
Thanks tried the row count with SELECT COUNT(*) and it works perfectly Thanks a lot
getopt:std questions
Hello everyone, Here's a section of code: my %options; my $u; use strict; use Getopt::Std; getopts(dwmyau:, \%options); How can I get the value of the '-u' option and print it to the screen? I've tried this: $u = $options{u}; print $u; but that doesn't work...it doesn't print anything. Can anybody shed some light on this for me? Thanks, Tyler Longren
Re: still: using fetchrow_hashref()
Remember that count(*) will only work in those cases where nothing gets inserted in the time between the two select statements. You may experience odd bugs. Comment the area around this code well. On 27 Jun 2001 16:20:29 +0200, Marcus Willemsen wrote: Thanks tried the row count with SELECT COUNT(*) and it works perfectly Thanks a lot -- Today is Pungenday, the 32nd day of Confusion in the YOLD 3167 Pzat!
AW: getopt:std questions
I use it like this ( checking program options ): my $usage = $0 -s servdata -u userdata -b begtime -e endtime -f params\n; my %opts; getopts('b:e:s:u:f:', \%opts); my $servdata = $opts{s}; my $userdata = $opts{u}; my $begtime = $opts{b}; my $endtime = $opts{e}; my $reqdata = $opts{f}; Cheers, Ela -Ursprüngliche Nachricht- Von: Tyler Longren [mailto:[EMAIL PROTECTED]] Gesendet: Mittwoch, 27. Juni 2001 16:24 An: Perl Beginners Betreff: getopt:std questions Hello everyone, Here's a section of code: my %options; my $u; use strict; use Getopt::Std; getopts(dwmyau:, \%options); How can I get the value of the '-u' option and print it to the screen? I've tried this: $u = $options{u}; print $u; but that doesn't work...it doesn't print anything. Can anybody shed some light on this for me? Thanks, Tyler Longren
Re: getopt:std questions
Ahh..that worked wonderfully. Thank you very much! Tyler - Original Message - From: Ela Jarecka [EMAIL PROTECTED] To: 'Tyler Longren' [EMAIL PROTECTED] Cc: Beginners list (E-Mail) [EMAIL PROTECTED] Sent: Wednesday, June 27, 2001 9:39 AM Subject: AW: getopt:std questions I use it like this ( checking program options ): my $usage = $0 -s servdata -u userdata -b begtime -e endtime -f params\n; my %opts; getopts('b:e:s:u:f:', \%opts); my $servdata = $opts{s}; my $userdata = $opts{u}; my $begtime = $opts{b}; my $endtime = $opts{e}; my $reqdata = $opts{f}; Cheers, Ela -Ursprüngliche Nachricht- Von: Tyler Longren [mailto:[EMAIL PROTECTED]] Gesendet: Mittwoch, 27. Juni 2001 16:24 An: Perl Beginners Betreff: getopt:std questions Hello everyone, Here's a section of code: my %options; my $u; use strict; use Getopt::Std; getopts(dwmyau:, \%options); How can I get the value of the '-u' option and print it to the screen? I've tried this: $u = $options{u}; print $u; but that doesn't work...it doesn't print anything. Can anybody shed some light on this for me? Thanks, Tyler Longren
Incrementing Strings
If I define a variable as a string my $var = a; I can get the increment to work print ++$var; -- prints b but the decrement print --$var -- prints -1 Why? and how can I decrement it? Thanks, -Nick _ Get your FREE download of MSN Explorer at http://explorer.msn.com
Re: Incrementing Strings
On Jun 27, Nick Transier said: If I define a variable as a string my $var = a; I can get the increment to work print ++$var; -- prints b but the decrement print --$var -- prints -1 Why? and how can I decrement it? The perlop documentation says that ++ is magical for strings, but that -- isn't. The reason is because there's not a clear-cut way of defining it. What is 'a'--? -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun. Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/ Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/ Acacia Fraternity, Rensselaer Chapter. Brother #734 ** Manning Publications, Co, is publishing my Perl Regex book **
Re: Incrementing Strings
On Wed, Jun 27, 2001 at 10:55:54AM -0400, Jeff 'japhy' Pinyan ([EMAIL PROTECTED]) spew-ed forth: On Jun 27, Nick Transier said: The perlop documentation says that ++ is magical for strings, but that -- isn't. The reason is because there's not a clear-cut way of defining it. What is 'a'--? Is that the reason? I would think --'a' would be z, but that is my own internal logic :) But, why is --'a' (or any a-zA-Z) -1? Why doesn't, at least, it evaluate 'a' to true (1) and --'a' = 0 (or undef, since I don't know why it should return a true value)? I guess there must be a reason, but it isn't documented from what I can see. Cheers, Kevin -- [Writing CGI Applications with Perl - http://perlcgi-book.com] I know the human being and fish can coexist peacefully. -- G.W. Bush, Saginaw, MI 09/29/2000
Re: Incrementing Strings
--- Nick Transier [EMAIL PROTECTED] wrote: If I define a variable as a string my $var = a; I can get the increment to work print ++$var; -- prints b but the decrement print --$var -- prints -1 Why? and how can I decrement it? Incrementing strings is magic that isn't implemented backwards. In other words, you can't decrement a string. From perldoc perlop: === Auto-increment and Auto-decrement ``++'' and ``--'' work as in C. That is, if placed before a variable, they increment or decrement the variable before returning the value, and if placed after, increment or decrement the variable after returning the value. The auto-increment operator has a little extra builtin magic to it. If you increment a variable that is numeric, or that has ever been used in a numeric context, you get a normal increment. If, however, the variable has been used in only string contexts since it was set, and has a value that is not null and matches the pattern /^[a-zA-Z]*[0-9]*$/, the increment is done as a string, preserving each character within its range, with carry: print ++($foo = '99'); # prints '100' print ++($foo = 'a0'); # prints 'a1' print ++($foo = 'Az'); # prints 'Ba' print ++($foo = 'zz'); # prints 'aaa' The auto-decrement operator is not magical. __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/
to delete the trailing newline
I have a variable and I want to write it into a textarea (HTML). The problem is when I look at the textarea in my HTML page, there is the text I want, plus a trailing newline. How can I delete this. My variable: $texte=wazaa; In textarea: wazza tks Sorry for my english steph
Re: Incrementing Strings
On Wed, Jun 27, 2001 at 11:07:12AM -0400, Kevin Meltzer wrote: On Wed, Jun 27, 2001 at 10:55:54AM -0400, Jeff 'japhy' Pinyan ([EMAIL PROTECTED]) spew-ed forth: On Jun 27, Nick Transier said: The perlop documentation says that ++ is magical for strings, but that -- isn't. The reason is because there's not a clear-cut way of defining it. What is 'a'--? Is that the reason? I would think --'a' would be z, but that is my own internal logic :) But ++'z' isn't 'a'. But, why is --'a' (or any a-zA-Z) -1? Why doesn't, at least, it evaluate 'a' to true (1) and --'a' = 0 (or undef, since I don't know why it should return a true value)? I guess there must be a reason, but it isn't documented from what I can see. Converting 'a' to a number gives 0. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net
Converting Unix paths to windows
Hi, I am writing a script to be used on Windows and many different flavors of Unix. I am looking for a good way to convert Unix paths to Windows. Any Ideas? Thanks, Daryl J. Hoyt Performance Engineer Geodesic Systems http://www.geodesic.com [EMAIL PROTECTED]
Re: Incrementing Strings
On Wed, 27 Jun 2001, Paul wrote: The auto-decrement operator is not magical. The Camel Book adds that there are not any plans to make it magical. -- Brett http://www.chapelperilous.net/btfwk/ Women, when they have made a sheep of a man, always tell him that he is a lion with a will of iron. -- Honor'e de Balzac
Re: to delete the trailing newline
On Wed, 27 Jun 2001, Stéphane JEAN BAPTISTE wrote: I have a variable and I want to write it into a textarea (HTML). The problem is when I look at the textarea in my HTML page, there is the text I want, plus a trailing newline. How can I delete this. My variable: $texte=wazaa; In textarea: wazza You can chomp off that trailing newline using 'chomp'. Weren't you the guy who was asking about it yesterday? -- Brett http://www.chapelperilous.net/btfwk/ This fortune intentionally says nothing.
Re: to delete the trailing newline
you might want to try to use 'chomp' on your variable... this function is specifically there to 'chomp off' trailing newlines you'll often see it used as: open FH, 'foo.txt'; while(FH){ chomp; #remove trailing newline do something } perldoc -f chomp for details hth, Jos Boumans Stéphane JEAN BAPTISTE wrote: I have a variable and I want to write it into a textarea (HTML). The problem is when I look at the textarea in my HTML page, there is the text I want, plus a trailing newline. How can I delete this. My variable: $texte=wazaa; In textarea: wazza tks Sorry for my english steph
Re: Incrementing Strings
On Wed, 27 Jun 2001, Paul Johnson wrote: Is that the reason? I would think --'a' would be z, but that is my own internal logic :) But ++'z' isn't 'a'. Technically, you can't do ++'z' because you are modifying a constant... but autoincrementing a variable whose value is 'z' will make it 'aa'. -- Brett http://www.chapelperilous.net/btfwk/ You will win success in whatever calling you adopt.
Re: Incrementing Strings
On Wed, Jun 27, 2001 at 06:21:30PM +0200, Paul Johnson ([EMAIL PROTECTED]) spew-ed forth: On Wed, Jun 27, 2001 at 11:07:12AM -0400, Kevin Meltzer wrote: Is that the reason? I would think --'a' would be z, but that is my own internal logic :) But ++'z' isn't 'a'. No, it is aa, the next logical thing to come after z. So, --a could be aa. or, to me, more logically z. But, I don't scream that my logic is always logical ;) But, why is --'a' (or any a-zA-Z) -1? Why doesn't, at least, it evaluate 'a' to true (1) and --'a' = 0 (or undef, since I don't know why it should return a true value)? I guess there must be a reason, but it isn't documented from what I can see. Converting 'a' to a number gives 0. I'm not convinced on that. Being that magic is built in to make a++ into b.. so it isn't being converted to 0 in that case, which would make that statement false. Why would it be 0? Why not 1? Why is 'b' also converted to 0? Why not use it's ord() value? To me (again, internal, warped, logic) --a returning ` makes more sense than -1. z++ is aa, so why isn't aa-- reverted back to z? Why must --a be seemingly useless? Cheers, Kevin -- [Writing CGI Applications with Perl - http://perlcgi-book.com] Families is where out nation finds hope, where wings take dream. -- G.W. Bush, LaCrosse, WI 10/18/2000
Re: to delete the trailing newline
Brett W. McCoy a écrit : On Wed, 27 Jun 2001, Stéphane JEAN BAPTISTE wrote: I have a variable and I want to write it into a textarea (HTML). The problem is when I look at the textarea in my HTML page, there is the text I want, plus a trailing newline. How can I delete this. My variable: $texte=wazaa; In textarea: wazza You can chomp off that trailing newline using 'chomp'. Weren't you the guy who was asking about it yesterday? Yes! But chomp delete it in perl but not the conversion in HTML.
Re: Incrementing Strings
does this all mean that c++ is ACTUALLY D ? hu. food for thought. Pierre - Original Message - From: Kevin Meltzer [EMAIL PROTECTED] To: Paul Johnson [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; Nick Transier [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, June 27, 2001 4:38 PM Subject: Re: Incrementing Strings On Wed, Jun 27, 2001 at 06:21:30PM +0200, Paul Johnson ([EMAIL PROTECTED]) spew-ed forth: On Wed, Jun 27, 2001 at 11:07:12AM -0400, Kevin Meltzer wrote: Is that the reason? I would think --'a' would be z, but that is my own internal logic :) But ++'z' isn't 'a'. No, it is aa, the next logical thing to come after z. So, --a could be aa. or, to me, more logically z. But, I don't scream that my logic is always logical ;) But, why is --'a' (or any a-zA-Z) -1? Why doesn't, at least, it evaluate 'a' to true (1) and --'a' = 0 (or undef, since I don't know why it should return a true value)? I guess there must be a reason, but it isn't documented from what I can see. Converting 'a' to a number gives 0. I'm not convinced on that. Being that magic is built in to make a++ into b.. so it isn't being converted to 0 in that case, which would make that statement false. Why would it be 0? Why not 1? Why is 'b' also converted to 0? Why not use it's ord() value? To me (again, internal, warped, logic) --a returning ` makes more sense than -1. z++ is aa, so why isn't aa-- reverted back to z? Why must --a be seemingly useless? Cheers, Kevin -- [Writing CGI Applications with Perl - http://perlcgi-book.com] Families is where out nation finds hope, where wings take dream. -- G.W. Bush, LaCrosse, WI 10/18/2000
Re: to delete the trailing newline
On Wed, 27 Jun 2001, Stéphane JEAN BAPTISTE wrote: You can chomp off that trailing newline using 'chomp'. Weren't you the guy who was asking about it yesterday? Yes! But chomp delete it in perl but not the conversion in HTML. Oh, I'm sorry! Perhaps you have a newline embedded in your script, like this: textarea$variable /textarea -- Brett http://www.chapelperilous.net/btfwk/ It'll be just like Beggars' Canyon back home. -- Luke Skywalker
Re: Joining variables
On 27 Jun 2001 10:06:28 -0400, Chas Owens wrote: On 27 Jun 2001 14:37:14 +0100, Pierre Smolarek wrote: On Wed, Jun 27, 2001 at 02:07:22PM +0100, Pierre Smolarek wrote: $newvar = $var1.-.$var2.-.$var3; or $newvar = $var1-$var2-$var3; or $concat = '-'; $newvar .= $var1; $newvar .= $concat; $newvar .= $var2; $newvar .= $concat; $newvar .= $var3; dude, you should really look this up in a book.. its pre-basic perl or $newvar = join -, ($var1, $var2, $var3); TMTOWTDI -- Today is Pungenday, the 32nd day of Confusion in the YOLD 3167 Wibble. or $newvar='';$newvar .= $_- foreach ($var1, $var2, $var3); chop $newvar; or $newvar = sprintf %04d-%02d-%02d, $var1, $var2, $var3; or $newvar =~ s/.*/$var1-$var2-$var3/; I think I need a life. -- Today is Pungenday, the 32nd day of Confusion in the YOLD 3167 Kallisti!
Re: Incrementing Strings
How do you mean? concider: if ('a' == 'b') { print foo } # this will print 'foo', seeing 'a' and 'b' both yield '1' in numeric context here. however $x = 'a'; print $x + 4; will print '4'; Jos Boumans Converting 'a' to a number gives 0. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net
Re: Incrementing Strings
On Wed, 27 Jun 2001, Pierre Smolarek wrote: does this all mean that c++ is ACTUALLY D ? No, c++ is ACTUALLY a pain in the butt to code... :-) -- Brett http://www.chapelperilous.net/btfwk/ Positive, adj.: Mistaken at the top of one's voice. -- Ambrose Bierce, The Devil's Dictionary
Re: Incrementing Strings
On 27 Jun 2001 17:45:18 +0200, Jos Boumans wrote: How do you mean? concider: if ('a' == 'b') { print foo } # this will print 'foo', seeing 'a' and 'b' both yield '1' in numeric context here. You mean 0 not 1 don't you? however $x = 'a'; print $x + 4; will print '4'; Jos Boumans Converting 'a' to a number gives 0. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- Today is Pungenday, the 32nd day of Confusion in the YOLD 3167 Kallisti!
Re: Converting Unix paths to windows
At 10:22 27.06.2001 -0500, Daryl Hoyt wrote: Hi, I am writing a script to be used on Windows and many different flavors of Unix. I am looking for a good way to convert Unix paths to Windows. Any Ideas? What do you mean exactly. If you just mean converting \ to / and getting rid of the drive you can do this: my $sPath = C:\\foo\\bar; $sPath =~ s/^[a-z]+://i; $sPath =~ s/\\/\//g; print $sPath; Aaron Craig Programming iSoftitler.com
Suggestions?
Greetings all - I realize this is a very broad question, however any suggestions would be appreciated. I'm looking to purchase good learning tools about programming in PERL. I've been programming with it for several years, but I've never truly learned the basics - just looked at other code and learned from that. Specifically I'd like to learn from ground zero about variables, hashes, etc. as well as MySQL connectivity. I'd like to find something that is concise - I have several projects that I'll be working on in the very near future, and fine-tuning my knowledge would be of great benefit. Again, any suggestions will be appreciated.
Re: Incrementing Strings
On Wed, Jun 27, 2001 at 11:51:01AM -0400, Chas Owens ([EMAIL PROTECTED]) spew-ed forth: On 27 Jun 2001 17:45:18 +0200, Jos Boumans wrote: How do you mean? concider: if ('a' == 'b') { print foo } # this will print 'foo', seeing 'a' and 'b' both yield '1' in numeric context here. You mean 0 not 1 don't you? # perl -wle 'print a ? Yes : no;' They are true values, 0 is false. It would also print 'foo' if it were 'a' == 'bb' (althoug warnings should yell at you for doing this :) If they yielded 0, it wouldn't print 'foo'. Cheers, Kevin -- [Writing CGI Applications with Perl - http://perlcgi-book.com] This Too Shall Pass -- inscription on the inside of King Solomon's Ring.
Re: Suggestions?
I learnt with Sams teach yourself perl in 21 days did teh trick here... from that i graped the basics and then got reference books like Programming perl, perl cookbook by oreilly I have an html version of Sams, which i can send to you by request, Pierre - Original Message - From: Bill Pierson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, June 27, 2001 4:57 PM Subject: Suggestions? Greetings all - I realize this is a very broad question, however any suggestions would be appreciated. I'm looking to purchase good learning tools about programming in PERL. I've been programming with it for several years, but I've never truly learned the basics - just looked at other code and learned from that. Specifically I'd like to learn from ground zero about variables, hashes, etc. as well as MySQL connectivity. I'd like to find something that is concise - I have several projects that I'll be working on in the very near future, and fine-tuning my knowledge would be of great benefit. Again, any suggestions will be appreciated.
Re: Joining variables
Just to make it longwinded: my $stuff = { $var1 = - , $var2 = - , $var3 = - }; my $newvar = ; $newvar .= $_$stuff-{$_} foreach keys %{ $stuff }; At 11:45 27.06.2001 -0400, Chas Owens wrote: On 27 Jun 2001 10:06:28 -0400, Chas Owens wrote: On 27 Jun 2001 14:37:14 +0100, Pierre Smolarek wrote: On Wed, Jun 27, 2001 at 02:07:22PM +0100, Pierre Smolarek wrote: $newvar = $var1.-.$var2.-.$var3; or $newvar = $var1-$var2-$var3; or $concat = '-'; $newvar .= $var1; $newvar .= $concat; $newvar .= $var2; $newvar .= $concat; $newvar .= $var3; dude, you should really look this up in a book.. its pre-basic perl or $newvar = join -, ($var1, $var2, $var3); TMTOWTDI -- Today is Pungenday, the 32nd day of Confusion in the YOLD 3167 Wibble. or $newvar='';$newvar .= $_- foreach ($var1, $var2, $var3); chop $newvar; or $newvar = sprintf %04d-%02d-%02d, $var1, $var2, $var3; or $newvar =~ s/.*/$var1-$var2-$var3/; I think I need a life. -- Today is Pungenday, the 32nd day of Confusion in the YOLD 3167 Kallisti! Aaron Craig Programming iSoftitler.com
RE: Converting Unix paths to windows
As a side note, you can still use forward slash / instead of \ in Windows. They are compatible with all internal Windows API. Reasons for this is the history prior to MS-DOS being born. -Robin -Original Message- From: Aaron Craig [SMTP:[EMAIL PROTECTED]] Sent: Wednesday, June 27, 2001 11:50 AM To: [EMAIL PROTECTED] Subject: Re: Converting Unix paths to windows At 10:22 27.06.2001 -0500, Daryl Hoyt wrote: Hi, I am writing a script to be used on Windows and many different flavors of Unix. I am looking for a good way to convert Unix paths to Windows. Any Ideas? What do you mean exactly. If you just mean converting \ to / and getting rid of the drive you can do this: my $sPath = C:\\foo\\bar; $sPath =~ s/^[a-z]+://i; $sPath =~ s/\\/\//g; print $sPath; Aaron Craig Programming iSoftitler.com
Re: Incrementing Strings
On Jun 27, Kevin Meltzer said: On Wed, Jun 27, 2001 at 11:51:01AM -0400, Chas Owens ([EMAIL PROTECTED]) spew-ed forth: On 27 Jun 2001 17:45:18 +0200, Jos Boumans wrote: How do you mean? concider: if ('a' == 'b') { print foo } # this will print 'foo', seeing 'a' and 'b' both yield '1' in numeric context here. You mean 0 not 1 don't you? # perl -wle 'print a ? Yes : no;' They are true values, 0 is false. Values that can not be converted to a numerical value have the value of 0 in numerical context. a is converted to 0 in numerical context, as are b, foobar, a1b2, and -d3. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun. Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/ Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/ Acacia Fraternity, Rensselaer Chapter. Brother #734 ** Manning Publications, Co, is publishing my Perl Regex book **
Re: Incrementing Strings
On Wed, Jun 27, 2001 at 12:04:53PM -0400, Jeff 'japhy' Pinyan ([EMAIL PROTECTED]) spew-ed forth: On Jun 27, Kevin Meltzer said: On Wed, Jun 27, 2001 at 11:51:01AM -0400, Chas Owens ([EMAIL PROTECTED]) spew-ed forth: On 27 Jun 2001 17:45:18 +0200, Jos Boumans wrote: How do you mean? They are true values, 0 is false. Values that can not be converted to a numerical value have the value of 0 in numerical context. a is converted to 0 in numerical context, as are b, foobar, a1b2, and -d3. Ugh... yes.. finger vs. brain RPMs aren't the same :) The 'evaluation' was true.. not the elements. Sorry folks.. my 1-screw-up-per-day quota has been met. However, I still think --a returning -1 is useless :) Cheers, Kevin -- [Writing CGI Applications with Perl - http://perlcgi-book.com] Nuclear explosions under the Nevada desert? What the f*ck are we testing for? We already know the sh*t blows up. -- Frank Zappa
Best practice for config file use?
I need to pass a number of parms to my program. Is there a best Practice for how to do this? Command line is not something I want to do. I did search on Config from search.cpan.org, but it returned 99 modules! Any suggestions? In the past, I have done it by hand, but... -- [EMAIL PROTECTED] Using The Bat! eMail v1.53d Windows NT 5.0.2195 (Service Pack 1) Why don't you ever see the headline Psychic Wins Lottery?
Re: Suggestions?
On 27 Jun 2001 11:57:49 -0400, Bill Pierson wrote: Greetings all - I realize this is a very broad question, however any suggestions would be appreciated. I'm looking to purchase good learning tools about programming in PERL. I've been programming with it for several years, but I've never truly learned the basics - just looked at other code and learned from that. Specifically I'd like to learn from ground zero about variables, hashes, etc. as well as MySQL connectivity. I'd like to find something that is concise - I have several projects that I'll be working on in the very near future, and fine-tuning my knowledge would be of great benefit. Again, any suggestions will be appreciated. Canon: Camel (_Programming Perl_ 3rd edition by Wall, et al) Llama (_Learning Perl_ 2nd edition by Schwartz) (3rd will be out soon) Should get: _Object Oriented Perl_ by Conway _Mastering Regular Expressions_ by Jeffrey E. F. Friedl _Perl Cookbook_ by Tom Christiansen Nathan Torkington Good depending on you job: _Programming the Perl DBI_ by Alligator Descartes Tim Bunce _Data Munging with Perl_ by David Cross I hear that Manning is putting out a regexp book written by someone on this list, but I can't remember his name (and am too lazy to search for it). -- Today is Pungenday, the 32nd day of Confusion in the YOLD 3167 Keep the Lasagna flying!
Re: Incrementing Strings
ok, long day, let me write it like it IS concider: if ('a' == 'b') { print foo } # this will print 'foo', seeing 'a' compared to 'b' yields '1' even in numeric context here (ie, the RETURN value of the compare, not the representation of the characters) sorry for the confusion and thanks for poining out the mistake Chas Owens wrote: On 27 Jun 2001 17:45:18 +0200, Jos Boumans wrote: How do you mean? concider: if ('a' == 'b') { print foo } # this will print 'foo', seeing 'a' and 'b' both yield '1' in numeric context here. You mean 0 not 1 don't you? however $x = 'a'; print $x + 4; will print '4'; Jos Boumans Converting 'a' to a number gives 0. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- Today is Pungenday, the 32nd day of Confusion in the YOLD 3167 Kallisti!
Re: Joining variables
So we have: $newvar = $var1.-.$var2.-.$var3; $newvar = $var1-$var2-$var3; $concat = '-'; $newvar .= $var1; $newvar .= $concat; $newvar .= $var2; $newvar .= $concat; $newvar .= $var3; $newvar = join -, ($var1, $var2, $var3); $newvar = join '', ($var1, '-', $var2, '-', $var3); #new varient $newvar='';$newvar .= $_- foreach ($var1, $var2, $var3); chop $newvar; $newvar = sprintf %04d-%02d-%02d, $var1, $var2, $var3; $newvar =~ s/.*/$var1-$var2-$var3/; Does this answer your question grin /? Anybody else want to add a few ways? I think I am tapped. -- Today is Pungenday, the 32nd day of Confusion in the YOLD 3167 Kallisti!
Re: Joining variables
hahahahaha # This one has already been said, but hey.. thought i would make a bigger mess of it my ($newvar); my @new = ($var1,$cat,$var2,$cat,$var3); foreach (@new){ $newvar .= $_; } #or # once again, already said, just making it obvious my @new = ($var1,$var2,$var3); $newvar = join(-,@new); #or even a bigger mess of the above. my (@new); push(@new, $var1); push(@new, $var2); push(@new, $var3); $newvar = join(-,@new); - Original Message - From: Chas Owens [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, June 27, 2001 5:39 PM Subject: Re: Joining variables So we have: $newvar = $var1.-.$var2.-.$var3; $newvar = $var1-$var2-$var3; $concat = '-'; $newvar .= $var1; $newvar .= $concat; $newvar .= $var2; $newvar .= $concat; $newvar .= $var3; $newvar = join -, ($var1, $var2, $var3); $newvar = join '', ($var1, '-', $var2, '-', $var3); #new varient $newvar='';$newvar .= $_- foreach ($var1, $var2, $var3); chop $newvar; $newvar = sprintf %04d-%02d-%02d, $var1, $var2, $var3; $newvar =~ s/.*/$var1-$var2-$var3/; Does this answer your question grin /? Anybody else want to add a few ways? I think I am tapped. -- Today is Pungenday, the 32nd day of Confusion in the YOLD 3167 Kallisti!
Re: Joining variables
the obvious proof i have too much time: for(join'',map{$_.=$:}@{[qw(2000 05 08)]}){s/\s//gchopprint} Jos - Original Message - From: Chas Owens [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, June 27, 2001 6:39 PM Subject: Re: Joining variables So we have: $newvar = $var1.-.$var2.-.$var3; $newvar = $var1-$var2-$var3; $concat = '-'; $newvar .= $var1; $newvar .= $concat; $newvar .= $var2; $newvar .= $concat; $newvar .= $var3; $newvar = join -, ($var1, $var2, $var3); $newvar = join '', ($var1, '-', $var2, '-', $var3); #new varient $newvar='';$newvar .= $_- foreach ($var1, $var2, $var3); chop $newvar; $newvar = sprintf %04d-%02d-%02d, $var1, $var2, $var3; $newvar =~ s/.*/$var1-$var2-$var3/; Does this answer your question grin /? Anybody else want to add a few ways? I think I am tapped. -- Today is Pungenday, the 32nd day of Confusion in the YOLD 3167 Kallisti!
Re: Suggestions?
Someone recommended a SAMS book that will teach you perl in 21 days. Get the O'Reilly Llama book (Learning Perl) and spend about an hour a day to finish in less than a week and a half. There are a few other O'Reilly titles I really like: Perl in a Nutshell - great reference Perl for System Administration - If you are a sysadmin or webmaster this is a must-have. I want to get Programming Perl (the Camel book) as well as their Win32 book (even though most of my work is currently in UNIX). Chris Hedemark - Hillsborough, NC http://yonderway.com - Original Message - From: Bill Pierson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, June 27, 2001 11:57 AM Subject: Suggestions? Greetings all - I realize this is a very broad question, however any suggestions would be appreciated. I'm looking to purchase good learning tools about programming in PERL. I've been programming with it for several years, but I've never truly learned the basics - just looked at other code and learned from that. Specifically I'd like to learn from ground zero about variables, hashes, etc. as well as MySQL connectivity. I'd like to find something that is concise - I have several projects that I'll be working on in the very near future, and fine-tuning my knowledge would be of great benefit. Again, any suggestions will be appreciated.
RE: checking groups on unix
Since you're doing a string compare on $groupname, you need to use 'ne', not '!='. code foreach my $file (@files) { #getgrpid returns the group file entry for a given group id. my $groupname = (getgrgid((stat($file))[5]))[0]; if ($groupname ne groupname) { print $file has bad groupname: $groupname\n; } } /code (since foo == bar numerically) -Original Message- From: Chas Owens [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 27, 2001 3:11 AM To: [EMAIL PROTECTED] Subject: Re: checking groups on unix How to build @files is left as an exercise for the reader. code foreach my $file (@files) { #getgrpid returns the group file entry for a given group id. my $groupname = (getgrgid((stat($file))[5]))[0]; if ($groupname != groupname) { print $file has bad groupname: $groupname\n; } } /code On 27 Jun 2001 09:59:07 +0100, PURMONEN, Joni wrote: Hi ya, I need to check the group status on numerous files/directories, and haven't been able to fing out the best way to do it with perl. I simply need to see if some directories do not have certain group set on them. Can anyone give any pointers? Cheers, Joni Ps. I only have learning perl and some other fairly simple books which didn't seem to have anything useful in them -- Today is Pungenday, the 32nd day of Confusion in the YOLD 3167 This statement is false.
DBI problems
Hi group! Just got back from a trip, and I'm a little rusty (a rusty newbie, JOY) Anyway, before I left I was having trouble inserting new data into my database table, and oddly enough, the problem didn't solve itself while I was gone. :( Here is my current code. I've been racking my brain, and consulting the various books I have on lend from the library, with no success. It looks right to me! Can someone please help me out? I'm using Windows 98 with ActiveState Perl on Apache Web server. use cgi; use DBI; $dbh = DBI-connect('dbi:ODBC:freq'); DBI-trace( 2, 'errors.txt' ); $co = new CGI; print $co-header, $co - start_html(title='Canadian Online Radio Frequency Database'), $co-center($co-h1('Thanks using our database!')), $co-h3('Here is what you submitted...'),$co-hr;#not done feedback yet print $co-hr; print Data AddedBR\n; $newfreq=$co-param('txtFREQ'); $newloc=$co-param('txtLOC'); $newdesc=$co-param('txtDESC'); $newfreqtype=$co-param('txtFREQTYPE'); $newcat=$co-param('txtCAT'); $newcall=$co-param('txtCALL'); $newtx=$co-param('txtTX'); $sqlstatement = INSERT INTO canfreqtable (freq, loc, desc, freqtype, cat, call, tx) VALUES (?,?,?,?,?,?,?); $sth = $dbh-prepare($sqlstatement) || die $dbh-errstr; $sth-execute($newfreq, $newloc, $newdesc, $newfreqtype, $newcat, $newcall, $newtx) || die $dbh-errstr; print Thank you for submitting a frequency!; print $co-end_html; And here is what gets piped out to my errors.txt file. DBI 1.14-nothread dispatch trace level set to 2 - prepare for DBD::ODBC::db (DBI::db=HASH(0x1b38790)~0x1b3a194 'INSERT INTO canfreqtable (freq, loc, desc, freqtype, cat, call, tx) VALUES (?,?,?,?,?,?,?)') dbd_preparse scanned 7 distinct placeholders dbd_st_prepare'd sql f32113660 INSERT INTO canfreqtable (freq, loc, desc, freqtype, cat, call, tx) VALUES (?,?,?,?,?,?,?) - prepare= DBI::st=HASH(0x1b38880) at ADDTOF~1.PL line 29. - execute for DBD::ODBC::st (DBI::st=HASH(0x1b38880)~0x1b05b08 '11' 'MB' 'TEST' 'VHF' 'FARM' 'TESTING' '2') bind 1 == '11' (attribs: ) bind 1 == '11' (size 6/7/0, ptype 4, otype 1) bind 1: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=6. bind 2 == 'MB' (attribs: ) bind 2 == 'MB' (size 2/3/0, ptype 4, otype 1) bind 2: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=2. bind 3 == 'TEST' (attribs: ) bind 3 == 'TEST' (size 4/5/0, ptype 4, otype 1) bind 3: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=4. bind 4 == 'VHF' (attribs: ) bind 4 == 'VHF' (size 3/4/0, ptype 4, otype 1) bind 4: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=3. bind 5 == 'FARM' (attribs: ) bind 5 == 'FARM' (size 4/5/0, ptype 4, otype 1) bind 5: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=4. bind 6 == 'TESTING' (attribs: ) bind 6 == 'TESTING' (size 7/8/0, ptype 4, otype 1) bind 6: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=7. bind 7 == '2' (attribs: ) bind 7 == '2' (size 5/6/0, ptype 4, otype 1) bind 7: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=5. dbd_st_execute (for sql f32113660 after)... st_execute/SQLExecute error -1 recorded: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. (SQL-37000)(DBD: st_execute/SQLExecute err=-1) !! ERROR: -1 '[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. (SQL-37000)(DBD: st_execute/SQLExecute err=-1)' - execute= undef at ADDTOF~1.PL line 30. - errstr in DBD::_::common for DBD::ODBC::db (DBI::db=HASH(0x1b38790)~0x1b3a194) - errstr= ( '[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. (SQL-37000)(DBD: st_execute/SQLExecute err=-1)' ) [1 items] at ADDTOF~1.PL line 30. -- DBI::END - disconnect_all for DBD::ODBC::dr (DBI::dr=HASH(0x1b7dda8)~0x1b387e4) - disconnect_all= '' at DBI.pm line 450. - DESTROY for DBD::ODBC::st (DBI::st=HASH(0x1b05b08)~INNER) - DESTROY= undef during global destruction. - DESTROY for DBD::ODBC::db (DBI::db=HASH(0x1b3a194)~INNER) - DESTROY= undef during global destruction. - DESTROY in DBD::_::common for DBD::ODBC::dr (DBI::dr=HASH(0x1b387e4)~INNER) - DESTROY= undef during global destruction.