Re: NULL insertion
on Mon, 24 Feb 2003 22:54:59 GMT, [EMAIL PROTECTED] (T. Murlidharan Nair) wrote: 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!! Read the section on 'Null Values' in perldoc DBI -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
CGI.PM
I am using CGI.PM and can not seem to pull data from the form. What am I missing here Thanks Dave Gilden #!/usr/bin/perl use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); use POSIX 'strftime'; # use strict; my $mailprog = '/usr/sbin/sendmail'; my $recipient = '[EMAIL PROTECTED]'; my @referers; my $date = strftime('%A, %B %d, %Y %I:%M %p',localtime); my $check_referer; ... sniped... print header; print END_Thanks_HTML; htmlheadtitleThanks for your input!/title/head body bgcolor=#cc text=#00 link=#ff alink=#ff vlink=#336600 END_Thanks_HTML print em('Confirm'); # just to make sure CGI.pm is working and it is! print END_Thanks_HTML; h2 img align=bottom width=40 height=40 BORDER=0 SRC=/images/Globe_tran.gif ALT=GlobeIcon Cora Connection/h2 blockquote h2font color=#C15503Thanks for your message!/font/h2 END_Thanks_HTML print -x20,br\n; foreach $name (param()){ print param($name)br\n; } print -x20,br\n; print param('name') , , param('email') , on $date/p\n; print pre . param(message) ./pre\n; print END_Thanks_HTML; /blockquote centertable border=0 cellspacing=0 cellpadding=2 width=420 tr valign=middle td valign=bottom a href=http://www.coraconnection.com/; onMouseOver=window.status='Back to our opening page.' ; return true onMouseout=window.status='' ; return trueB img src=/images/b_kora.gif ALT=kora drawing WIDTH=50 HEIGHT=100 BORDER=0 ALT=Back to our front page/B/A/tdTD table border=0 cellspacing=0 cellpadding=2 ### etc. == Cora Connection: Your West African Music Source Resources, Recordings, Instruments More! http://www.coraconnection.com/ == -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CGI.PM
Try using: use CGI; my $q = new CGI; my $username = $q-param('username'); my $password = $q-param('password'); print eof; htmlheadtitletitle/title/head body Username is $usernamebr Password is $passwordbr form ... User: input type=text name=username Pass: input type=password name=password ... /form ... /body/html eof Teddy, Teddy's Center: http://teddy.fcc.ro/ Email: [EMAIL PROTECTED] - Original Message - From: David Gilden [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 7:36 PM Subject: CGI.PM I am using CGI.PM and can not seem to pull data from the form. What am I missing here Thanks Dave Gilden #!/usr/bin/perl use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); use POSIX 'strftime'; # use strict; my $mailprog = '/usr/sbin/sendmail'; my $recipient = '[EMAIL PROTECTED]'; my @referers; my $date = strftime('%A, %B %d, %Y %I:%M %p',localtime); my $check_referer; ... sniped... print header; print END_Thanks_HTML; htmlheadtitleThanks for your input!/title/head body bgcolor=#cc text=#00 link=#ff alink=#ff vlink=#336600 END_Thanks_HTML print em('Confirm'); # just to make sure CGI.pm is working and it is! print END_Thanks_HTML; h2 img align=bottom width=40 height=40 BORDER=0 SRC=/images/Globe_tran.gif ALT=GlobeIcon Cora Connection/h2 blockquote h2font color=#C15503Thanks for your message!/font/h2 END_Thanks_HTML print -x20,br\n; foreach $name (param()){ print param($name)br\n; } print -x20,br\n; print param('name') , , param('email') , on $date/p\n; print pre . param(message) ./pre\n; print END_Thanks_HTML; /blockquote centertable border=0 cellspacing=0 cellpadding=2 width=420 tr valign=middle td valign=bottom a href=http://www.coraconnection.com/; onMouseOver=window.status='Back to our opening page.' ; return true onMouseout=window.status='' ; return trueB img src=/images/b_kora.gif ALT=kora drawing WIDTH=50 HEIGHT=100 BORDER=0 ALT=Back to our front page/B/A/tdTD table border=0 cellspacing=0 cellpadding=2 ### etc. == Cora Connection: Your West African Music Source Resources, Recordings, Instruments More! http://www.coraconnection.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]
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]
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: lower casing email address
That's fine for the first step. However, its getting a regex in Perl to output lower case numbers which is the real gotcha! (Okay, okay. I'm sorry. I just couldn't resist...g) John-- [EMAIL PROTECTED] -Original Message- From: David Gilden [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 2: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: lower casing email address
The best I guess is: $email = lc($email); Teddy, Teddy's Center: http://teddy.fcc.ro/ Email: [EMAIL PROTECTED] - Original Message - From: David Gilden [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 9:12 PM 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: system info: cpu, ram, disk - Google for AdminMisc GetMemoryInfo()
Hi Robert I am also doing looking exactly the same some more info . I have got many info , mails from this helping list , examples on net which i myself hasn't worked on - what all i know about my own databsae of this search results is Win32:: there are some modules for win32 like AdminMisc ( GetProcessInfo() GetProcesserInfo() for processor , GetMemoryInfo() for ram ,GetDriveSpace() for disk ) DO Google for AdminMisc GetMemoryInfo() you will find many examples . Win32:: Tieregistry etc which will give you u these type of info , for taking info from remote machines u may use TieRegistry . I was thinking of implementing it as if(unix) { unix funcn } elsif(windows) { win32 funcn } http://www.the-labs.com/Perl/ThePerlJournal/Issue_08_Win32/ http://www.roth.net/conference/lisant/1999/ have good examples for you . It must be able to help you . Regards Pradeep - Original Message - From: Robert Citek [EMAIL PROTECTED] To: perl beginners [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 11:00 AM Subject: system info: cpu, ram, disk Hello all, How can I find out information about a system in a system-independent manner? I wrote a perl script that nicely displays information about a Linux system: # of cpus, cpu speed, size of RAM, # of disks, size of disks, IP address. The code uses the system() command and relies on the /proc psuedo-file system. Now, I would like to have a similar script that runs on Win32 systems. I seem to have two choices: 1) write a completely different script specific for Win32 or 2) write a system-independent script that will run on both Win32 and Linux. Ideally, I would like to do option 2. I've searched for commands that will tell me cpu, memory, IP, and disk information on a Win32 system, but have not found them. I have found Sys::CPU on CPAN, but that has not been tested on Win32 and is only part of what I'm looking for. Any pointers would be greatly appreciated. Regards, - Robert -- 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: Multi threading in perl
you might want to start with http://www.perldoc.com/perl5.8.0/pod/perlfunc.html#Alphabetical-Listing-of-P erl-Functions and look for 'fork' warning: there is no fork for win32, you have to use theWin32::Process module. Madhu Reddy [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, does anybody have sample perl script multi threaded program any site does talks about perl multi threading I appreciate u r help Thanx -Madhu __ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Get list of available modules?
Greetings! Hello I'm trying to do some Perl for a non-profit organization. The computer administrator doesn't know very much about Perl or about the server. If I were to ask him what Perl modules were available, he'd probably just have to call somebody else and get back to me. Is there any way to use Perl to generate a list of such modules for me? I was hoping to get some feedback on the following. Let me know what you think. #!/usr/bin/perl -w use ExtUtils::Installed; my $instmod = ExtUtils::Installed-new(); foreach my $module ($instmod-modules()) { my $version = $instmod-version($module) || ???; print $module -- $version\n; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regex question
Here is the perl script being used.. It supposedly takes regex or perl expressions for parameters.. however I have to search for the following string : TDS-RES.1.2345678 but when I use the following regex it fails: peg TDS-RES/.1/.2345678 MEDLAB* peg: error in Perl expression: (TDS-RES\.1\.2345678) Backslash found where operator expected at (eval 1) line 1, near RES\ Backslash found where operator expected at (eval 1) line 1, near .1\ (Missing operator before \?) syntax error at (eval 1) line 1, near RES\ You have mail in /usr/spool/mail/pegate what would be the appropriate Perl expression for this search? Thanks, Steve. Steve Lobach [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have a perl script that acts like grep, however, it doesn't totally do what is expected.. The script is called peg.. It supposedly takes regex or perl expressions for parameters.. however I have to search for the following string : TDS-RES.1.2345678 but when I use the following regex it fails: peg TDS-RES/.1/.2345678 MEDLAB* peg: error in Perl expression: (TDS-RES\.1\.2345678) Backslash found where operator expected at (eval 1) line 1, near RES\ Backslash found where operator expected at (eval 1) line 1, near .1\ (Missing operator before \?) syntax error at (eval 1) line 1, near RES\ You have mail in /usr/spool/mail/pegate what would be the appropriate Perl expression for this search? Thanks, Steve. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Perl textdb problems. Help!
Hello everyone, I've got a question. I hope anyone can take the time to look at my problem. I've started writing perl for use with CGI about a year ago. I'm average advanced with perl. After writing and writing a lot I stumbled upon a problem. This is it: I've got a text database in the form of |userid=1name=Pharellstreet=Bobstreet%204postal_code=47A3921B|userid=2name=Bobstreet=Pharellstreet| (all values are btw hex encoded) etcetera. Now the problem is, it's getting too big! It works completely great with a relatively small amount of items, but if the db is big it takes about 4 or more seconds to open the db, get the stuff and get the hell out. Four seconds is a lifetime. I've already wrote a complete module which uses files like this and now it's finally kind of done (on the scripting side), I tried it out on and made a new db of the old (it's an artist community website) poetry files which are something of about 120 text files, I put them all into my db and the db is now 1.5mb big and after writing all the scripting stuff for it, it just goes too slow! Sorry for the above piece of text being completely stupid written. What do you guys think I should do? I'm so f*cking desperate. I need something simple, great, effective, and quick to implementate into my code. Something like the fastest and at the same time most simple db around. It really doesn't need to be anything fancy, just like a text db but then fast. Thanks, Pharell -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help need in GUI
GlacierPlease post in plain text. Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How do I recursively look in every directory
I am new to perl. I would like to look into every directory below my home directory and look for files in it. #!/usr/bin/perl #use strict; use Cwd; my $curr = cwd(); opendir(CURRDIR, $curr) or die can't open directory ($!), exiting.\n; my @files = readdir(CURRDIR); #closedir(CURRDIR); foreach my $file (sort @files) { next if $file eq '.' || $file eq '..'; next if !-d $file; if (-d $file) { print $file/\n; #Puts a slash in front of every directory it encounters } else { print $file\n; } } Any Help would be greatly appreciated. _ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Script Works With One Newsgroup, Not With Another
Le Fri, Feb 21, 2003 at 05:19:06PM -0800, Michael Kelly a écrit ... OK ... no wants to answer me. *shrug* It's often not a matter of people not wanting to answer you so much as not being able to. I personally have no experience in the area of your question. Answers on mailing lists are provided assuming that (a) the right people with the right areas of experience see your message and (b) that they can donate their time to help fix someone else's problem. Check where you define the values in your if statement. Make sure they exist when you think they do, and are what you think they are. OK, thanks, I'll have a look, but I fear that I'm not going to get far, as I'm very much at the 'beginner' level, and the script isn't mine, but is one that a friend modified, from an already existing script. D. -- Desmond Coughlan |'Io non mori, e non rimasi vivo' [EMAIL PROTECTED] http://www.zeouane.org pgp0.pgp Description: PGP signature
Re: Script Works With One Newsgroup, Not With Another
Le Sat, Feb 22, 2003 at 11:37:57AM -0800, R. Joseph Newton a écrit ... I post statistics to a newsgroup called news:alt.activism.death-penalty once per week, using the 'ngstatistics' script by H. Alex LaHurreau and Davide G. M. Salvetti. You can see the script in its entirety here ... OK ... no wants to answer me. Well, you are going to have to do the lead work here. this isn't just a concept test--it's a full application, and debugging it is the programmer's job. You will probably want to start by inserting print statements at critical points in the script to see where it is hanging. Good tactic, I'll try that, but still can't figure out why, if it's hanging with one newsgroup, why isn't it doing it with them all ? You also will want to use an existing news application to sample the output from each group and examine it closely. Look for the application which shows the richest header information. Willdo. { snip remaining advice } I'll keep y'all posted, then. :-) D. -- Desmond Coughlan |'Io non mori, e non rimasi vivo' [EMAIL PROTECTED] http://www.zeouane.org pgp0.pgp Description: PGP signature
Help need in GUI
Hello all, I work on Solaris and I have perl installed. Do I have to install Perl Tk separately. I got this sample program from the web and I tried to run it in my machine. I get this error when I do it. Can't locate object method new via package MainWindow at ./gui_test.pl line 3 I dont understand what's happening. Please help me in this regard. #!/usr/local/bin/perl my $vu_win = MainWindow-new(); $vu_win-configure(-title='Verify User',-background='blue'); $vu_win-geometry('+100+300'); $vu_win-destroy; Anbudan, Anand~ --- Yesterday is a cancelled check. Tomorrow is a promisory note. Today is ready cash. Use it !! -Original Message- From: Bernhard van Staveren [mailto:[EMAIL PROTECTED] Sent: Monday, February 24, 2003 8:36 PM To: Anand Ramakrishna Cc: [EMAIL PROTECTED] Subject: Re: Help need in GUI It depends really on how fancy you want to get with it. At one end you have the Perl/Tk bindings for doing things in Tk, but you could also go to freshmeat.net, find yourself a copy of Glade, and find a copy of the Perl GTK bindings - that way you can 'visually' do the whole UI part, and put in the appropriate code later. That's about all I have on GUI stuff, hope it helps -- Bernhard van Staveren - madcat(at)ghostfield.com GhostField Internet - http://www.ghostfield.com/ A witty saying proves nothing, but damn it's funny! - me, 1998 DISCLAIMER: Information contained and transmitted by this E-MAIL is proprietary to Hexaware Technologies and is intended for use only by the individual or entity to which it is addressed and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If this is a forwarded message, the content of this E-MAIL may not have been sent with the authority of the Company. If you are not the intended recipient, an agent of the intended recipient or a person responsible for delivering the information to the named recipient, you are notified that any use, distribution, transmission, printing, copying or dissemination of this information in any way or in any manner is strictly prohibited. If you have received this communication in error, please delete this mail notify us immediately at [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
dynamic arrays
Hi, I'm a beginner at PERL. I've used it on and off, but only just recently got myself back into the picture. I figured that if you forget something in PERL, it'd be easy to take it up again. So far, I'm not too sure of the ease of taking up PERL again. Before, I made a few perl scripts. Now, when I look back, I find the whole thing overwhelming. Even with comments...Anyway, I digress.. I have a text file with each line of the following format: string1 string2 val1 val2 val3 I'm trying to read it into an array of arrays so I can stick it in the creategraph() function to create a line graph. So far, if I specifically create an array constant: ie. my(@data) = ( [test 1,0.34,0.56,0.33], [test 2,0.44,0.55,0.22], [final test,0.67,0.22,0.54]) my($grp) = new GD::Graph::linespoints(); and then put that in the $grp-plot([EMAIL PROTECTED]) function, I get a graph. But, if I use the following code: while (MYFILE){ chomp($_); @info = split( ,$_); my($strngval) = \$info[0] $info[1]\; $strval = $strval,$strngval; $m1vals = $m1vals,$info[2]; $m2vals = $m2vals,$info[3]; } my (@sv) = split(,,$strval); my(@m1) = split(,,$m1vals); my(@m2) = split(,,$m2vals); my(@data) = (@sv,@m1,@m2); Are @sv, @m1 and @m2 all arrays? So, would @data be an array of arrays? Or are the @sv, @m1 and @m2 arrays flattened out, making @data just an array? The thing is, with the fixed way of doing the graph, and when I print out @data, I get ARRAY() ARRAY() ARRAY(...) But with the 'dynamic' way, I just get ARRAY(...) where () are memory locations in Hex, I believe. Can someone point out what I'm doing wrong? Thanks E -- email: [EMAIL PROTECTED] | A man who knows not where he goes, | knows not when he arrives. |- Anon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How do I recursively look in every directory
Prasad Karpur wrote: I am new to perl. I would like to look into every directory below my home directory and look for files in it. [snip] Any Help would be greatly appreciated. Use the File::Find module. perldoc File::Find John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: good general programming book?
Well your in the wrong place for language neutral advise: however, Elements of Programming with Perl by Manning Press - gives a good grounding in the thought process needed utilizing Perl as the language. --On 24 February 2003 12:46 -0700 Jose Malacara [EMAIL PROTECTED] wrote: Does anyone recommend a good general programming book? Something that's not so much language specific, but more about methodologies, techniques, etc. I don't have a programming background, so I tend to have the most trouble when it comes to looking at the larger picture and how a program should flow, rather than the finer details like syntax. Thanks, Jose Daryl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Installing the Apache::Registry to get PERL working
do i do this although i have apache installed on my server. it came with Red Hat Linux 8. (i have Apache 2.0.40)? Cheers From: david [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: Installing the Apache::Registry to get PERL working Date: Mon, 24 Feb 2003 18:00:32 -0800 Mo Elwaisi wrote: I have found that the reason PERL is not working is that the Apache Registry is not installed, so i typed perl -MCPAN -e shell; cpan install Apache::Registry i was then asked to locate where the Apache scr is, which i am not sure where it is so i typed /usr/sbin/httpd try the following steps (assuming you are root): 1. download http://www.apache.org/dist/httpd/apache_1.3.27.tar.gz and store it under /tmp 2. tar -zxf apache_1.3.27.tar.gz 3. Enter the following command: perl -MCPAN -e 'install(Bundle::Apache)' 4. Answer a few questions. when it ask you where is the Apache source, type: /tmp/apache_1.3.27/src 5. wait for everything to finish and then do the following: cd /tmp/apache_1.3.27 make install 7. make change to httpd.conf and restart Apache 6. you are done. if you encounter any problem, read: http://perl.apache.org/docs/1.0/guide/getwet.html and you will be done in 20 minutes. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Surf together with new Shared Browsing http://join.msn.com/?page=features/browsepgmarket=en-gbXAPID=74DI=1059 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help with learning VB Script (Please don't shout at me)
As I said, please don't shout at me A situation has arisen at work, where a new application which has been bought requires VB script to do pattern matching and string modification. Yes I know that it is easier in Perl, (and the app supports perl) but the PHB has decreed that the VBscript route is the the one to take. My question: Can anyone point me at a good VBScript book/Site that will help someone who knows perl to adapt? (Changing jobs is not an option at this point) Suggestions please folks The information contained in this e-mail is intended only for the individual or entity to whom it is addressed. Its contents (including any attachments) are confidential and may contain privileged information. If you are not an intended recipient you must not use, disclose, disseminate, copy or print its contents. If you receive this email in error, please delete and destroy the message and notify the sender by reply email. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Help with learning VB Script (Please don't shout at me)
Look if the archive below contains some interesting info for what you want. HTH, José == THE ARCHIVE From: Ben Crane [EMAIL PROTECTED] Is there a way of using perl's amazing pattern-matching skills within VB???I find using VB to query txt files, etc to be more cumbersome and less friendly than perl's...I was wondering whether anyone had been able to utilize perl from within VB, and if so, how? I'm presuming using a perl dll [actually, can they be used in vb?], but that would be quite slow if you wanted to use the dll for a variety of pattern matching? See http://Jenda.Krynicky.cz/#Jenda.Rex I did not do any benchmarks myself, but I've been told: Our program runs 15% faster in our demo project than with Microsoft Regexp (the regexp part is just one of many things our program does). But our primary reason for using Jenda.Rex is that we do not want our customers to change their windows installation (installing a new vbscript.dll, we needed stuff in version 5.5). Of course Jenda.Rex is just regexps. If you want the whole power of Perl, you will need the PerlCtrl from ActiveState's PDK. ( http://www.activestate.com/Products/Perl_Dev_Kit/ ) That may be better because with Jenda.Rex you'll have to read the file in VB and then pass the whole text to the COM object, which may add too much overhead. I created several COM objects with PerlCtrl and use them from ASPs or VB programs and it works just great :-) Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: dynamic arrays
On Tue, 25 Feb 2003, cc wrote: Hi, I'm a beginner at PERL. I've used it on and off, but only just recently got myself back into the picture. I figured that if you forget something in PERL, it'd be easy to take it up again. So far, I'm not too sure of the ease of taking up PERL again. Before, I made a few perl scripts. Now, when I look back, I find the whole thing overwhelming. Even with comments...Anyway, I digress.. You might want to read through these docs too perldoc perllol perldoc perldsc perldoc perlreftut perldoc perlref I have a text file with each line of the following format: string1 string2 val1 val2 val3 I'm trying to read it into an array of arrays so I can stick it in the creategraph() function to create a line graph. So far, if I specifically create an array constant: ie. my(@data) = ( [test 1,0.34,0.56,0.33], [test 2,0.44,0.55,0.22], [final test,0.67,0.22,0.54]) my($grp) = new GD::Graph::linespoints(); and then put that in the $grp-plot([EMAIL PROTECTED]) function, I get a graph. But, if I use the following code: I guess you have enabled the strict and warnings pragmas, if not enable them. perldoc perltrap while (MYFILE){ chomp($_); You don't have to chomp here, the split in the next line will take care of removing the newline too perldoc -f split @info = split( ,$_); better written as my @info = split; my($strngval) = \$info[0] $info[1]\; $strval = $strval,$strngval; $m1vals = $m1vals,$info[2]; $m2vals = $m2vals,$info[3]; } my (@sv) = split(,,$strval); my(@m1) = split(,,$m1vals); my(@m2) = split(,,$m2vals); my(@data) = (@sv,@m1,@m2); Are @sv, @m1 and @m2 all arrays? So, would @data be an array of arrays? Or are the @sv, @m1 and @m2 arrays flattened out, making @data just an array? Yes, @data is just an array not an array of arrays. Does this do what you want? # CODE START # my @data; while (MYFILE) { my @info = split; push (@data, [$info[0] $info[1], @info[2..$#info]]); } # CODE END # You might also want to take a look at the Data::Dumper module to make sure your array of arrays is formed correctly. perldoc Data::Dumper The thing is, with the fixed way of doing the graph, and when I print out @data, I get ARRAY() ARRAY() ARRAY(...) But with the 'dynamic' way, I just get ARRAY(...) where () are memory locations in Hex, I believe. Can someone point out what I'm doing wrong? Thanks E hth, Sudarshan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Help with learning VB Script (Please don't shout at me)
Many thanks, this looks useful. I appreciate the help as this is slightly OT Regards Rod Crowder The information contained in this e-mail is intended only for the individual or entity to whom it is addressed. Its contents (including any attachments) are confidential and may contain privileged information. If you are not an intended recipient you must not use, disclose, disseminate, copy or print its contents. If you receive this email in error, please delete and destroy the message and notify the sender by reply email. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How do you 'read' from a Tk widget ?
On Fri, 21 Feb 2003 14:14:08 +0200, [EMAIL PROTECTED] (Yargo) wrote: Hi all, I have this little script that asks the user for UserName password. I can't figure out where do I get the input. e.g. : UserName = yargo Password = q1w2e3 Here's an example: #!/usr/bin/perl use Tk; my $MainWindow = MainWindow-new; $MainWindow-title(Password Entry); $MainWindow - Label(-justify = 'left', -text = Name: ) -pack(-side = 'left', -anchor = 'n'); my $entry = $MainWindow - Entry(-selectborderwidth = 10) -pack(-side = 'top', -anchor = 'n'); ### $MainWindow - Label(-justify = 'left', -text = Password: ) -pack(-side = 'left', -anchor = 'w'); my $entry1 = $MainWindow - Entry(-selectborderwidth = 10, -show = *) -pack(-side = 'left', -anchor = 'e'); ## $MainWindow - Button(-text = SUBMIT, -command = \somesub) -pack(-side = 'bottom',-anchor = 's'); $entry-bind('Return',[\somesub]); $entry-focus; MainLoop; sub somesub { $name = $entry - get; $password = $entry1-get; print name -$name\n; print password -$password\n; $MainWindow - destroy; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multi threading in perl
On Mon, 24 Feb 2003 10:45:44 -0800 (PST), [EMAIL PROTECTED] (Madhu Reddy) wrote: Hi, does anybody have sample perl script multi threaded program Here are a couple of simple examples. When you run them, open an xterm an watch top while they run. ### #!/usr/bin/perl use threads; my @kiddies; foreach(1..10) { print $$ starting loop $_; push @kiddies, threads-new(\sub1); print $$ exiting loop $_\n; } sub sub1 { print \tchild , threads-tid(), created ok\n; sleep(int(rand(10))); print \tchild, threads-tid() , done, outta here\n; } foreach (@kiddies){ $_-join(); } #!/usr/bin/perl #threads share same memory stack #each thread has it's own pid and stack pointer #threads can access other threads variables use threads; use threads::shared; use strict; my $wait = 500; my @up: shared; my $th; my @childs; my $child; my @down: shared; my @list = qw (5 10 15 20 25 30 35 40 45 50 55 60); foreach (@list) { push @childs, threads-create( do_my_thing, $_ ); } foreach $child (@childs) { $child-join(); } print @up,\n; print @down,\n; sub do_my_thing { my $val = shift; push @up,$val started; sleep $val; #sleep various lengths in thread push @down, $val down\n; } ### -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: dynamic arrays
Cc wrote: Hi, Hello, I'm a beginner at PERL. I've used it on and off, but only just recently got myself back into the picture. I figured that if you forget something in PERL, it'd be easy to take it up again. So far, I'm not too sure of the ease of taking up PERL again. Before, I made a few perl scripts. Now, when I look back, I find the whole thing overwhelming. Even with comments...Anyway, I digress.. I have a text file with each line of the following format: string1 string2 val1 val2 val3 I'm trying to read it into an array of arrays so I can stick it in the creategraph() function to create a line graph. So far, if I specifically create an array constant: ie. my(@data) = ( [test 1,0.34,0.56,0.33], [test 2,0.44,0.55,0.22], [final test,0.67,0.22,0.54]) my($grp) = new GD::Graph::linespoints(); and then put that in the $grp-plot([EMAIL PROTECTED]) function, I get a graph. But, if I use the following code: while (MYFILE){ chomp($_); @info = split( ,$_); my($strngval) = \$info[0] $info[1]\; $strval = $strval,$strngval; $m1vals = $m1vals,$info[2]; $m2vals = $m2vals,$info[3]; } From your description, you probably want something like this: my @data; while ( MYFILE ) { my ( $str1, $str2, @info ) = split; push @data, [ $str1 $str2, @info ]; } my (@sv) = split(,,$strval); my(@m1) = split(,,$m1vals); my(@m2) = split(,,$m2vals); my(@data) = (@sv,@m1,@m2); Are @sv, @m1 and @m2 all arrays? Yes. So, would @data be an array of arrays? No. Or are the @sv, @m1 and @m2 arrays flattened out, making @data just an array? Yes. The thing is, with the fixed way of doing the graph, and when I print out @data, I get ARRAY() ARRAY() ARRAY(...) Those are references to arrays. That is how Perl enables the use of multidimensional data structures. But with the 'dynamic' way, I just get ARRAY(...) where () are memory locations in Hex, I believe. Yes. Can someone point out what I'm doing wrong? You could use the Data::Dumper module to display the contents of @data: use Data::Dumper; print Dumper( [EMAIL PROTECTED] ); John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Get list of available modules?
Rob: You may try PERDIVER. Its very simple and quite useful. You can download from here http://www.scriptsolutions.com/programs/free/perldiver/ Just upload chmod 755 and run. -rm- - Original Message - From: Rob Richardson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 24, 2003 1:12 PM Subject: Get list of available modules? Greetings! I'm trying to do some Perl for a non-profit organization. The computer administrator doesn't know very much about Perl or about the server. If I were to ask him what Perl modules were available, he'd probably just have to call somebody else and get back to me. Is there any way to use Perl to generate a list of such modules for me? Thanks! Rob __ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.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: Nomber of anonymous hashes in an anonymous array
Olivier Wirz wrote: Hello, Ich have an anonymous array of anonymous hashes: $self - {_definitions} = [ { IN = file1.txt, INOUT= file1.dat,}, { IN = file2.txt, INOUT= file2.dat,} ]; and I woud like to have the number of anonymous hashes in the [] (2 in this example). With scalar on $self - {_definitions} (i.e. I have a method definitions() which returns $self - {_definitions}, so I have something like this: my @definitions = self - definitions(); But $self-{_definitions} is a scalar (a reference to the anon array). So after this statement, @definitions contains only one element, the reference. If you want to copy the anon array into @definitions, you need: my @definitions = @{ $self-definitions }; my $numberOfHashes = @definitions; Note that scalar is not required in the second statement. The assignment to a scalar puts the right hand side into scalar context for you. my $numberOfHashes = scalar (@definitions); $numberOfHashes is 1 (and not 2). The general case is: if X is a reference to an array, then the array itself can be accessed as @{ X } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Dynamic Hash Naming and multi-dimensional hashes
Hello beginners! Where do I start... I've already done some reading on this and I've played tag the wall with the forehead long enough. What I'm challenging myself to do is to create: a) a way to name a hash from user input b) find a way to create a multi-level hash (hash within a hash) From what I can derive, you can insert an array as an element of a hash, thus making it multi-dimensional. As a side effort, which is probably easier... I'm also asking for an example of multi-dimensional arrays, and the object-orientation aspect. I realize the arrays @array1 and @array2 will actually be slice numbers 0 and 1, but this is for understandability I deviate. #Create a multi-dimensional array my @parent= (@array1, @array2); #Spit out the info in the arrays foreach $i ($parent($array1)) { print $parent($array1[$i]) is part of $parent($array2[$i])\n; } If anyone can help me, I would be much appreciative. Thanks, Paul H. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: help with nearly identical hash keys
Hello people, Can any one please help me. I have 2 hashes, hashA and hashB, the keys in both cases, are made up of a mixture of numbers and words etc. But the keys are differnt so I presume I cannot use if exits or if defined. Is there anyway of check to see if the words and numbers making up the keys of hashB are present in the keys of hashA? ie: initially I check if a certain word is present in key of hashA, such as if ( $key =~ /WORD1/ ) { then the key of hashA looks like: 12334RET456WORD1W56778 sp_entry14300.001T (the value for this key is say 1234.1) and the corresponding key of hashB looks like: 1234.1A1sp_entry 14300.001 (the value for this key is say 1234.1.A1 ) What I am trying is if the key of hashA contain s sp_entry 14 30 0.001 ; then to print the value held by the current key of hashB (1234.1.A1) followed by the entire current key of hashA (12334RET456WORD1W56778sp_entry14300.001 T) so that the final output is: 1234.1.A112334RET456WORD1W56778sp_entry14 300.001T (all on the same line). The mixture of words and numbers in the keys are seperated by a tab. Thanks in advance for reading and reading with a reply. cheers all, amal -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help need in GUI
On Tue, 25 Feb 2003 10:30:32 +0530, [EMAIL PROTECTED] (Anand Ramakrishna) wrote: I work on Solaris and I have perl installed. Do I have to install Perl Tk separately. I got this sample program from the web and I tried to run it in my machine. I get this error when I do it. Can't locate object method new via package MainWindow at ./gui_test.pl line 3 I dont understand what's happening. Please help me in this regard. You must install Tk, it's a separate module. Plus the program needs a MainLoop statement. #!/usr/local/bin/perl use Tk; my $vu_win = MainWindow-new(); $vu_win-configure(-title='Verify User',-background='blue'); $vu_win-geometry('+100+300'); MainLoop; $vu_win-destroy; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Dynamic Hash Naming and multi-dimensional hashes
Hendricks Paul D A1C 27 IS/INYS wrote: Hello beginners! Where do I start... I've already done some reading on this and I've played tag the wall with the forehead long enough. Are you working through a book, like Learning Perl? If not, you should, because it takes you step by step through these concepts. What I'm challenging myself to do is to create: a) a way to name a hash from user input No. Don't do that. Instead, think about what a hash is: a set of key/value pairs, where you can quickly access a value by its key. keys are always strings, and values are always scalars. The scalar value can be a reference to some other structure (hash, array, etc.), which is how you can manage complex data structures. So, name a hash from user input should be reformulated as: Get a string (hash key) from user input and store a reference to another hash using that key. Here's a complete example: #!/usr/bin/perl use strict; use Data::Dumper; my %data; # here will be the hashes of user data print Enter your first name: ; chomp(my $name = STDIN); print Enter your age: ; chomp(my $age = STDIN); print Enter your favorite color: ; chomp(my $color = STDIN); $data{$name} = { age = $age, color = $color }; print Dumper(\%data); Sample run: Enter your first name: Bob Enter your age: 41 Enter your favorite color: Green $VAR1 = { 'Bob' = { 'color' = 'Green', 'age' = '41' } }; So we've named a hash 'Bob'. The hash has two entries (key 'age', value '41' and key 'color' value 'Green'). We don't have a variable named %Bob in our program, but you don't want to do that. Not all strings the user might enter are legal variable names, and some would conflict with the variables in your program. So we keep these hashes in a special namespace, the %data hash. b) find a way to create a multi-level hash (hash within a hash) We just did it. %data is a hash whose value is another hash. The key line in the example above is: $data{$name} = { age = $age, color = $color }; You need to understand exactly what that is doing. Do you? From what I can derive, you can insert an array as an element of a hash, thus making it multi-dimensional. Technically, an array *reference* As a side effort, which is probably easier... I'm also asking for an example of multi-dimensional arrays, and the object-orientation aspect. I realize the arrays @array1 and @array2 will actually be slice numbers 0 and 1, but this is for understandability I deviate. #Create a multi-dimensional array my @parent= (@array1, @array2); #Spit out the info in the arrays foreach $i ($parent($array1)) { print $parent($array1[$i]) is part of $parent($array2[$i])\n; } Sorry, I can't figure out at all what you're trying to do here. The first statement does not create a multi-dimensional array. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multi threading in perl
Hi, Lance list! Hi, does anybody have sample perl script multi threaded program As of perl 5.8.0 there is a new thread implementation (IThreads). Although its not yet recomended for production, its worth a look. perldoc perlthrtut gives a good starting point. HTH, Jan -- cat /dev/world | perl -e while () {(/(^.*? \?) 42 \!/) (print $1)} errors-(c) - -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to look into every subdirectory
I am new to Perl and would like to know how to look into every subdirectory. Any help would be greatly appreciated. #!/usr/bin/perl #use strict; use Cwd; my $curr = cwd(); opendir(CURRDIR, $curr) or die can't open directory ($!), exiting.\n; my @files = readdir(CURRDIR); #closedir(CURRDIR); foreach my $file (sort @files) { next if $file eq '.' || $file eq '..'; next if !-d $file; if (-d $file) { print $file/\n; #Puts a slash in front of every directory it encounters } else { print $file\n; } } closedir(CURDIR); __ The NEW Netscape 7.0 browser is now available. Upgrade now! http://channels.netscape.com/ns/browsers/download.jsp Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help with learning VB Script (Please don't shout at me)
go to the microsoft site and look for VB script. http://msdn.microsoft.com/library/default.asp?url=/nhp/Default.asp?contentid =28001169 Rod Crowder [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] As I said, please don't shout at me A situation has arisen at work, where a new application which has been bought requires VB script to do pattern matching and string modification. Yes I know that it is easier in Perl, (and the app supports perl) but the PHB has decreed that the VBscript route is the the one to take. My question: Can anyone point me at a good VBScript book/Site that will help someone who knows perl to adapt? (Changing jobs is not an option at this point) Suggestions please folks The information contained in this e-mail is intended only for the individual or entity to whom it is addressed. Its contents (including any attachments) are confidential and may contain privileged information. If you are not an intended recipient you must not use, disclose, disseminate, copy or print its contents. If you receive this email in error, please delete and destroy the message and notify the sender by reply email. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help with learning VB Script (Please don't shout at me)
From: Crowder, Rod [EMAIL PROTECTED] As I said, please don't shout at me We wount shout. We pity you. A situation has arisen at work, where a new application which has been bought requires VB script to do pattern matching and string modification. Yes I know that it is easier in Perl, (and the app supports perl) but the PHB has decreed that the VBscript route is the the one to take. My question: Can anyone point me at a good VBScript book/Site that will help someone who knows perl to adapt? (Changing jobs is not an option at this point) What about changing the PHB? He aparently sticks his nose into issues he knows nothing about :-} Sorry I can't give you any book/site recommendation. Anyway ... it may be best to use Perl to implement the modifications, PerlCtrl to convert the library into a COM dll and then call your Perl functions from VBScript. The PHB will not notice and you'll stay sane. Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to look into every subdirectory
Hi - -Original Message- From: Prasad Karpur [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:18 AM To: [EMAIL PROTECTED] Subject: How to look into every subdirectory I am new to Perl and would like to know how to look into every subdirectory. Any help would be greatly appreciated. #!/usr/bin/perl #use strict; use Cwd; my $curr = cwd(); opendir(CURRDIR, $curr) or die can't open directory ($!), exiting.\n; my @files = readdir(CURRDIR); #closedir(CURRDIR); foreach my $file (sort @files) { next if $file eq '.' || $file eq '..'; next if !-d $file; if (-d $file) { print $file/\n; #Puts a slash in front of every directory it encounters } else { print $file\n; } } closedir(CURDIR); Just use a recursive subroutine to traverse your directory tree from any starting point: traverse (cwd()); sub traverse { my $dir = shift; $dir .= '/' unless $dir =~ m{/$}; opendir (DIR, $dir) || die unable to open directory $dir: $!\n; my @contents = readdir (DIR); closedir (DIR); for my $item (sort @contents) { my $di = $dir$item; next unless (-d $di); next if ($item eq '.' or $item eq '..'); print dir: $di\n; traverse ($di); } for my $item (sort @contents) { my $di = $dir$item; next if (-d $di); print file: $di\n; } } Try the above; WARNING: may contain typos! :) Also - check out File::Find on CPAN. Aloha = Beau; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Installing the Apache::Registry to get PERL working
Mo Elwaisi wrote: do i do this although i have apache installed on my server. it came with Red Hat Linux 8. (i have Apache 2.0.40)? even Apache is shipped with your Linux box, chances are that the source is not included. you will need to source to rebuild Apache to have mod_perl support. it's not very complicated. the instruction that i sent out yesterday should get you going without problem. simply installing a few Apache::... modules will NOT get your Apache to have mod_perl support. mod_perl is deeper intergrated with Apache than regular CGI scripts and you need to tell it (with Apache's source) how mod_perl intergrate with Apache. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Installing the Apache::Registry to get PERL working
thanks for all the help. one question though, you see when i am asked for where the apache src is located? i typed /tmp/httpd-2.0.40/src. but i got a message saying cannot stat '/tmp/httpd-2.0.40/src'. what shall i do From: david [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: Installing the Apache::Registry to get PERL working Date: Mon, 24 Feb 2003 18:00:32 -0800 Mo Elwaisi wrote: I have found that the reason PERL is not working is that the Apache Registry is not installed, so i typed perl -MCPAN -e shell; cpan install Apache::Registry i was then asked to locate where the Apache scr is, which i am not sure where it is so i typed /usr/sbin/httpd try the following steps (assuming you are root): 1. download http://www.apache.org/dist/httpd/apache_1.3.27.tar.gz and store it under /tmp 2. tar -zxf apache_1.3.27.tar.gz 3. Enter the following command: perl -MCPAN -e 'install(Bundle::Apache)' 4. Answer a few questions. when it ask you where is the Apache source, type: /tmp/apache_1.3.27/src 5. wait for everything to finish and then do the following: cd /tmp/apache_1.3.27 make install 7. make change to httpd.conf and restart Apache 6. you are done. if you encounter any problem, read: http://perl.apache.org/docs/1.0/guide/getwet.html and you will be done in 20 minutes. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Worried what your kids see online? Protect them better with MSN 8 http://join.msn.com/?page=features/parentalpgmarket=en-gbXAPID=186DI=1059 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Shifting
Hi, I've come across a dilemma, I can solve it the long way round, I'm enquiring if there's a shorter way to do this. I have an array, @data, which contains a lot of data which has been received from a socket. The problem is I want to have the 10th item (9th index) onwards. My way of doing this was: shift(@data); x 9 so that the first item in the array now is the first word of the data I wanted in the first place. Is there a shorter way to do this? I also have to alter the first index to remove a : which prefixes the first word in the array. Thanks in advance. Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Installing the Apache::Registry to get PERL working
Mo Elwaisi wrote: thanks for all the help. one question though, you see when i am asked for where the apache src is located? i typed /tmp/httpd-2.0.40/src. but i got a message saying cannot stat '/tmp/httpd-2.0.40/src'. what shall i do i am sure you downloaded the wrong thing. you need the following: http://www.apache.org/dist/httpd/apache_1.3.27.tar.gz when you downloaded that and untar it inside /tmp, you will see a /tmp/apache_1.3.27/src directory, there is no /tmp/httpd-2.0.40/src directory. make sure you download the right thing. davi -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Shifting
There are probably oodles of ways of doing this. Here are two: # An array slice @[EMAIL PROTECTED]; or # start at position 0, remove 9 elements splice @data, 0, 9; Pete On Tue, 2003-02-25 at 14:39, dan wrote: onwards. My way of doing this was: shift(@data); x 9 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Precedence Question ('and' vs '')
Basic question on using '' vs 'and'. I see that '' has higher precedence than 'and', but why does print 1 1 0; print \n; print 1 and 1 and 0; print \n; return 0 1 I would have expected both statements to return 0. Thanks Jeff __ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Precedence Question ('and' vs '')
Basic question on using '' vs 'and'. I see that '' has higher precedence than 'and', but why does print 1 1 0; print \n; print 1 and 1 and 0; print \n; return 0 1 I would have expected both statements to return 0. From a couple of experiments, I would guess that print has higher precedence than and. print 1 and print 0; prints both in order, it doesn't and the 1 from printing 0 to the literal 1 to print 01 as you get with print 1 print 0; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Win32::Process question
Hi All, I'm hoping someone has done this before. I need to spawn 3 processes and then wait for all three to finish. spawn like this: my $obj; my $appname = $perl; my $cmdline = $deliverscript $arg; my $iflags = 1; my $cflags = CREATE_NEW_CONSOLE | NORMAL_PRIORITY_CLASS; my $curdir = $localdir{$filetype}; my $Result1 = Win32::Process::Create( $obj1,$appname,$cmdline,$iflags,$cflags,$curdir ); my $Result2 = Win32::Process::Create( $obj2,$appname,$cmdline,$iflags,$cflags,$curdir ); my $Result3 = Win32::Process::Create( $obj3,$appname,$cmdline,$iflags,$cflags,$curdir ); but how can I tell when all three are finished? If I use $obj1-Wait(INFINITE); $obj2-Wait(INFINITE); $obj3-Wait(INFINITE); what happens if $obj2 finishes before $obj1? is there a way to check and see if a process ($obj1,$obj2,$obj3) is still running? Then I could try something like: while (1){ if ($obj-status and $obj-status and $obj-status) {last;} sleep (.2); } TIA, Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Precedence Question ('and' vs '')
On Tue, Feb 25, 2003 at 12:21:49PM -0800, Jeff Westman wrote: Basic question on using '' vs 'and'. I see that '' has higher precedence than 'and', but why does print 1 1 0; print \n; print 1 and 1 and 0; print \n; return 0 1 I would have expected both statements to return 0. s/return/print/g Running your program through perl -MO=Deparse,-p gives: print(0); print(\n); ((print(1) and 1) and '???'); print(\n); and has very low precedence. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Precedence Question ('and' vs '')
Thanks. The telling story is ((print(1) and 1) and ('???', '???')); Perl seems to be looking for another operator when using 'and'. -Jeff --- Paul Johnson [EMAIL PROTECTED] wrote: On Tue, Feb 25, 2003 at 12:21:49PM -0800, Jeff Westman wrote: Basic question on using '' vs 'and'. I see that '' has higher precedence than 'and', but why does print 1 1 0; print \n; print 1 and 1 and 0; print \n; return 0 1 I would have expected both statements to return 0. s/return/print/g Running your program through perl -MO=Deparse,-p gives: print(0); print(\n); ((print(1) and 1) and '???'); print(\n); and has very low precedence. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net __ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
wrestling with `eval'
I posted here a while back about how to set the parameters of an s/// type of action, inside a script from the cmdline. Paul posted a simple script in answer that does exactly that. and even allows any modifier to be set from cmdline. (Slightly modified for clarity) cat example1.pl #!/usr/bin/perl -wp BEGIN { our($regex,$repl,$mod) = (shift,shift,shift||'') } eval s/$regex/$repl/$mod; Results: echo something|./example1.pl '(some)(.*$)' '$1one' someone Paul explained in brief how and why this works but I'm having trouble integrating this into a more complex script, can't seem to find the error of my attempts. The script is awfully contrived but the idea is to get this to work in a script employing Getopts::Std or other complications. In the example below the input is expected to come from files so I dropped the -p part. In this contrived case the input file contains only the one line something I know my script is wrong but have tried a number of variations. All failed. Its apparent I'm lacking some basic knowledge about eval here. With a command line like: ./example2.pl -s '(some)(.*$)' '$1one' cat example2.pl #!/usr/local/bin/perl -w $file = ./input; use vars qw($opt_s); use Getopt::Std; my $optstr =s:; getopts($optstr); if ($opt_s) { $regex = $opt_s; BEGIN { our ($repl,$mod) = (shift,shift||'') } } open(FILE,$file) or die; # NOW how to use eval here while(FILE){ chomp; # how can I make these variables be seen as a legitimate piece # of perl code? And print the result # eval $_ =~ s/$regex/$repl/$mod; # print... } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How do I return multiple discrete arrays and/or hashes from a subroutine?
Hello: I know I can return multiple scalar values from a subroutine using an array, but how do I return multiple arrays, hashes, etc from a subroutine? For example, the following snippet... my @ip_addresses = getIPAddresses; my (@hostfile, @no_dname) = getHostNames(@ip_addresses); print \nHOSTFILE: , scalar @hostfile,\n,@hostfile; print \nNO_DNAME: , scalar @no_dname,\n,@no_dname; Generates this for output... HOSTFILE: 411 NO_DNAME: 0 When what I REALLY want returned is this: (valid data) HOSTFILE: 44 NO_DNAME: 367 The subroutine I'm using looks like this: sub getHostNames { my (@hostfile,@no_dname,$bitbucket,$hostname); foreach my $ip_address (@ip_addresses) { my @results = `/usr/sbin/nslookup $ip_address 21`; chomp @results; foreach (@results) { # [PARSE OUTPUT HERE] } } @hostfile, @no_dname; } Obviously the subroutine assignments are just merging the contents of the last subroutine evaluation statement (@hostfile, @no_dname), and is returning the merged values to the first variable (@hostfile/411 elements). How can I return discrete arrays and hashes from a subroutine? Grateful for any help! Lance -- This message may contain confidential information, and is intended only for the use of the individual(s) to whom it is addressed. ==
RE: How do I return multiple discrete arrays and/or hashes from a subroutine?
how do I return multiple arrays, hashes, etc from a subroutine? You can't... but you can return references. my ($x, $y) = foo(); # returns 2 references my @x = @{$x}; # dereference back to an array my @y = %{$y}; # dereference back to a hash sub foo { my @x = (1,2,3); my %y = (k1 = 1, k2 = 2); return ([EMAIL PROTECTED], \%y); } ...You can dereference the variables when you get them back, or you can use the references directly. my ($x, $y) = foo(); # returns 2 references $x-[1]; # index #1 of the array $y-{k1}; # the key k1 of that hash For more info check out the perldocs for perlreftut. Rob -Original Message- From: Lance Murray [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 5:05 PM To: [EMAIL PROTECTED] Subject: How do I return multiple discrete arrays and/or hashes from a subroutine? Hello: I know I can return multiple scalar values from a subroutine using an array, but how do I return multiple arrays, hashes, etc from a subroutine? For example, the following snippet... my @ip_addresses = getIPAddresses; my (@hostfile, @no_dname) = getHostNames(@ip_addresses); print \nHOSTFILE: , scalar @hostfile,\n,@hostfile; print \nNO_DNAME: , scalar @no_dname,\n,@no_dname; Generates this for output... HOSTFILE: 411 NO_DNAME: 0 When what I REALLY want returned is this: (valid data) HOSTFILE: 44 NO_DNAME: 367 The subroutine I'm using looks like this: sub getHostNames { my (@hostfile,@no_dname,$bitbucket,$hostname); foreach my $ip_address (@ip_addresses) { my @results = `/usr/sbin/nslookup $ip_address 21`; chomp @results; foreach (@results) { # [PARSE OUTPUT HERE] } } @hostfile, @no_dname; } Obviously the subroutine assignments are just merging the contents of the last subroutine evaluation statement (@hostfile, @no_dname), and is returning the merged values to the first variable (@hostfile/411 elements). How can I return discrete arrays and hashes from a subroutine? Grateful for any help! Lance -- This message may contain confidential information, and is intended only for the use of the individual(s) to whom it is addressed. == -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: help with nearly identical hash keys
something like: foreach my $key( keys %hashA ){ if( $hashB{$key}){ printdo the dance of joy, duplicate key found } } should do the trick. Aimal Pashtoonmal [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello people, Can any one please help me. I have 2 hashes, hashA and hashB, the keys in both cases, are made up of a mixture of numbers and words etc. But the keys are differnt so I presume I cannot use if exits or if defined. Is there anyway of check to see if the words and numbers making up the keys of hashB are present in the keys of hashA? ie: initially I check if a certain word is present in key of hashA, such as if ( $key =~ /WORD1/ ) { then the key of hashA looks like: 12334RET456WORD1W56778 sp_entry14300.001T (the value for this key is say 1234.1) and the corresponding key of hashB looks like: 1234.1A1sp_entry 14300.001 (the value for this key is say 1234.1.A1 ) What I am trying is if the key of hashA contain s sp_entry 14 30 0.001 ; then to print the value held by the current key of hashB (1234.1.A1) followed by the entire current key of hashA (12334RET456WORD1W56778sp_entry14300.001 T) so that the final output is: 1234.1.A112334RET456WORD1W56778sp_entry14 300.001T (all on the same line). The mixture of words and numbers in the keys are seperated by a tab. Thanks in advance for reading and reading with a reply. cheers all, amal -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic Hash Naming and multi-dimensional hashes
if you are just trying to access a set of nested arrays, use something like my @parent=([1,2,3], [7,8,9]); print $parent[0][1]\n;# outputs 2 print $parent[1][2]\n;# outputs 9 ## now to access the the info, use references foreach my $num(@parent){ foreach my $kid(@$num){ print $kid\n; } } check out 'Learning Perl', 'Programming Perl' and the 'Perl Cookbook' for excellent examples. also 'perldoc perlref' at your shell prompt should pull up the perl reference info, but it is a little esoteric... www.perldoc.com is a great source of info as well. #Create a multi-dimensional array my @parent= (@array1, @array2); #Spit out the info in the arrays foreach $i ($parent($array1)) { print $parent($array1[$i]) is part of $parent($array2[$i])\n; } Sorry, I can't figure out at all what you're trying to do here. The first statement does not create a multi-dimensional array. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Perl grep clone
OK, I am not having any luck figuring out the regex stuff.. Can somebody share with me a perl version of grep that works or tell me the Perl Expression for this..The reason I need something like perl is because the 2048 character limitation on grep... We have situations where the line can be much longer than that.. Thanks. Steve. We need to be able to use the -c (count) and -h (suppress filename) thanks, Steve. counting lines: node13:/prod/app$ grep -c .* ./client/tmp/BATCH/failed/in/PPR_RESP.log 1858571 node13:/prod/app$ peg -c .* ./client/tmp/BATCH/failed/in/PPR_RESP.log peg: error in Perl expression: (.*) syntax error at (eval 1) line 1, near (. node13:/prod/app$ AND search for lines with . (period) in the search string node13:/prod/app/data/journal$ grep RES\.1\.25 sjl RES.1.2504178found RES.1.250417RES.1.250417RES.1.250417RES.1.250417 RES.1.250417RES.1.250417RES.1.250417RES.1.250417 node13:/prod/app/data/journal$ peg RES\.1\.25 sjl peg: error in Perl expression: (RES\.1\.25) Backslash found where operator expected at (eval 1) line 1, near RES\ Backslash found where operator expected at (eval 1) line 1, near .1\ (Missing operator before \?) syntax error at (eval 1) line 1, near RES\ node13:/prod/app/data/journal$ #!/usr/local/bin/perl -w my $VERSION = '1.00'; my $Usage = Usage: peg [options|-help] perlexpr [files]\n; my ($Dirs_specified, $Eval, $Implicit_C, $No_slurp); my (@Files, %Options, @Perlexpr, @Warnings) = (); my ($After, $Before) = (2, 2); my $Perlexpr = ''; $SIG{'__WARN__'} = sub { push @Warnings, @_; }; process_ARGV(); check_Perlexpr(); $g ||= $s; find_files() if ($d || $r); build_Eval(); show_debug() if $D; reset 'a-z'; eval $Eval; die \npeg: run time eval error:\n, @Warnings, $@, \n...when eval'ing:\n$Eval\n...with input:\n$_\n; sub process_ARGV { my $options = 1; my $context = 'C'; if ($_ = $ENV{'PEG_OPTIONS'}) { unshift @ARGV, (/^-/ ? $_ : -$_); } while (defined ($_ = shift @ARGV)) { if ($f) { open(F, $_) || die peg: can't open $_: $!\n; while (F) { chomp; push @Perlexpr, $_ unless /^$/; } close F; $f = 0; } elsif ($options s/^-(?=.)//) { /^help$/ help(); while (s/^(.)//) { my $opt = $1; if ($opt =~ /^[abcdfghilnoqrstvwxyABCDEFGHLNOPQSTXYZ]$/) { ${$opt} = $Options{$opt} = 1; $context = $opt if ($opt =~ /^[ABC]$/); } elsif ($opt =~ /^\d$/) { while (s/^(\d)//) { $opt = (10 * $opt) + $1; } $After = $opt if ($context ne 'B'); $Before = $opt if ($context ne 'A'); $Implicit_C = 1; } elsif ($opt eq '-') { $options = 0; } elsif ($opt eq 'V') { die peg v$VERSION (Dec 1999)\n; } else { die peg: illegal option -- $opt\n$Usage; } } } elsif ([EMAIL PROTECTED] || (($o || $O) $options)) { push @Perlexpr, $_; } else { push @Files, $_; } } die $Usage unless @Perlexpr; } # process_ARGV sub check_Perlexpr { my $regexp = $G || $Q || $i || $w || $x; foreach (@Perlexpr) { ($Q !$E) || ($No_slurp ||= /[\^\$]/); next if ($E || !($regexp || /^\w+$/)); $Q ? ($_ = quotemeta($_)) : (s/\//\\\//g); $_ = '\b' . $_ . '\b' if ($w !$x); $_ = '^' . $_ . '$' if $x; $_ = '/' . $_ . '/'; $_ .= 'i' if $i; } if ($O) { $Perlexpr .= join(,\n\t, map({(\$Match$_ ||= ( . $Perlexpr[$_] . ))} (0..$#Perlexpr)), ('(' . join(' ', map {\$Match$_} (0 .. $#Perlexpr)) . ')')); } else { $Perlexpr = join(\n\t|| , map {($_)} @Perlexpr); } $Perlexpr = 'not (' . $Perlexpr . ')' if $v; local ($a, $b, $c, $d, $f, $g, $h, $i, $l, $n, $o, $q, $r, $s, $t, $v, $w, $x, $y, $A, $B, $C, $D, $E, $F, $G, $H, $L, $N, $O, $P, $Q, $S, $T, $X, $Y, $Z); eval \$_ = ''; if ($Perlexpr) {}; die peg: error in Perl expression: $Perlexpr\n, @Warnings, $@ if $@; } # check_Perlexpr sub find_files { if ($d @Files) { my ($start_dir, $dir, @dirs, @files); foreach (@Files) { (-d $_) ? push @dirs, $_ : push @files, $_; } if ($Dirs_specified = @dirs) { @Files = @files; require Cwd; $start_dir = Cwd::cwd() || die peg: cannot determine current directory\n; foreach $dir (@dirs) { chdir($dir) || (($s || print STDERR peg: can't chdir to $dir: $!\n), next); find($dir); chdir($start_dir) || die peg: can't chdir back to starting directory $start_dir: $!\n; } } } find('.') if $r; if ([EMAIL PROTECTED] ($r || ($d $Dirs_specified)) !$X) { print STDERR peg: no files found\n if !$s; exit(1); } } # find_files sub find { my $cwd = shift; my (@f, $f, $ff); opendir(DIR, '.') || (($g || print STDERR peg: can't opendir $cwd: $!\n), return); @f = readdir DIR; closedir DIR; foreach $f (@f) { next if ($f eq '.' || $f eq '..'); $ff = $cwd/$f; lstat $f; if (-d _) {
Re: How to look into every subdirectory
www.perldoc.com search for File::Find. It does the recursion for you! Prasad Karpur [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I am new to Perl and would like to know how to look into every subdirectory. Any help would be greatly appreciated. #!/usr/bin/perl #use strict; use Cwd; my $curr = cwd(); opendir(CURRDIR, $curr) or die can't open directory ($!), exiting.\n; my @files = readdir(CURRDIR); #closedir(CURRDIR); foreach my $file (sort @files) { next if $file eq '.' || $file eq '..'; next if !-d $file; if (-d $file) { print $file/\n; #Puts a slash in front of every directory it encounters } else { print $file\n; } } closedir(CURDIR); __ The NEW Netscape 7.0 browser is now available. Upgrade now! http://channels.netscape.com/ns/browsers/download.jsp Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: good general programming book?
Daryl [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Well your in the wrong place for language neutral advise: however, Elements of Programming with Perl by Manning Press - gives a good grounding in the thought process needed utilizing Perl as the language. I am going through this back now. It is a great book and I am learning a lot with it. The author is online at the Manning site as well and is very responsive in the forums. Bob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
FW: Win32::Process question
but how can I tell when all three are finished? If I use $obj1-Wait(INFINITE); $obj2-Wait(INFINITE); $obj3-Wait(INFINITE); what happens if $obj2 finishes before $obj1? looks like this works fine... PHF -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How do I return multiple discrete arrays and/or hashes from a subroutine?
Have a look at: % perldoc perlsub Esentially you can't return multiple array's (you probably can with fancy prototyping - but i'm not sure of that) - you usually have to use references instead. On Wed, 2003-02-26 at 09:05, Lance Murray wrote: Hello: I know I can return multiple scalar values from a subroutine using an array, but how do I return multiple arrays, hashes, etc from a subroutine? For example, the following snippet... my @ip_addresses = getIPAddresses; my (@hostfile, @no_dname) = getHostNames(@ip_addresses); print \nHOSTFILE: , scalar @hostfile,\n,@hostfile; print \nNO_DNAME: , scalar @no_dname,\n,@no_dname; Generates this for output... HOSTFILE: 411 NO_DNAME: 0 When what I REALLY want returned is this: (valid data) HOSTFILE: 44 NO_DNAME: 367 The subroutine I'm using looks like this: sub getHostNames { my (@hostfile,@no_dname,$bitbucket,$hostname); foreach my $ip_address (@ip_addresses) { my @results = `/usr/sbin/nslookup $ip_address 21`; chomp @results; foreach (@results) { # [PARSE OUTPUT HERE] } } @hostfile, @no_dname; } Obviously the subroutine assignments are just merging the contents of the last subroutine evaluation statement (@hostfile, @no_dname), and is returning the merged values to the first variable (@hostfile/411 elements). How can I return discrete arrays and hashes from a subroutine? Grateful for any help! Lance -- This message may contain confidential information, and is intended only for the use of the individual(s) to whom it is addressed. == -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Removing a string from within a string
Hey again. I have another problem, I have a string of nicknames that looks like: $mystring1 = nick1,nick2,nick3,nick4,nick5; I've asked this question before, but because of my bad regex knowledge, I'm asking again, but this time in a slightly different context. The last time I asked, the string was: $mystring2 = nick1 nick2 nick3 nick4 nick5; and I was given this regex: (assume $src contains nick3) $mystring2 =~ s/(\s|^)\Q$src\E(?=\s|$)//g; I was told that this would remove the trailing space after $src, but since now there is no trailing space, just a comma instead. What's the alteration I need to make to this to remove $src from $mystring1? Thanks in advance. Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Removing a string from within a string
dan wrote: Hey again. I have another problem, I have a string of nicknames that looks like: $mystring1 = nick1,nick2,nick3,nick4,nick5; I've asked this question before, but because of my bad regex knowledge, I'm asking again, but this time in a slightly different context. The last time I asked, the string was: $mystring2 = nick1 nick2 nick3 nick4 nick5; and I was given this regex: (assume $src contains nick3) $mystring2 =~ s/(\s|^)\Q$src\E(?=\s|$)//g; I was told that this would remove the trailing space after $src, but since now there is no trailing space, just a comma instead. What's the alteration I need to make to this to remove $src from $mystring1? Thanks in advance. Dan Replace the \s with a , and it will work for you. Wags ;) ** This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
delete paragraphs
I have a file test2 with the format of: [Kent] Address:3473278 jones omaha, ne 65465 Phone: Home 8943, Work 83485, Cell 84853 Email: Home @j.cor, Work Birthdate: 88484 [Pat] Address:747474 street where, CA 848484 Phone: Home 555-, Work 333-, Cell 222-2 Email: Home [EMAIL PROTECTED], Work Birthdate: 8-4-4 I'm trying to delete in place a paragraph, if a name match is found. The following code does not work but I think it should:) What am I doing wrong? #!/usr/bin/perl use strict; use warnings; open FILE, '+test2' || die $!; chomp (my $name = @ARGV); $^I; $/ = ; while (FILE) { if (/^\[$name/i) { s/.//g; } } Thanks, kent -- To know the truth is to distort the Universe. Alfred N. Whitehead (adaptation) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic Hash Naming and multi-dimensional hashes
I've played tag the wall with the forehead long enough. a) a way to name a hash from user input If you mean assign a value with in a hash using the user input, then: my %hash $key = STDIN; $val = STDIN; $hash{$key} = $val; If you really want to let the user name your variables for you (which you probably really don't want), you would use eval; $hashname = STDIN; eval (\$$hashname;); don't do that though... b) find a way to create a multi-level hash (hash within a hash) This is done with references. They only seem hard at first. here's a hash: %happy_hash = ( smile = :), bigger= :D, ); here's another: %another_hash = ( far = Look over There!, near = Look at this!, ); now here's a third that holds the first two: %big_hash = ( happy = \%happy_hash, another = \%another_hash, ); the back slash means that the variable refers to the hash, but is not really the hash. This way you get a scalar (which is what hashes are made of), but you can use it to get to the hash. here's one syntax to get to the hash: $big_smile = ${$big_hash{happy}}{bigger}; # you can probably get away with $big_hash{happy}{bigger}, # and it doesn't look as confusing, but I use the previous syntax. $big_hash{happy} returns the reference to the happy_hash, just as this would assign it to a scalar: $hrHappy = $big_hash{happy}; To dereference this to the hash is %{$big_hash{happy}}. Just wrap the scalar in braces and stick the appropriate symbol on front ($%@*) for $hrHappy it's %{$hrHappy} Now you can access the value in the hash; just like a regular hash, but with a weird lookin' name. The syntax is $hashname{key}, so here it's ${$big_hash{happy}}{bigger} or ${$hrHappy}{bigger}, both of which return $happy_hash{bigger}, which is :D Ofcourse, why put hashes that have names in other hashes unless you have a good reason? So there are anonymous hashes. They look like this: {smile = :), bigger = :D} and you can assign them just like a hash reference: %big_hash = ( happy = { smile = :), bigger= :D, }, another = { far = Look over There!, near = Look at this!, }, ); and create them on the fly too: ${$big_hash{onion}}{burger} = beefy; ${$big_hash{onion}}{ring} = greasy; $big_hash{foul} = {bird = duck, ball = strike}; And hopefully code that looked illegible before is starting to make some sense. #Create a multi-dimensional array same thing: @big_arr = ([EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]); even: @hash_arr = (\%hash1, \%hash1, \%hash1); or: @mixed_arr = (\%hash1, [EMAIL PROTECTED], \%big_hash, [EMAIL PROTECTED]); There are lots of fun ways to build data structures using references. You can create anonymous subroutines too, and put those in a hash. HTH -Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Removing a string from within a string
I have another problem, I have a string of nicknames that looks like: $mystring1 = nick1,nick2,nick3,nick4,nick5; I've asked this question before, but because of my bad regex knowledge, I'm asking again, but this time in a slightly different context. The last time I asked, the string was: $mystring2 = nick1 nick2 nick3 nick4 nick5; and I was given this regex: (assume $src contains nick3) $mystring2 =~ s/(\s|^)\Q$src\E(?=\s|$)//g; I was told that this would remove the trailing space after $src, but since now there is no trailing space, just a comma instead. What's the alteration I need to make to this to remove $src from $mystring1? Replace the \s with a , and it will work for you. It actually replaces the leading comma, so if $src contains nick1 you're going to still have a leading space (now comma) on the string. It also replaces all occurrences of $src in the string. If you want it to work 'right' (i.e., snip the trailing comma if it is at the beginning of the string, and the leading comma if it isn't), then try: $mystring1 =~ s/(,)?\Q$src\E(,)?/$2?($1||''):''/ge; /\/\ark -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Perl grep clone
[EMAIL PROTECTED] wrote: OK, I am not having any luck figuring out the regex stuff.. Can somebody share with me a perl version of grep that works or tell me the Perl Expression for this. http://www.perl.com/language/ppt/src/grep/index.html http://www.perl.com/language/ppt/src/egrep/index.html http://www.perl.com/language/ppt/src/fgrep/index.html John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: wrestling with `eval'
Harry Putnam wrote: I posted here a while back about how to set the parameters of an s/// type of action, inside a script from the cmdline. Paul posted a simple script in answer that does exactly that. and even allows any modifier to be set from cmdline. (Slightly modified for clarity) cat example1.pl #!/usr/bin/perl -wp BEGIN { our($regex,$repl,$mod) = (shift,shift,shift||'') } eval s/$regex/$repl/$mod; Results: echo something|./example1.pl '(some)(.*$)' '$1one' someone Paul explained in brief how and why this works but I'm having trouble integrating this into a more complex script, can't seem to find the error of my attempts. The script is awfully contrived but the idea is to get this to work in a script employing Getopts::Std or other complications. In the example below the input is expected to come from files so I dropped the -p part. In this contrived case the input file contains only the one line something I know my script is wrong but have tried a number of variations. All failed. Its apparent I'm lacking some basic knowledge about eval here. With a command line like: ./example2.pl -s '(some)(.*$)' '$1one' ^ That won't work because it be interpreted as the variable $1one instead of the variable $1 followed by the string 'one'. You need to put parens around the variable name like this: ./example2.pl -s '(some)(.*$)' '${1}one' cat example2.pl #!/usr/local/bin/perl -w $file = ./input; use vars qw($opt_s); use Getopt::Std; my $optstr =s:; getopts($optstr); if ($opt_s) { $regex = $opt_s; BEGIN { our ($repl,$mod) = (shift,shift||'') } You are not using either the -p or -n switch so you don't need this in a begin block. } open(FILE,$file) or die; You should include the $! variable in the error message so you know WHY it failed. # NOW how to use eval here while(FILE){ chomp; # how can I make these variables be seen as a legitimate piece # of perl code? And print the result # eval $_ =~ s/$regex/$repl/$mod; # print... } Your substitution operator will work like this: s/(?$mod:$regex)/qq($repl)/ee; print; The /ee does the eval but just on the replacement half, not the whole expression. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How do I return multiple discrete arrays and/or hashes from a subroutine?
Lance Murray wrote: Hello: Hello, I know I can return multiple scalar values from a subroutine using an array, but how do I return multiple arrays, hashes, etc from a subroutine? You have to return references to arrays and hashes. This is all explained in the perlsub document. perldoc perlsub For example, the following snippet... my @ip_addresses = getIPAddresses; ^ perlsub also explains why you shouldn't use the Perl4 form of calling subs anymore. Is there any reason you are not using perl's builtin networking functions like gethostbyname() and gethostbyaddr()? perldoc -f gethostbyaddr perldoc -f gethostbyname my (@hostfile, @no_dname) = getHostNames(@ip_addresses); print \nHOSTFILE: , scalar @hostfile,\n,@hostfile; print \nNO_DNAME: , scalar @no_dname,\n,@no_dname; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: pass cmdline var to this syntax s/$var/$revar/
John, Somehow I over looked your answer to my question and have since posted a couple more similar questions. Your answer here pretty much provides a way to make my scripts work Thanks. If possible, please note my comments in the code below and point me to something that will allow me to understand what is happening in that syntax. John W. Krahn [EMAIL PROTECTED] writes: Harry Putnam wrote: Something I'm messing with today and can't get right. I've presented a simplified version of what I'd like to do. It amounts to setting the strings inside a s/some_re/some_rep/ type action. I can get it to work fine if both elements are simple and don't involve grouping and back reference. But grouping and back reference would make my script (the real one ) considerably more versatile. Examples: cat rein.pl #!/usr/local/bin/perl -w $strp_re = shift; You COULD compile this to a regex now which is a bit more efficient. my $strp_re = qr/@{[shift]}/; I find `qr' explained very briefly in `Programming Perl [3rd]' but not enough to understand what role these play = [EMAIL PROTECTED]' I understand what shift is doing but not the rest. $rein_str = shift; while(){ chomp; $pre_out = $_; ($out = $pre_out) =~ s/$strp_re/$rein_str/; ($out = $pre_out) =~ s/$strp_re/qq[$rein_str]/ee; I find no reference to `qq' used like this in `Programming Perl [3rd]'. Ditto for a double `ee' in this context. I can sort of see what is happing ... That is, $rein_str is being presented to the interpreter in such a way that it knows how to read it. But not clear what all is happening here. print $out\n; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: delete paragraphs
Ktb wrote: I have a file test2 with the format of: [Kent] Address:3473278 jones omaha, ne 65465 Phone: Home 8943, Work 83485, Cell 84853 Email: Home @j.cor, Work Birthdate: 88484 [Pat] Address:747474 street where, CA 848484 Phone: Home 555-, Work 333-, Cell 222-2 Email: Home [EMAIL PROTECTED], Work Birthdate: 8-4-4 I'm trying to delete in place a paragraph, if a name match is found. The following code does not work but I think it should:) What am I doing wrong? #!/usr/bin/perl use strict; use warnings; open FILE, '+test2' || die $!; chomp (my $name = @ARGV); You are using the operator improperly here. It can be used as either readline() or glob() and in this context it is doing a file glob. $^I; $/ = ; while (FILE) { if (/^\[$name/i) { s/.//g; } } You have to have the file name in @ARGV and you have to set $^I to SOME value for perl's in-place editing to work. #!/usr/bin/perl use strict; use warnings; my $name = shift; @ARGV = 'test2'; $^I = ''; $/ = ''; while ( ) { next if /^\[$name/i; print; } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: pass cmdline var to this syntax s/$var/$revar/
Harry Putnam wrote: John, Somehow I over looked your answer to my question and have since posted a couple more similar questions. Your answer here pretty much provides a way to make my scripts work Thanks. If possible, please note my comments in the code below and point me to something that will allow me to understand what is happening in that syntax. John W. Krahn [EMAIL PROTECTED] writes: Harry Putnam wrote: Something I'm messing with today and can't get right. I've presented a simplified version of what I'd like to do. It amounts to setting the strings inside a s/some_re/some_rep/ type action. I can get it to work fine if both elements are simple and don't involve grouping and back reference. But grouping and back reference would make my script (the real one ) considerably more versatile. Examples: cat rein.pl #!/usr/local/bin/perl -w $strp_re = shift; You COULD compile this to a regex now which is a bit more efficient. my $strp_re = qr/@{[shift]}/; I find `qr' explained very briefly in `Programming Perl [3rd]' It should be in the documentation installed on your hard disk along with Perl. perldoc perlop but not enough to understand what role these play = [EMAIL PROTECTED]' I understand what shift is doing but not the rest. The @{[]} idiom allows an expression or function to be evaluated in a double quoted string. Without that it would be a two step process like this: my $strp_re = shift; $strp_re = qr/$strp_re/; $rein_str = shift; while(){ chomp; $pre_out = $_; ($out = $pre_out) =~ s/$strp_re/$rein_str/; ($out = $pre_out) =~ s/$strp_re/qq[$rein_str]/ee; I find no reference to `qq' used like this in `Programming Perl [3rd]'. Ditto for a double `ee' in this context. I can sort of see what is happing ... That is, $rein_str is being presented to the interpreter in such a way that it knows how to read it. But not clear what all is happening here. The /e option eval()s the replacement string however, because you have back-reference variables ($1, $2, etc.) in the replacement string you have to wrap it in double quotes for each eval. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help need in GUI
zentara wrote: You must install Tk, it's a separate module. Plus the program needs a MainLoop statement. It depends on the Perl version. When I tried to install Tk on Perl 5.6.1, I got an error message saying it was already installed. I tried the code posted in: Subject: Re: How do you 'read' from a Tk widget ? Date: Fri, 21 Feb 2003 07:31:23 -0500 From: Steve Lobach [EMAIL PROTECTED] and it worked fine. It might be better to just upgrade to 5.8. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: pass cmdline var to this syntax s/$var/$revar/
John W. Krahn [EMAIL PROTECTED] writes: $rein_str = shift; while(){ chomp; $pre_out = $_; ($out = $pre_out) =~ s/$strp_re/$rein_str/; ($out = $pre_out) =~ s/$strp_re/qq[$rein_str]/ee; I find no reference to `qq' used like this in `Programming Perl [3rd]'. Ditto for a double `ee' in this context. I can sort of see what is happing ... That is, $rein_str is being presented to the interpreter in such a way that it knows how to read it. But not clear what all is happening here. The /e option eval()s the replacement string however, because you have back-reference variables ($1, $2, etc.) in the replacement string you have to wrap it in double quotes for each eval. Probably being very dense here but something still confusing me. qq means double quotes but then are already around $rein_str, so do we have double double quotes? And does 'ee' mean double eval? I think I'm still missing something basic here. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
parsing uploaded csv file from HTTP
Hi I'm trying to parse an uploaded csv file. From the HTTP info I have a string that looks like this Content-Disposition: form-data; name=afile; filename=C:\myfolder\mytest.csv Content-Type: application/octet-stream 12345678,John Doe 79696676,Superman 215154552,Wilfred DeSilva 216215,Bart Simpson -7d336333d1034e-- with some difficulty I've managed to jury-rig a regex $data =~ m/(.*[:]\\.*\s.*\s\W+)([\w+\,\w+\s\w+\r\n]+)(-+\w+-{2}\s$)/g; which gives me 12345678,John Doe 79696676,Superman 215154552,Wilfred DeSilva 216215,Bart Simpson Unfortunately if the CSV file has punctuation (Wilfred De'Silva) everything falls in a heap. How can I pull out the data without relying on $2 ([\w+\,\w+\s\w+\r\n]+) which seems to be the bit that grabs the CSV values Running ASP on WinNT box with PerlScript Help appreciated Clinton -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic Hash Naming and multi-dimensional hashes
Hendricks Paul D A1C 27 IS/INYS wrote: Hello beginners! Where do I start... I've already done some reading on this and I've played tag the wall with the forehead long enough. What I'm challenging myself to do is to create: a) a way to name a hash from user input Don't. If you really want to have some basic value for the hash to come from input, then add a 'name' key to the hash, and assign the user-submitted name to that. $myHash{'name'} = shift; Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: help with nearly identical hash keys
Here's a simpler example that contains some tools that might be useful to you. (Sorry for the lazy hash declarations.) If you explain the bigger picture, you might get suggestions for data structures that can be manipulated more simply. Katy my %one = qw(_cat peach _dog apple _mouse apricot _rat tangerine _bat strawberry _snake loquat); my %two = qw(fox mango wolf blueberry zebra kumquat rat banana bat papaya ratsnake pear bird orange); my %keys = reverse map { /(_(.*))/ } keys %one; my $ors = join('|', keys %keys); foreach (grep { /$ors/ } keys(%two)) { print $_ $one{$keys{$_}}\n if defined($keys{$_}); } On Tue, 25 Feb 2003 15:34:04 +, Aimal Pashtoonmal [EMAIL PROTECTED] wrote: Hello people, Can any one please help me. I have 2 hashes, hashA and hashB, the keys in both cases, are made up of a mixture of numbers and words etc. But the keys are differnt so I presume I cannot use if exits or if defined. Is there anyway of check to see if the words and numbers making up the keys of hashB are present in the keys of hashA? ie: initially I check if a certain word is present in key of hashA, such as if ( $key =~ /WORD1/ ) { then the key of hashA looks like: 12334RET456WORD1W56778 sp_entry14300.001T (the value for this key is say 1234.1) and the corresponding key of hashB looks like: 1234.1A1sp_entry 14300.001 (the value for this key is say 1234.1.A1 ) What I am trying is if the key of hashA contain s sp_entry 14 30 0.001 ; then to print the value held by the current key of hashB (1234.1.A1) followed by the entire current key of hashA (12334RET456WORD1W56778sp_entry14300.001 T) so that the final output is: 1234.1.A112334RET456WORD1W56778sp_entry14 300.001T (all on the same line). The mixture of words and numbers in the keys are seperated by a tab. Thanks in advance for reading and reading with a reply. cheers all, amal -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: parsing uploaded csv file from HTTP
It's late so maybe I'm missing something, but here's one way: #throw away the header and keep everything after application/octet-stream my($junk,$data2) = split(/application\/octet-stream/,$data); #split the rest up by commas and put it into an array my @records = split(/,/,$data2); Then it's all in a neat little array. This is, of course, assuming that you don't have any data in your file that has a comma in it... -Original Message- From: Clinton [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 10:34 PM To: [EMAIL PROTECTED] Subject: parsing uploaded csv file from HTTP Hi I'm trying to parse an uploaded csv file. From the HTTP info I have a string that looks like this Content-Disposition: form-data; name=afile; filename=C:\myfolder\mytest.csv Content-Type: application/octet-stream 12345678,John Doe 79696676,Superman 215154552,Wilfred DeSilva 216215,Bart Simpson -7d336333d1034e-- with some difficulty I've managed to jury-rig a regex $data =~ m/(.*[:]\\.*\s.*\s\W+)([\w+\,\w+\s\w+\r\n]+)(-+\w+-{2}\s$)/g; which gives me 12345678,John Doe 79696676,Superman 215154552,Wilfred DeSilva 216215,Bart Simpson Unfortunately if the CSV file has punctuation (Wilfred De'Silva) everything falls in a heap. How can I pull out the data without relying on $2 ([\w+\,\w+\s\w+\r\n]+) which seems to be the bit that grabs the CSV values Running ASP on WinNT box with PerlScript Help appreciated Clinton -- 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 look into every subdirectory
Beau == Beau E Cox [EMAIL PROTECTED] writes: Beau Hi - Beau Just use a recursive subroutine to traverse your directory tree Beau from any starting point: No no. You ignore the problem of symlinks. Please use File::Find, unless you really understand File::Find's every behavior. -- 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! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How do I recursively look in every directory
John == John W Krahn [EMAIL PROTECTED] writes: John Prasad Karpur wrote: I am new to perl. I would like to look into every directory below my home directory and look for files in it. [snip] Any Help would be greatly appreciated. John Use the File::Find module. John perldoc File::Find I have many examples of this module (including a two-parter that recently appeared in Linux Magazine) on my site. Google for site:stonehenge.com File::Find for the examples. 43 hits at the moment. -- 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! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]