permissions
Hi, I have a site running locally under /home/me/public_html. With sub-folders of cgi_bin and data. What are considered to be the best permissions for the directories and files. I want to copy this accross to a server. Data files are created dynamically from a script running on the local machine, so only two or three cgi scripts need to run on the server. Many thanks Francesco -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Best Practices: Error Handling???
Try the Error.pm module. You can find it at: http://search.cpan.org/doc/MSERGEANT/AxKit-1.4/Error-0.13/Error.pm Brad Handy --www.jack-of-all-trades.net --mailto:[EMAIL PROTECTED] -Original Message- From: David Simcik [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 14, 2001 10:52 AM To: Perl Cgi Subject: Best Practices: Error Handling??? I've been perusing the Camel book, the Cookbook, CGI Programming w/Perl, and Effective Perl for answers to this question, but have yet to find one or two definitive solutions. I've seen the standard die/eval() statements and the use of the various incarnations of Carp, but I have yet to see anyone say something along the lines of this is the most common approach. I find myself longing for the consistency of try/catch blocks. Can anyone shed some light on the situation? Regards, DTS -- 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: which one to choose WxPerl or perlTk
On Thursday 09 August 2001 12:16, Dinakar Desai wrote: Hello: I was wondering which one to learn in terms of GUI. I am not very familiar with any GUI application development. I am just exploring the possibilities of GUI tool kits. I would like to know your experience in terms of stability, maturity and usability of WXPerl and PerlTk GUI tool kits. I really appreciate your comments.. Thank you. dinakar Content-Type: text/plain; charset=us-ascii; name=Attachment: 1 Content-Transfer-Encoding: 7bit Content-Description: I found PerlTK very easy to use, it works very well for what I used it for , a GUI to a data base program. Greg -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Beginning CGI
--- Eric Wang [EMAIL PROTECTED] wrote: Can you run CGI on IIS? sorry, I always thought you either need apache or httpd for unix/linux but if IIS can run CGI,it'll be great! eric Eric, You can run CGI on IIS, but if you run ActiveState Perl, it will set up IIS to run your CGI scripts through ISAPI (Internet Server Application Programming Interface) instead of as straight CGI. ISAPI runs your Perl scripts through the perlis.dll which which has the advantage of being persistent in memory, thus giving you faster response time, but has the disadvantage of not being able to pass certain switches to Perl. In particular, you can't pass the -T switch and activate taint checking. This is a significant security problem. You can read more about this at http://www.perlmonks.org/index.pl?node_id=82619. Cheers, Curtis Poe = Senior Programmer Onsite! Technology (http://www.onsitetech.com/) Ovid on http://www.perlmonks.org/ __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Assigning variables from an array?
i use... my ${$item}= $query-param($item); Dianne Van Dulken wrote: Hi all, One day I am going to stop asking these fairly dumb questions, and start answering them with a wise and profound look on my face, but in the meantime... I know this one has to be pretty simple, but I can't work out how to do it, and I haven't been able to find anyone else doing it. I am receiving a lot of values from a form. I want to loop through them and set new variables, with the same name, to the same value. EG: I want the param value phone to be set to $phone. I know I could do this with hardcoding by my $phone = $query-param('phone'), but this seems to me to be a bit of a waste of typing when I already have a foreach loop happening. (I know, I know, laziness is bad). This is my foreach loop: $query = new CGI; @values = $query-param; foreach $item (@values) { print $item .=. $query-param($item).br; $msg .= $item .= . $query-param($item) . \n; } I've tried \$.$item = and I've tried $.$item = and I've tried eval($item) = I'm sure there must be an easy way to do it. As I said, I know I don't HAVE to do it, and I could just use $query-param('whatever') whenever I need it, but it's annoying me now, and I want to know. Sorry if it's too stupid a question, and you all go Tchah, moron! at me (please feel free to, as long as you also let me know exactly WHY I'm a moron, 'cause as I said, it's annoying me). Cheers di -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Assigning variables from an array?
Dianne Van Dulken [EMAIL PROTECTED] said something to this effect on 08/14/2001: I am receiving a lot of values from a form. I want to loop through them and set new variables, with the same name, to the same value. EG: I want the param value phone to be set to $phone. So, you want to create a variable in the current namespace for each form parameter that comes in? A request like script.cgi?foo=bar will create $foo? There are a couple of options. CGI.pm, which you appear to be using, based on the code snippet below, has a method called import_names. From perldoc CGI: IMPORTING ALL PARAMETERS INTO A NAMESPACE: $query-import_names('R'); This creates a series of variables in the 'R' namespace. For example, $R::foo, @R:foo. For keyword lists, a variable @R::keywords will appear. If no namespace is given, this method will assume 'Q'. WARNING: don't import anything into 'main'; this is a major security risk What you want, basically, is to use symbolic references. Without this turning into a reference tutorial (perldoc perlref, BTW), a soft reference uses the value of a scalar as the name of another variable: my $one = 'foo'; $$one = 42; print $foo; #produces 42 The problem is that this is one of the things use strict prevents by default, since it's usually not what people want (you are using strict, right?). you can selectively turn off strict reference checking by block with the 'no strict qw(refs)' pragme. Here is a loop to do what (I think) you are asking for: use strict; { # extra naked block to scope the no strict 'refs' # turning off strict refs leaves on the other strictures, # such as vars and subs no strict 'refs'; for my $p ($q-param) { ${$p} = $q-param($p); # or just $$p = $q-param($p) # I prefer the former because it makes explicit what # you are trying to do, and also makes it clear that # you are assigning to a soft reference and not # dereferencing a regular reference } } This is just for illustration; use CGI's import_names method, because it does a lot of checking to ensure that the namespace you choose is clean: my $q = CGI-new; $q-import_names(Q); print $Q::phone; (Choose a more descriptive name than Q, though!) Good luck. (darren) -- You are what you see. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: qq{} vs here. When and where to use
I think that when you use the qq you still have to escape special characters whereas in the EOH case you don't. Someone, please, correct me if I am wrong. Are there any reasons to pick between Print qq{ content }; and print EndOfHtml; content EndOfHtml when writing cgi? To this newbie they seem the same. They both interpolate. I believe the literal is expressed as print q{content}; *Teresa Raymond *Mariposa Net *http://www.mariposanet.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: which one to choose WxPerl or perlTk
Plus Perl/Tk's got a nifty little O'Reilly book all its own. Nancy Walsh, Learning Perl/Tk. Also Perl/Tk Pocket Reference and a bit of a blurb in the Advanced Perl book. That's my O'Reilly plug for today. I've heard good things about GTK (Gimp Took Kit) too. You may wish to check it out. Good Luck. Kristina Nairn - Original Message - From: Greg Jetter [EMAIL PROTECTED] To: Dinakar Desai [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Friday, August 10, 2001 6:07 PM Subject: Re: which one to choose WxPerl or perlTk On Thursday 09 August 2001 12:16, Dinakar Desai wrote: Hello: I was wondering which one to learn in terms of GUI. I am not very familiar with any GUI application development. I am just exploring the possibilities of GUI tool kits. I would like to know your experience in terms of stability, maturity and usability of WXPerl and PerlTk GUI tool kits. I really appreciate your comments.. Thank you. dinakar Content-Type: text/plain; charset=us-ascii; name=Attachment: 1 Content-Transfer-Encoding: 7bit Content-Description: I found PerlTK very easy to use, it works very well for what I used it for , a GUI to a data base program. Greg -- 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]
Best Practices: Error Handling???
I've been perusing the Camel book, the Cookbook, CGI Programming w/Perl, and Effective Perl for answers to this question, but have yet to find one or two definitive solutions. I've seen the standard die/eval() statements and the use of the various incarnations of Carp, but I have yet to see anyone say something along the lines of this is the most common approach. I find myself longing for the consistency of try/catch blocks. Can anyone shed some light on the situation? Regards, DTS -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Sendmail w/perl
sounds as if the perl script isn't getting called at all. If you're working on UNIX you're probably using a .forward file to forward mail to the script. Instead of forwarding the mail to the script, forward it to a regular email account. - and if that doesn't work then there's no way your perl script will be called. So try .forward: [EMAIL PROTECTED] instead of |/export/scripts/myscript.pl (whatever) And if the email thing won't work then you've probably got a permissions problem on the .forward file, or its parent directory. -mm Robert Aspinall wrote: I have an alias that runs a perl script whenever mail is recieved for a certain account, but as far as I can tell, the perl script runs without doing a single thing. Is there a way to see the output of the script? I have it write hello to a text file (which never gets created), print hello to STDOUT, and even print hello to STDERR, and I don't see the slightest peep from it. Any suggestions? Robert Aspinall Support Engineer V-ONE Corporation [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- http://sun.com/globalization/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Unix Perl and Html
Hi guys i'm having a problem. It might be kinda easy to some and kinda hard to others, but i'd really appreciate it if you could help me out. I can type in a unix command called sudo printstatus that checks the status of printers in my school printer lab. Frankly i'm getting tired of typing in this command, and i dont have any type of unix shell at my home computer. An administrator friend of mine can write a program in unix that runs a certain script lets say every 30 seconds. I would like to know how i would even begin to write a perl script that reads from the unix sudo printstatus command and prints it out to a webpage. I dont know if its too advanced but any input from you guys would be great. Thanks for your time _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: automatically naming scalars
I am not sure if this will help but you might be talking about using soft references ... you would have to turn off strict to use it ... I could not get my head aroun your description of the problem but I had many experinces when I had discussions with people at work who felt soft references were the only way to get to the solution and then after discussing the problem in the open realised that a data structure is actually an easy answer to the problem ... example of soft reference ... my @array = qw( first second third ); my $cnt = 1; foreach (@array) { ${$_} = $cnt++ } foreach (@array) { print ${$_},\n; } print \$first is $first\n; print \$second is $second\n; print \$third is $third\n; do what you must ... On Tue, Jul 31, 2001 at 11:32:47PM -0400, Ron Woodall shaped the electrons to read: Hi Brett: Thanks for the reply. At 12:08 PM 7/31/01 -0400, you wrote: On Tue, 31 Jul 2001, Ron Woodall wrote: I'm trying to take a word from a file and naming a scalar with that word. i.e. I find the word target in a file. I then need to create $target = xxx and various other variables related to target. Any suggestions? Create a hash containing the keywords in the file: $akey = 'target'; $file_data{$akey} = 'xxx'; Or even a more complex data structure: $file_data{$akey} = { xxx = 'stuff', yyy = [1, 2, 3] }; Hm, I don't think this is going to work. How exactly is the data in the file organized? Here's the problem. Go to the Compendium of HTML Elements, www.htmlcompendium.org -- Main Menu -- HTML -- Attribute Pages and click on one of the tag names. The right frame will open up into a list of the tag and all attributes/arguments documented to work with that tag. I'm in the process of completely restructuring the site and using a perl script. This is, in part a learning exercise for me. Here's the problem. One tag will have 166 attributes plus additional arguments for each attribute. The next tag will potentially have none. No two tags share all of the same attributes. I need to create a series of scalars for each attribute such that each variable can be directly addressed and decisions drawn from them and the new structure constructed. The process is to bring up a tag page, gradually work my way down the page parsing all of the pertinent information and storing it in variables. The attributes are then sorted and the new structure is then constructed using these variables. When this program is complete, it will provide the shell for the next program which will do the same thing but will add new tags, attributes, arguments, properties, values, methods and parameters. Your help is much appreciated. Ron Woodall --- Ron Woodall [EMAIL PROTECTED] The Compendium of HTML Elements your essential web publishing resource - available at/disponible ?: http://au.htmlcompendium.org/index.htm (Australia) http://www.htmlcompendium.org/index.htm (Europe and North America) -- 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: Unix Perl and Html
Its going to be rather involved in my opinion ... suod will prompt for a password so you need to use something called Expect to interactively put the password in ... one way might be to write a script that prints the output to a webpage and run that as root ... sorry i know this does not help but I cant think of anything better ... On Tue, Aug 14, 2001 at 09:23:41AM -0400, John Blaze shaped the electrons to read: Hi guys i'm having a problem. It might be kinda easy to some and kinda hard to others, but i'd really appreciate it if you could help me out. I can type in a unix command called sudo printstatus that checks the status of printers in my school printer lab. Frankly i'm getting tired of typing in this command, and i dont have any type of unix shell at my home computer. An administrator friend of mine can write a program in unix that runs a certain script lets say every 30 seconds. I would like to know how i would even begin to write a perl script that reads from the unix sudo printstatus command and prints it out to a webpage. I dont know if its too advanced but any input from you guys would be great. Thanks for your time _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- 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: Sendmail w/perl
I just ran into this exact same problem myself--piping an alias to a perl script through a version of sendmail running smrsh. Assuming that you're absolutely sure that the script really is being called, you might want to check that smrsh has permission to write to that directory/file. It's not good enough that the script has permission if run from the command line, smrsh has to see the directory (or at least the file that you want to write to) as a valid path too. At least that's what solved the problem for me. My solution was just to put a symbolic link to the file I was trying to write in /etc/smrsh (or wherever your smrsh directory is). HTH -dave On Tue, 14 Aug 2001 09:04:04 -0400, Robert Aspinall wrote: The aliases entry is ca: |caprocess.pl (since smrsh calls it and ignores the path anyway) The script has nothing of any substance in it, just something like #!/usr/bin/perl open (OUTPUT, output.txt); print OUTPUT testing!; print testing!; print STDERR testing!; Any ideas? Robert Aspinall Support Engineer V-ONE Corporation [EMAIL PROTECTED] - Original Message - From: Gary Stainburn [EMAIL PROTECTED] To: Robert Aspinall [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, August 14, 2001 8:54 AM Subject: Re: Sendmail w/perl Hows about giving us some code to look at? If it's a big un, just give us some snippets. Also, give us the aliases file entry that calls it. Gary On Tuesday 14 August 2001 1:51 pm, Robert Aspinall wrote: I have an alias that runs a perl script whenever mail is recieved for a certain account, but as far as I can tell, the perl script runs without doing a single thing. Is there a way to see the output of the script? I have it write hello to a text file (which never gets created), print hello to STDOUT, and even print hello to STDERR, and I don't see the slightest peep from it. Any suggestions? Robert Aspinall Support Engineer V-ONE Corporation [EMAIL PROTECTED] -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Unix Perl and Html
On Tuesday 14 August 2001 09:23, John Blaze wrote: printstatus command and prints it out to a webpage. I dont know if its too advanced but any input from you guys would be great. You could put the sudo command in back quotes and capture the output to a straight text file. Load that text file in a web browser and you have a quick, easy report. Here's some code (a script called gen_report.pl): #!/usr/bin/perl print `sudo printstatus`; Call this periodically by running gen_report.pl report.txt in a cron job. Of course, you'll have to have someone who knows how to configure Sudo properly if you're going to run this as a user other than the one you normally run it as. Regards, Troy -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
what does %$variable mean?
I copied some code to get POP mail: my $pop = Net::POP3-new($mail_server) or die Can't open connection to $mail_server: $!\n; defined($pop-login($mail_username, $mail_password)) or die Can't login to $mail_server, $mail_username, $mail_password: $!\n; my $messages = $pop-list() or die Can't get list of messages from $mail_server: $!\n; It works. I iterate the list of messages with this loop: foreach my $msgnum (keys %$messages) { } This works as well. But I don't understand the use of the hash. Why isn't it: %messages = $pop-list() and: foreach my $msgnum (keys %messages) { } What does %$messages mean? Thanks John Sands __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Code for review
I spoke with Mr. Peter Scott and he informed me that I would be ok to cut/paste my code in an email and post it to the list, so with that said here it is.. Please be open and honest, I am looking to speed up the script and make it more efficient as well Regards, Ron #!/usr/bin/perl -w use Getopt::Long; use Time::Local; use strict; use Benchmark; use POSIX qw(strftime); use Time::Local; if ( @ARGV 2 ) { print You must supply two command line options\n; print The run # and the sleeptime\n; print \n IE: $0 1 60\n;; exit (1); } # This just times the script, it should take roughly 30 - 45 seconds to run to completion # Disable buffering of output $| = 1; # declare global variables for use my ($smtx, $syscl, $usr, $sys, $wt, $idl, $CPUS, $avg1, $avg2, $avg3, @time, %otime, $otime, $tmp, $stime, %stime, $oratime, $systime); my (@mpstat, $OUT, $OFN, $ldavg, $STAT, $SFAN, $header, @lookFor, %results, $results, $clients, $pricing, @output, %lookFor); my ($get_errors_timer, $tt, $RTDLOGDIR, $RTDUSER, $RTDPASS, $RTD_ORACLE_SID, $sessions, $active, $VQUSER, $VQPASS, $lwtime); my ($TARGET_HOST, @sessions,@active); # A timer so I can limit when the get_errors() runs my $time = time() + 30; # oracle related values, used to gather connect times $RTDLOGDIR = $ENV{APPSPATH} . /logs/runtime_logs/; $RTDUSER=rtdiag; $RTDPASS=byteme; $RTD_ORACLE_SID=VALUTEST; $VQUSER=VQ3994; $VQPASS=VQUIX04; $TARGET_HOST=mc0300uv004; if ( $ENV{NODE} =~ /NodeA/ ) { $VQUSER=VQ3993; } # Initialy zero out all the hash values foreach my $keys (keys %lookFor ) { $results{$keys} = 0; } # Start some benchmarking stuff $tt = new Benchmark; sub abort () { # set currnt timer time my $t3 = new Benchmark; # find the processing time my $te = timediff($t3, $tt); # report the processing time print OFN elapsed time\t: . timestr($te) . \n; close(SFN); close(OFN); exit(1); } sub timer () { if ( time() $time ) { return 1; } else { return 0; } } %SIG = ( HUP = \abort, # just because it seems only reasonable! INT = \abort, QUIT = \abort, # can kids inherit these? should they? TERM = \abort, ); # cleanup routine called every iteration through the get_errors() # to 0 out all values and hopefully reclaim memory... sub cleanup () { @output = (); %otime = (); %stime = (); @mpstat = (); %results = (); @sessions = (); @active = (); foreach my $keys (keys %lookFor ) { $results{$keys} = 0; } } # setup some output files my $host = `hostname`; my $date = `date +%b%d`; chomp( $host); chomp( $date ); # Define the output files used $OUT = $ENV{APPSPATH} . /trg/ltt/scripts/ . $host . _ . $date . _run$ARGV[0]_$$.out; $STAT = $ENV{APPSPATH} . /trg/ltt/scripts/ . $host . _ . $date . _run$ARGV[0]_$$.xls; # BIG UGLY hash of current errors we are tracking for each SLT # please add new elements to the bottom of the hash, also ensure # that the print_stat_header() and the generate_statistic_output() # are updated accordingly # yeah yeah yeah, I could remove the = ; but why they look so so pretty ;-P %lookFor = ( ORA- = ORACLE errors (various Oracle errors), Fault 2-001 = Fault 2-001Host/server down or unresponsive, Fault 2-002 = Fault 2-002no orbix daemon or unresponsive, Fault 2-003 = Fault 2-003Can not bind to Authorization Object (ACF2/Message Broker), Fault 2-004 = Fault 2-004Can not bind to Contract Object (CMS/Get Q/Message Broker), Fault 2-005 = Fault 2-005Can not bind to Order Object (Order Submit/Message Broker), Fault 2-006 = Fault 2-006Authorization Object fault (ACF2/Message Broker), Fault 2-007 = Fault 2-007Contract Object fault (CMS/Get Q/Message Broker), Fault 2-008 = Fault 2-008Order Object fault (Order Submit/Message Broker), Fault 2-009 = Fault 2-009CHI 3270 session fault (Customer Information/TRG), Fault 2-010 = Fault 2-010CAPS 3270 session fault (Trade-in Information/TRG), Fault 2-011 = Fault 2-011Sale Range 3270 session fault (Negotiated Credit Info/TRG), Fault 2-012 = Fault 2-012Oracle DBMS offline, Fault 2-013 = Fault 2-013Oracle DBMS is out of critical resource, Fault 2-015 = Fault 2-015Factory Server failed to start Session Server, Fault 2-016 = Fault 2-016CAPS Broker failure (Serial, Order Information/TRG), Fault 2-017 = Fault 2-017CAPS Broker fault (Serial, Order Information/TRG), Fault 2-018 = Fault 2-018Pooling Broker failure (Pooling Information/TRG), Fault 2-019 = Fault 2-019
FW: FUCK YOU
Mr. Lucifer/Sir Chees-a-lot, Ya' know, unwittingly, this is a good way to get yourself targeted. You might want to rethink your words before you go flinging them about so witlessly. People like myself can and most often do retaliate to children that run amuck at the mouth. Don't push it BOZO, I mean Mr. Lucifer/Sir Chees-a-lot, John -Original Message- From: Zen [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 09, 2001 4:48 PM To: [EMAIL PROTECTED] Subject: FUCK YOU I DESPISE morons who wander onto lists and get pissed at all the mail... I get even more PISSED when they forward them back to said list If you are too fucking stupid to follow the directions IMMEDIATLY BELOW THIS TEXT: \/ - Begin Simple Instructions -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - End Simple Instructions - Then you are simply to fucking dumb to be on ANY lists. Don't bother replying, you're blocked. PS, Here's YOUR mail back, I already got them -BEGIN GEEK CODE BLOCK- Version: 3.1 GIT/U d--(---) s: a-? C++(---) U*++L+++ P++ L+(++) E- W+++$ N++@ K w(---) !O? M-- V? PS+ PE Y+ PGP t+ 5-- X+ R@ tv- b D+++ G e++ h- r*- y-++ --END GEEK CODE BLOCK--
annoying warning in Net/Config.pm
Using the -w flag and: use Net::FTP or use Net::POP3 gives this warning message: Use of uninitialized value in concatenation (.) at C:/Perl/site/lib/Net/Config.pm line 44. I know it's trivial, but I'd like to get rid of it. Does anyone know how I can? I'm using Perl 5.006 from ActiveState. Thanks John Sands __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [ADMIN} Re: FW: F*** YOU
I know we should not spend too much bandwidth on something like this .. but I have been on several lists and this issue always comes up at several points in the lists history ... I actually think it will be cool for the guys writing mailing list programs to take the unsubscribing issue into the program itself ... On Tue, Aug 14, 2001 at 10:59:10AM -0400, Kevin Meltzer shaped the electrons to read: Whoa.. there is no reason to put this on the list. If anyone is planning on repsonding to the list on this, don't. If you have complaints/comments on the list, people on the list, threads on the list, etc.. please send them to [EMAIL PROTECTED], or try to deal with them maturely, off the list, with an individual. Thanks for your cooperation. Cheers, Kevin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: annoying warning in Net/Config.pm
At 08:17 AM 8/14/01 -0700, John Sands wrote: Using the -w flag and: use Net::FTP or use Net::POP3 gives this warning message: Use of uninitialized value in concatenation (.) at C:/Perl/site/lib/Net/Config.pm line 44. I know it's trivial, but I'd like to get rid of it. Does anyone know how I can? I'm using Perl 5.006 from ActiveState. Looks like you've found an enhancement opportunity; well-behaved modules ought to be -w clean on all platforms. The code triggering that warning is 43 my $home = eval { (getpwuid($))[7] } || $ENV{HOME}; 44 $file = $home . /.libnetrc; and obviously on your Windows system getpwuid() is not implemented and neither is an environment variable HOME set. I will suggest a patch like this, which you could put in Config.pm yourself: 43 my $home = eval { (getpwuid($))[7] } || $ENV{HOME} || '.'; 44 $file = $home . /.libnetrc; -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Reading magnetic stripe data with perl
Hi, I'm _very_ new to Perl and was wondering if anyone can help me read a com port? I intend to set up a linux machine to boot straight into a perl program which checks details from a card reader via the com port and compares them with details in a database, probably via a DBI. The intention is to be able to turn this machine on without monitor/mouse/kb (ruling out Winxx) and for it to work on an IP network (ruling out DOS?). It also needs to be secure, hence linux. All I need is perl code to read a line of input from ttyS0. Thanks Julian Julian Sawkins Analyst Programmer/DBA MIS Team University of Derby Tel: (01332 59)1224/1239 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: annoying warning in Net/Config.pm
At 08:47 AM 8/14/01 -0700, I wrote: At 08:17 AM 8/14/01 -0700, John Sands wrote: Using the -w flag and: use Net::FTP or use Net::POP3 gives this warning message: Use of uninitialized value in concatenation (.) at C:/Perl/site/lib/Net/Config.pm line 44. I know it's trivial, but I'd like to get rid of it. Does anyone know how I can? I'm using Perl 5.006 from ActiveState. Looks like you've found an enhancement opportunity; well-behaved modules ought to be -w clean on all platforms. The code triggering that warning is 43 my $home = eval { (getpwuid($))[7] } || $ENV{HOME}; 44 $file = $home . /.libnetrc; and obviously on your Windows system getpwuid() is not implemented and neither is an environment variable HOME set. I will suggest a patch like this, which you could put in Config.pm yourself: 43 my $home = eval { (getpwuid($))[7] } || $ENV{HOME} || '.'; 44 $file = $home . /.libnetrc; Oops, spoke too soon. In the next version of Perl this has already been fixed. Not in the currently stable one, but in the development version. The new code looks like: use File::Spec; my $home = eval { (getpwuid($))[7] } || $ENV{HOME} || $ENV{HOMEDRIVE} || $ENV{HOMEPATH} || File::Spec-curdir; $file = File::Spec-catfile($home, .libnetrc); But DON'T PUT THAT IN. There are many many other changes to that file and this probably won't work just by itself. The patch I gave above will silence the warning for you right now. When perl 5.8 is released, ActiveState will have a new version that will also work. -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how many items in a hash?
-Original Message- From: Troy Denkinger [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 14, 2001 9:58 AM To: John Sands; [EMAIL PROTECTED] Subject: Re: how many items in a hash? On Tuesday 14 August 2001 10:36, John Sands wrote: Is there a simple way to know whether a hash has items in it? Like using @ARRAY in a scalar context gives the size of an array. Or using $#ARRAY gives the last valid index. Calling keys() on the hash will return a list of the keys in the hash. Calling scalar() on that list will give you the number of elements in the list. Or, from perldoc perldata: If you evaluate a hash in scalar context, it returns false if the hash is empty. If there are any key/value pairs, it returns true; more precisely, the value returned is a string consisting of the number of used buckets and the number of allocated buckets, separated by a slash. print Empty!\n unless %myhash; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
lc vs. tr
1. Any opinions on which is better to convert characters into lowercase (efficiency, speed, etc)? lc vs. tr /A-Z/a-z/ ? 2. Is there an option to tell tr to ignore case? as in: tr/abc/222/i; #translates regardless of case 3. If #2 isn't possible, how would you use lc to convert to lowercase before using tr/abc/222/, as in: while () { # trying to convert $_ to lowercase using lc before using tr/// function lc; tr/abc/222/; print; } This code produces an error Useless use of lc in void context. How do I successfully combine these three lines of code? TIA, -- Drew -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: automatically naming scalars
I must agree with Jos on this ... I read the email and I saw that what Ron was asking for was soft reference ... like I mentioned before a lot of the situations (like I mentioned my experience) .. where you think that soft reference is the only way to do it is because your mindset had been stuck in that way but solutions using other data structures will do the job and everyone can understand it much better ... plus you get to keep strict which i never do without ... the use strict and #!perl lines have been programmed into my fingers already ... i had a situation once when one of my colleague was trying to get round a problem and he asked me how to do soft reference ... when i asked him why he explained what he was trying to do and suddenly we both realised that all he needed was a hash!! Look through the problem to make sure soft reference is what you want 'cos liek Jos said it is considered bad programming practice. On Tue, Aug 14, 2001 at 05:33:07PM +0200, Jos I. Boumans shaped the electrons to read: a few notes on soft references: 1. they are generally concidered evil 2. they will not work under use strict 3. they are rarely what you really need/want I'm not saying they are bad in your case, but let me just elaborate on the above. you'll have to say 'no strict refs' for a certain block to have soft refs work under use strict. assuming you *are* in fact running under strict.. which imo one always should. furthermore, you'd need to 'my' those variables as well, to make strict happy. now, for another fix: ### old code ### my @array = qw( first second third ); my $cnt = 1; foreach (@array) { ${$_} = $cnt++ } ### new code ### my @array = qw( first second third ); my qw(%hash $cnt); for (@array) { $hash{$_} = ++$cnt } this sticks all those variables in one tidy hash, without upsetting strict or polluting your namespace with tons of global variables... just fyi, Jos I am not sure if this will help but you might be talking about using soft references ... you would have to turn off strict to use it ... I could not get my head aroun your description of the problem but I had many experinces when I had discussions with people at work who felt soft references were the only way to get to the solution and then after discussing the problem in the open realised that a data structure is actually an easy answer to the problem ... example of soft reference ... my @array = qw( first second third ); my $cnt = 1; foreach (@array) { ${$_} = $cnt++ } foreach (@array) { print ${$_},\n; } print \$first is $first\n; print \$second is $second\n; print \$third is $third\n; do what you must ... On Tue, Jul 31, 2001 at 11:32:47PM -0400, Ron Woodall shaped the electrons to read: Hi Brett: Thanks for the reply. At 12:08 PM 7/31/01 -0400, you wrote: On Tue, 31 Jul 2001, Ron Woodall wrote: I'm trying to take a word from a file and naming a scalar with that word. i.e. I find the word target in a file. I then need to create $target = xxx and various other variables related to target. Any suggestions? Create a hash containing the keywords in the file: $akey = 'target'; $file_data{$akey} = 'xxx'; Or even a more complex data structure: $file_data{$akey} = { xxx = 'stuff', yyy = [1, 2, 3] }; Hm, I don't think this is going to work. How exactly is the data in the file organized? Here's the problem. Go to the Compendium of HTML Elements, www.htmlcompendium.org -- Main Menu -- HTML -- Attribute Pages and click on one of the tag names. The right frame will open up into a list of the tag and all attributes/arguments documented to work with that tag. I'm in the process of completely restructuring the site and using a perl script. This is, in part a learning exercise for me. Here's the problem. One tag will have 166 attributes plus additional arguments for each attribute. The next tag will potentially have none. No two tags share all of the same attributes. I need to create a series of scalars for each attribute such that each variable can be directly addressed and decisions drawn from them and the new structure constructed. The process is to bring up a tag page, gradually work my way down the page parsing all of the pertinent information and storing it in variables. The attributes are then sorted and the new structure is then constructed using these variables. When this program is complete, it will provide the shell for the next program which will do the same thing but will add new tags, attributes, arguments, properties, values, methods and parameters. Your help is much appreciated. Ron Woodall
Re: Code for review
At 10:33 AM 8/14/01 -0400, Yacketta, Ronald wrote: I spoke with Mr. Peter Scott and he informed me that I would be ok to cut/paste my code in an email and post it to the list, Didn't think of the posting a URL solution at the time :-( Please be open and honest, I am looking to speed up the script and make it more efficient as well Snippage below. #!/usr/bin/perl -w use Getopt::Long; use Time::Local; use strict; I always put use strict as the first line after the shebang, just to make it a standard incantation. if ( @ARGV 2 ) { print You must supply two command line options\n; So more than 2 would also be an error, no? Perhaps check if @ARGV != 2? print The run # and the sleeptime\n; print \n IE: $0 1 60\n;; exit (1); } # This just times the script, it should take roughly 30 - 45 seconds to run to completion What is this comment above referring to? # Disable buffering of output $| = 1; Tiny style point: personally, I'd have put that comment on the same line. # declare global variables for use my ($smtx, $syscl, $usr, $sys, $wt, $idl, $CPUS, $avg1, $avg2, $avg3, @time, %otime, $otime, $tmp, $stime, %stime, $oratime, $systime); my (@mpstat, $OUT, $OFN, $ldavg, $STAT, $SFAN, $header, @lookFor, %results, $results, $clients, $pricing, @output, %lookFor); my ($get_errors_timer, $tt, $RTDLOGDIR, $RTDUSER, $RTDPASS, $RTD_ORACLE_SID, $sessions, $active, $VQUSER, $VQPASS, $lwtime); my ($TARGET_HOST, @sessions,@active); I am 99.99% sure that most of those shouldn't be global variables, and I haven't read any more yet :-) And the ones that should, should be commented. # A timer so I can limit when the get_errors() runs my $time = time() + 30; # oracle related values, used to gather connect times $RTDLOGDIR = $ENV{APPSPATH} . /logs/runtime_logs/; $RTDUSER=rtdiag; $RTDPASS=byteme; $RTD_ORACLE_SID=VALUTEST; $VQUSER=VQ3994; $VQPASS=VQUIX04; Thanks for telling us your db password :-) Consider whether it should be passed in from the command line. $TARGET_HOST=mc0300uv004; if ( $ENV{NODE} =~ /NodeA/ ) { $VQUSER=VQ3993; } # Initialy zero out all the hash values foreach my $keys (keys %lookFor ) { $results{$keys} = 0; } # Start some benchmarking stuff $tt = new Benchmark; sub abort () { # set currnt timer time my $t3 = new Benchmark; # find the processing time my $te = timediff($t3, $tt); # report the processing time print OFN elapsed time\t: . timestr($te) . \n; close(SFN); close(OFN); exit(1); } Fix the indentation. It's more important than you might think. Same comment applies in other places. sub timer () { if ( time() $time ) { return 1; } else { return 0; } } %SIG = ( HUP = \abort, # just because it seems only reasonable! INT = \abort, QUIT = \abort, # can kids inherit these? should they? TERM = \abort, ); # cleanup routine called every iteration through the get_errors() # to 0 out all values and hopefully reclaim memory... sub cleanup () { @output = (); %otime = (); %stime = (); @mpstat = (); %results = (); @sessions = (); @active = (); foreach my $keys (keys %lookFor ) { $results{$keys} = 0; } } # setup some output files my $host = `hostname`; my $date = `date +%b%d`; chomp( $host); chomp( $date ); You can actually do these in one step if you want: chomp( my $host = `hostname` ); Weird, eh? # Define the output files used $OUT = $ENV{APPSPATH} . /trg/ltt/scripts/ . $host . _ . $date . _run$ARGV[0]_$$.out; $STAT = $ENV{APPSPATH} . /trg/ltt/scripts/ . $host . _ . $date . _run$ARGV[0]_$$.xls; Put at least the /trg/ltt/scripts/ in a constant defined at the top. Also, interpolation is your friend: $OUT = $ENV{APPSPATH}/trg/ltt/scripts/${host}_${date}_run$ARGV[0]_$$.out; # BIG UGLY hash of current errors we are tracking for each SLT # please add new elements to the bottom of the hash, also ensure # that the print_stat_header() and the generate_statistic_output() # are updated accordingly # yeah yeah yeah, I could remove the = ; but why they look so so pretty ;-P Which is a good reason to keep them in. I can't think of a reason to take them out. %lookFor = ( ORA- = ORACLE errors (various Oracle errors), Fault 2-001 = Fault 2-001Host/server down or [snip]); # This begins the output of the statistical data for graphical manipulation # print the Excel column header sub print_stat_header () { print SFN \n; print SFN DateTimeStamp,ORAn,F2001,F2002,F2003,F2004,F2005,F2006,F2007,F2008,F2009,F2 010,F2011,F2012,F2013,F2015,F2016,; print SFN F2017,F2018,F2019,FactoryFailure,SystemError,SystemException,CommunicationF ailure,ORBProblem,GetQError,; print SFN # of clients still running,# of PricingSessions still running,# of clients Finished Test,smtx / syscl,user %,; print SFN sys %,wt %,idl %,current load average,current load average,current load
Re: lc vs. tr
At 11:59 AM 8/14/01 -0400, Drew Cohan wrote: 1. Any opinions on which is better to convert characters into lowercase (efficiency, speed, etc)? lc vs. tr /A-Z/a-z/ ? lc can handle locales where upper and lower case isn't the same as A-Z vs a-z. 2. Is there an option to tell tr to ignore case? No. 3. If #2 isn't possible, how would you use lc to convert to lowercase before using tr/abc/222/, as in: I wouldn't. while () { # trying to convert $_ to lowercase using lc before using tr/// function lc; tr/abc/222/; print; } This code produces an error Useless use of lc in void context. lc doesn't modify it's argument, you have to save it somewhere. How do I successfully combine these three lines of code? I'd do tr/ABCabc/22/. Unless I thought I might be in a locale where the uppercase of abc wasn't ABC. (Anyone know of one?) -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[ADMIN] Re: [ADMIN] Re: FW: F*** YOU
On Tue, Aug 14, 2001 at 11:03:02AM -0500, John ([EMAIL PROTECTED]) spew-ed forth: then do something about this BOZO. I have already emailed 1st.net. what more can I do? John John, You can start by reading what I posted which firstly said no more of this should go to the list, and secondly gave other avenues to take your grievences. Noone on the list wants to be involved in this. Take it off-list. Think before you post, please. Cheers, Kevin - Original Message - From: Kevin Meltzer [EMAIL PROTECTED] To: John [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, August 14, 2001 9:59 AM Subject: [ADMIN} Re: FW: F*** YOU Whoa.. there is no reason to put this on the list. If anyone is planning on repsonding to the list on this, don't. If you have complaints/comments on the list, people on the list, threads on the list, etc.. please send them to [EMAIL PROTECTED], or try to deal with them maturely, off the list, with an individual. Thanks for your cooperation. Cheers, Kevin On Tue, Aug 14, 2001 at 09:54:26AM -0500, John ([EMAIL PROTECTED]) spew-ed forth: Mr. Lucifer/Sir Chees-a-lot, Ya' know, unwittingly, this is a good way to get yourself targeted. You might want to rethink your words before you go flinging them about so witlessly. People like myself can and most often do retaliate to children that run amuck at the mouth. Don't push it BOZO, I mean Mr. Lucifer/Sir Chees-a-lot, John -Original Message- From: Zen [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 09, 2001 4:48 PM To: [EMAIL PROTECTED] Subject: FUCK YOU I DESPISE morons who wander onto lists and get pissed at all the mail... I get even more PISSED when they forward them back to said list If you are too fucking stupid to follow the directions IMMEDIATLY BELOW THIS TEXT: \/ - Begin Simple Instructions -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - End Simple Instructions - Then you are simply to fucking dumb to be on ANY lists. Don't bother replying, you're blocked. PS, Here's YOUR mail back, I already got them -BEGIN GEEK CODE BLOCK- Version: 3.1 GIT/U d--(---) s: a-? C++(---) U*++L+++ P++ L+(++) E- W+++$ N++@ K w(---) !O? M-- V? PS+ PE Y+ PGP t+ 5-- X+ R@ tv- b D+++ G e++ h- r*- y-++ --END GEEK CODE BLOCK-- -- [Writing CGI Applications with Perl - http://perlcgi-book.com] Not a speck of cereal. -- Frank Zappa -- [Writing CGI Applications with Perl - http://perlcgi-book.com] Q: How many Zen masters does it take to screw in a light bulb? A: None. The Universe spins the bulb, and the Zen master stays out of the way. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: lc vs. tr
Using Benchmark.pm ... the answer is to use lc ... if you flip through to the Perl Cookbook pg 19 or receipe 1.9 you will find that tr is the wrong way to do changing of case (or at least tr/A-Z/a-z/ since it will miss accented characteers and so on..) THe reason you are getting the error is because you did not capture lc's return value. unlike chomp lc does not work on the argument and the return value is the converted string ... On Tue, Aug 14, 2001 at 11:59:54AM -0400, Drew Cohan shaped the electrons to read: 1. Any opinions on which is better to convert characters into lowercase (efficiency, speed, etc)? lc vs. tr /A-Z/a-z/ ? 2. Is there an option to tell tr to ignore case? as in: tr/abc/222/i; #translates regardless of case 3. If #2 isn't possible, how would you use lc to convert to lowercase before using tr/abc/222/, as in: while () { # trying to convert $_ to lowercase using lc before using tr/// function lc; tr/abc/222/; print; } This code produces an error Useless use of lc in void context. How do I successfully combine these three lines of code? TIA, -- Drew -- 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: lc vs. tr
Thanks to both Peter and register for answering my questions. -- Drew. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 14, 2001 1:07 PM To: Drew Cohan Cc: [EMAIL PROTECTED] Subject: Re: lc vs. tr Using Benchmark.pm ... the answer is to use lc ... if you flip through to the Perl Cookbook pg 19 or receipe 1.9 you will find that tr is the wrong way to do changing of case (or at least tr/A-Z/a-z/ since it will miss accented characteers and so on..) THe reason you are getting the error is because you did not capture lc's return value. unlike chomp lc does not work on the argument and the return value is the converted string ... On Tue, Aug 14, 2001 at 11:59:54AM -0400, Drew Cohan shaped the electrons to read: 1. Any opinions on which is better to convert characters into lowercase (efficiency, speed, etc)? lc vs. tr /A-Z/a-z/ ? 2. Is there an option to tell tr to ignore case? as in: tr/abc/222/i; #translates regardless of case 3. If #2 isn't possible, how would you use lc to convert to lowercase before using tr/abc/222/, as in: while () { # trying to convert $_ to lowercase using lc before using tr/// function lc; tr/abc/222/; print; } This code produces an error Useless use of lc in void context. How do I successfully combine these three lines of code? TIA, -- Drew -- 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]
Associative array
Hi guys, Got a quick question. If I let @foo = some string; can I access say the t in this string by using $foo[6] ? thanx eric * *Eric T. Wang * *Bioinformatic Support and SRA * *University of California, Irvine College of Medicine * *Department of Biological Chemistry * *RK Moyzis Lab * *[EMAIL PROTECTED] * *949-824-1870 * * -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Associative array
An associative array is the old name for a hash, which isn't what you're using. At 10:14 AM 8/14/01 -0700, Eric Wang wrote: Hi guys, Got a quick question. If I let @foo = some string; can I access say the t in this string by using $foo[6] ? You've got a scalar which you want to treat as an array. Put the string in a scalar, and use the substr() function (perldoc -f substr). -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: finding a key in a hash with regexp
Hi, you could try using grep on the keys, e.g.: my %hash = ( a = 'a', b= 'b', 3 = 'three'); ($val) = @hash{grep /^\d/, keys %hash}; print val = '$val'\n; ;) Dave -Original Message- From: Eric Beaudoin [mailto:[EMAIL PROTECTED]] Sent: 13 August 2001 00:15 To: Birgit Kellner Cc: [EMAIL PROTECTED] Subject: Re: finding a key in a hash with regexp At 18:25 2001.08.12, Birgit Kellner wrote: Hm, what's the shortest way to do this: I have a hash where one, and only one, key begins with a number, I don't know its value and want to assign this value to a variable. If I were to do a foreach loop, I'd do this (presuming that %hash is already defined): foreach my $key(keys %hash) { if ($key =~ /^\d/) {push (@keys, $key); } } But since I know there will only be one key where this condition is true, looping and creating an array seems like a waste. Birgit Kellner How about : foreach my $key (sort keys %hash) { if ($key =~ /^\d/) { push (@keys, $key); # Put the key in the keys list last; # Exit the loop, do not proccess the rest of %hash. } } Since sorting a list is faster than processing each element of it and since numbers are sorted before letters, you should find your number very fast. If you are looking for other type of data, you could make yourself a special sort. You could also use the grep command and generate a list with only the keys that match the regex. As in my $key = (grep /^d/, (keys %hash))[0]; # Find one key begining with a number. push (@keys, $key); # Put the key in the keys list. Hope it helps. --- Éric Beaudoinmailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Help needed on Regular Expression
Could you please take me off this alias. Thanks Nick Futter Director, Channel Sales EBIZ Enterprises Incorporated 13715 Murphy Road, Suite D Stafford, TX 77477 tel:800-876-8649 x 8570 fax: 281-403-8670 email: [EMAIL PROTECTED] http://www.EBIZMart.com http://www.LinuxMall.com Accardo, Lucia To: 'Hanming Tu' [EMAIL PROTECTED], Lucia.Accardo@[EMAIL PROTECTED] qwest.com cc: Subject: RE: Help needed on Regular 08/14/01 09:17 Expression AM I wish I could help.. I could barely understand the program! :) -Original Message- From: Hanming Tu [mailto:[EMAIL PROTECTED]] Sent: Monday, August 13, 2001 1:53 PM To: [EMAIL PROTECTED] Subject: Help needed on Regular Expression Hi All, I am writing a program to display POD, functions, Perl FAQ, and programs and want to impement two rules for the input: 1. it is Perl module names if the input starts with words or '-m'; 2. it is Perl function, FAQ, or program name if it starts with -f, -q, or -p respectively. Here is the test program that I used to test the codes to parse out the input. I have problem to implement Rule two if there is '-' in the server name or file names. Could you help me - you RE and Perl experts! Hanming # more tst70.pl #!/usr/local/bin/perl # use strict; use warnings; my $inp='Carp Text::ParseWords -f stat qr '; $inp .= '-m CGI DBI -f open readdir '; $inp .= '-q send mail:mail address:parse '; $inp .= '-p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv '; $inp .= '-f lc uc '; my $re1 = qr((-m\s*)?[\w: ]+); my $re2 = qr(-[fpmq]\s+); my $re3 = qr([\w:'\/\s]+); my $i = 0; while ($inp) { ++$i; if ($inp =~ /^($re1)/) { print \nMatch: $\n Pre: $`\n Post: $'\n; $inp = $'; } if ($inp =~ m{^($re2)($re3)\s+($re2)?}) { print \n 1st: $1\n 2nd: $2\n 3rd: $3\n; print Match: $\n Pre: $`\n Post: $'\n; $inp = $3$'; } print Input $i: $inp\n; $inp = if ($i 9); } # ./tst70.pl Match: Carp Text::ParseWords Pre: Post: -f stat qr -m CGI DBI -f open readdir -q send mail:mail address:parse -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc 1st: -f 2nd: stat qr 3rd: -m Match: -f stat qr -m Pre: Post: CGI DBI -f open readdir -q send mail:mail address:parse -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 1: -m CGI DBI -f open readdir -q send mail:mail address:parse -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Match: -m CGI DBI Pre: Post: -f open readdir -q send mail:mail address:parse -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc 1st: -f 2nd: open readdir 3rd: -q Match: -f open readdir -q Pre: Post: send mail:mail address:parse -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 2: -q send mail:mail address:parse -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc 1st: -q 2nd: send mail:mail address:parse 3rd: -p Match: -q send mail:mail address:parse -p Pre: Post: df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 3: -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 4: -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 5: -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 6: -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 7: -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 8: -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 9: -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 10: -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc -- 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 many items in a hash?
-Original Message- From: Michael Fowler [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 14, 2001 1:32 PM To: Bob Showalter Cc: '[EMAIL PROTECTED]' Subject: Re: how many items in a hash? On Tue, Aug 14, 2001 at 11:56:11AM -0400, Bob Showalter wrote: Or, from perldoc perldata: If you evaluate a hash in scalar context, it returns false if the hash is empty. If there are any key/value pairs, it returns true; more precisely, the value returned is a string consisting of the number of used buckets and the number of allocated buckets, separated by a slash. print Empty!\n unless %myhash; I figured someone might suggest this. Testing a normal hash in a boolean context will tell you if it has keys in it, testing a tied hash in such a way won't. With a tied hash you must use keys(%hash) instead. So, I have taken to using keys(%hash) for this test, in case the hash ever becomes tied (for whatever reason). Fair enough. Does using a tied hash in list context still unroll into a list of key/value pairs? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how many items in a hash?
On Tuesday 14 August 2001 11:56, Bob Showalter wrote: Or, from perldoc perldata: If you evaluate a hash in scalar context, it returns false if the hash is empty. If there are any key/value pairs, it returns true; more precisely, the value returned is a string consisting of the number of used buckets and the number of allocated buckets, separated by a slash. print Empty!\n unless %myhash; Doh! I answered the question in my head, not the one that was asked. Sorry, kids. Regards, Troy -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Code for review
$regex = 'join ('|', keys %lookFor); if (/($regex)/o) { # Now switch on $1 for your specific sub-tests like /Factory/ etc } could you kindly elaborate some on this part? I thought one could only switch on numeric values? switch { case 1: case 2: case 3: default: } Regards, Ron -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Converting into exe
Hi, Can anyone tell me the procedure in detail please how to convert a Perl script into an executable Thanks Junaid -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Converting into exe
http://www.activestate.com Please download the Perl Development Kit with the trial license. Using PerlApp that comes with PDK, you can create both Perl EXEs and Freestanding EXEs. -- Rex -Original Message- From: Najamuddin, Junaid [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 14, 2001 1:43 PM To: [EMAIL PROTECTED] Subject: Converting into exe Hi, Can anyone tell me the procedure in detail please how to convert a Perl script into an executable Thanks Junaid -- 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: [ADMIN] Re: [ADMIN] Re: FW: F*** YOU
On 8/14/01 9:48 AM, [EMAIL PROTECTED] wrote: On Tue, Aug 14, 2001 at 11:03:02AM -0500, John ([EMAIL PROTECTED]) spew-ed forth: then do something about this BOZO. I have already emailed 1st.net. what more can I do? John John, You can start by reading what I posted which firstly said no more of this should go to the list, and secondly gave other avenues to take your grievences. Noone on the list wants to be involved in this. Take it off-list. Think before you post, please. Cheers, Kevin Ok, sorry to bring more of this up, but... Can't someone just block this John character from the list? I know I'm already adding a little filter to delete all messages from him, but couldn't the list do that automatically? :) -Michael Kelly Email: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Command line interface
I am working on a program that has users enter commands in a command line interface. Is a giant switch / case statement the only way to structure a program like this? There will probably be several hundred commands, some with several arguments. Thanks, Chris Schooley -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Converting into exe
at the command line: chmod +x (filename) :-Original Message- :From: Najamuddin, Junaid [mailto:[EMAIL PROTECTED]] :Sent: Tuesday, August 14, 2001 1:43 PM :To: [EMAIL PROTECTED] :Subject: Converting into exe : : :Hi, : :Can anyone tell me the procedure in detail please :how to convert a Perl script into an executable : :Thanks :Junaid : :-- :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: Command line interface
Use GetOpt::Long or GetOpt::Std modules for processing command-line options. - Rex -Original Message- From: Schooley, Chris [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 14, 2001 1:47 PM To: '[EMAIL PROTECTED]' Subject: Command line interface I am working on a program that has users enter commands in a command line interface. Is a giant switch / case statement the only way to structure a program like this? There will probably be several hundred commands, some with several arguments. Thanks, Chris Schooley -- 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: Command line interface
Forgot to send to the list... -Original Message- From: Schooley, Chris Sent: Tuesday, August 14, 2001 10:53 AM To: '[EMAIL PROTECTED]' Subject: RE: Command line interface Sorry, I should clarify - the program itself is like shell, has its own commands, etc. It is intended to simulate the command line interface found on various Cisco devices. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 14, 2001 10:47 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: Command line interface Use GetOpt::Long or GetOpt::Std modules for processing command-line options. - Rex -Original Message- From: Schooley, Chris [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 14, 2001 1:47 PM To: '[EMAIL PROTECTED]' Subject: Command line interface I am working on a program that has users enter commands in a command line interface. Is a giant switch / case statement the only way to structure a program like this? There will probably be several hundred commands, some with several arguments. Thanks, Chris Schooley -- 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 many items in a hash?
This works fine for my hash (which will always be fairly small) so my problem is solved, thanks. It seems a lot of overhead, though, to build a list of keys and count the number of items in the list, just to say: if (scalar(keys(%messages)) 0) { #do stuff } I thought there might be something faster. On the other hand, I'm far too new to Perl to be making these kinds of assumptions about how the scalar and keys functions are implemented! -John Is there a simple way to know whether a hash has items in it? Like using @ARRAY in a scalar context gives the size of an array. Or using $#ARRAY gives the last valid index. Calling keys() on the hash will return a list of the keys in the hash. Calling scalar() on that list will give you the number of elements in the list. Regards, Troy __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Different OS, different results
try a \n at the end of your print. -Original Message- From: David Bagwell [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 14, 2001 11:01 AM To: [EMAIL PROTECTED] Subject: Different OS, different results I have ActiveState Perl 5.6.1.628 running on Win98 and Linux Mandrake 8.0 running the same. When I run a simple program such as: #!/usr/bin/perl print 6 * 4; On the Win98 version, I get 24. On the linux version, I don't get anything. On another linux machine with a standard 5.6.0 perl install, I still don't get anything. Just curious why this happens. -- 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: [ADMIN] Re: [ADMIN] Re: FW: F*** YOU
Agreed. It would be nice not to have to deal with jerks on this list. -Original Message- From: Michael Kelly [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 14, 2001 12:47 PM To: [EMAIL PROTECTED] Subject: Re: [ADMIN] Re: [ADMIN] Re: FW: F*** YOU On 8/14/01 9:48 AM, [EMAIL PROTECTED] wrote: On Tue, Aug 14, 2001 at 11:03:02AM -0500, John ([EMAIL PROTECTED]) spew-ed forth: then do something about this BOZO. I have already emailed 1st.net. what more can I do? John John, You can start by reading what I posted which firstly said no more of this should go to the list, and secondly gave other avenues to take your grievences. Noone on the list wants to be involved in this. Take it off-list. Think before you post, please. Cheers, Kevin Ok, sorry to bring more of this up, but... Can't someone just block this John character from the list? I know I'm already adding a little filter to delete all messages from him, but couldn't the list do that automatically? :) -Michael Kelly Email: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help needed on Regular Expression
Nick, If you want to unsubscribe to the list, you need to send a message to [EMAIL PROTECTED] Could any one answers to my question? Hanming [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Could you please take me off this alias. Thanks Nick Futter Director, Channel Sales EBIZ Enterprises Incorporated 13715 Murphy Road, Suite D Stafford, TX 77477 tel:800-876-8649 x 8570 fax: 281-403-8670 email: [EMAIL PROTECTED] http://www.EBIZMart.com http://www.LinuxMall.com Accardo, Lucia To: 'Hanming Tu' [EMAIL PROTECTED], Lucia.Accardo@[EMAIL PROTECTED] qwest.com cc: Subject: RE: Help needed on Regular 08/14/01 09:17 Expression AM I wish I could help.. I could barely understand the program! :) -Original Message- From: Hanming Tu [mailto:[EMAIL PROTECTED]] Sent: Monday, August 13, 2001 1:53 PM To: [EMAIL PROTECTED] Subject: Help needed on Regular Expression Hi All, I am writing a program to display POD, functions, Perl FAQ, and programs and want to impement two rules for the input: 1. it is Perl module names if the input starts with words or '-m'; 2. it is Perl function, FAQ, or program name if it starts with -f, -q, or -p respectively. Here is the test program that I used to test the codes to parse out the input. I have problem to implement Rule two if there is '-' in the server name or file names. Could you help me - you RE and Perl experts! Hanming # more tst70.pl #!/usr/local/bin/perl # use strict; use warnings; my $inp='Carp Text::ParseWords -f stat qr '; $inp .= '-m CGI DBI -f open readdir '; $inp .= '-q send mail:mail address:parse '; $inp .= '-p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv '; $inp .= '-f lc uc '; my $re1 = qr((-m\s*)?[\w: ]+); my $re2 = qr(-[fpmq]\s+); my $re3 = qr([\w:'\/\s]+); my $i = 0; while ($inp) { ++$i; if ($inp =~ /^($re1)/) { print \nMatch: $\n Pre: $`\n Post: $'\n; $inp = $'; } if ($inp =~ m{^($re2)($re3)\s+($re2)?}) { print \n 1st: $1\n 2nd: $2\n 3rd: $3\n; print Match: $\n Pre: $`\n Post: $'\n; $inp = $3$'; } print Input $i: $inp\n; $inp = if ($i 9); } # ./tst70.pl Match: Carp Text::ParseWords Pre: Post: -f stat qr -m CGI DBI -f open readdir -q send mail:mail address:parse -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc 1st: -f 2nd: stat qr 3rd: -m Match: -f stat qr -m Pre: Post: CGI DBI -f open readdir -q send mail:mail address:parse -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 1: -m CGI DBI -f open readdir -q send mail:mail address:parse -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Match: -m CGI DBI Pre: Post: -f open readdir -q send mail:mail address:parse -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc 1st: -f 2nd: open readdir 3rd: -q Match: -f open readdir -q Pre: Post: send mail:mail address:parse -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 2: -q send mail:mail address:parse -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc 1st: -q 2nd: send mail:mail address:parse 3rd: -p Match: -q send mail:mail address:parse -p Pre: Post: df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 3: -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 4: -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 5: -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 6: -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 7: -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 8: -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 9: -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc Input 10: -p df-svr1:/tmp/myfile.txt df-svr2:/tmp/myfile.csv -f lc uc -- 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: annoying warning in Net/Config.pm
Or I could take the lazy way out, which is making a HOME environment variable. The warning is gone, thanks. -John --- Peter Scott [EMAIL PROTECTED] wrote: At 08:17 AM 8/14/01 -0700, John Sands wrote: Using the -w flag and: use Net::FTP or use Net::POP3 gives this warning message: Use of uninitialized value in concatenation (.) at C:/Perl/site/lib/Net/Config.pm line 44. I know it's trivial, but I'd like to get rid of it. Does anyone know how I can? I'm using Perl 5.006 from ActiveState. Looks like you've found an enhancement opportunity; well-behaved modules ought to be -w clean on all platforms. The code triggering that warning is 43 my $home = eval { (getpwuid($))[7] } || $ENV{HOME}; 44 $file = $home . /.libnetrc; and obviously on your Windows system getpwuid() is not implemented and neither is an environment variable HOME set. I will suggest a patch like this, which you could put in Config.pm yourself: 43 my $home = eval { (getpwuid($))[7] } || $ENV{HOME} || '.'; 44 $file = $home . /.libnetrc; -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how many items in a hash?
On Tue, Aug 14, 2001 at 10:59:08AM -0700, John Sands wrote: It seems a lot of overhead, though, to build a list of keys and count the number of items in the list, just to say: if (scalar(keys(%messages)) 0) { #do stuff } I thought there might be something faster. On the other hand, I'm far too new to Perl to be making these kinds of assumptions about how the scalar and keys functions are implemented! You're right, you shouldn't be making these kinds of assumptions. :) In fact, the keys operator in scalar context is optimized to just count the number of keys, not expand the keys into a temporary list and count that. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Associative array
At 11:12 AM 8/14/01 -0700, you wrote: Hi Peter, Can you be more specific? so I can use $foo = string; and then what? Then you type perldoc -f substr to learn about the substr function. You should see something like this, which contains all the information you need plus examples: substr EXPR,OFFSET,LENGTH,REPLACEMENT substr EXPR,OFFSET,LENGTH substr EXPR,OFFSET Extracts a substring out of EXPR and returns it. First character is at offset 0, or whatever you've set $[ to (but don't do that). If OFFSET is negative (or more precisely, less than $[), starts that far from the end of the string. If LENGTH is omitted, returns everything to the end of the string. If LENGTH is negative, leaves that many characters off the end of the string. You can use the substr() function as an lvalue, in which case EXPR must itself be an lvalue. If you assign something shorter than LENGTH, the string will shrink, and if you assign something longer than LENGTH, the string will grow to accommodate it. To keep the string the same length you may need to pad or chop your value using sprintf. If OFFSET and LENGTH specify a substring that is partly outside the string, only the part within the string is returned. If the substring is beyond either end of the string, substr() returns the undefined value and produces a warning. When used as an lvalue, specifying a substring that is entirely outside the string is a fatal error. Here's an example showing the behavior for boundary cases: my $name = 'fred'; substr($name, 4) = 'dy';# $name is now 'freddy' my $null = substr $name, 6, 2; # returns '' (no warning) my $oops = substr $name, 7; # returns undef, with warni ng substr($name, 7) = 'gap'; # fatal error An alternative to using substr() as an lvalue is to specify the replacement string as the 4th argument. This allows you to replace parts of the EXPR and return what was there before in one operation, just as you can with splice(). Thanks for your help. Eric On Tue, 14 Aug 2001, Peter Scott wrote: An associative array is the old name for a hash, which isn't what you're using. At 10:14 AM 8/14/01 -0700, Eric Wang wrote: Hi guys, Got a quick question. If I let @foo = some string; can I access say the t in this string by using $foo[6] ? You've got a scalar which you want to treat as an array. Put the string in a scalar, and use the substr() function (perldoc -f substr). -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Different OS, different results
print (6 * 4, \n); -Original Message- From: Guilherme Pinto [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 14, 2001 11:04 AM To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: Different OS, different results try a \n at the end of your print. -Original Message- From: David Bagwell [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 14, 2001 11:01 AM To: [EMAIL PROTECTED] Subject: Different OS, different results I have ActiveState Perl 5.6.1.628 running on Win98 and Linux Mandrake 8.0 running the same. When I run a simple program such as: #!/usr/bin/perl print 6 * 4; On the Win98 version, I get 24. On the linux version, I don't get anything. On another linux machine with a standard 5.6.0 perl install, I still don't get anything. Just curious why this happens. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Command line interface
On Tue, Aug 14, 2001 at 10:54:05AM -0700, Schooley, Chris wrote: Sorry, I should clarify - the program itself is like shell, has its own commands, etc. It is intended to simulate the command line interface found on various Cisco devices. Based on this, I'm going to assume you have a set of commands that you're checking thusly: if ($command eq 'foo') { do_foo(); } elsif ($command eq 'bar') { do_bar(); } ... What I typically do for problems like these is use a hash of hashes: %commands = ( foo = { sub = \do_foo, }, bar = { sub = \do_bar, }, ); Then you simply do a lookup: if ($commands{$command}) { $commands{$command}{'sub'}-(); } else { die(Unknown command name \$command\.\n); } I use a hash of hashes, instead of a hash of name = subroutine pairs, so that I can include other meta-data along with the command. For instance: %commands = ( foo = { sub = \do_foo, arguments = 2, usage = 'arg1 arg2', }, bar = { sub = \do_bar, arguments = [0, 1], usage = '[optional arg1]', }, ); With this, you can do things like check the number of arguments specified for the command, and if there aren't enough, or there are too many, print out a usage message. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [ADMIN] Re: [ADMIN] Re: FW: F*** YOU
On Tue, Aug 14, 2001 at 01:05:22PM -0500, Mooney Christophe-CMOONEY1 wrote: : Agreed. It would be nice not to have to deal with jerks on this list. No. John may have replied to his personal mail in an inappropriate manner, but he is willing to work it out. He has been in contact with all of the list admins and is trying to handle his problems more professionaly. I like this. It shows character. I can assure you that he won't be doing this anymore. Put a personal filter on him if you wish. As long a John is willing to learn from this mistake, I'm not going to hold it against him. If he chooses to continue in this manner, that is a different story. Believe it or not, this thread *really is closed*. Casey West -- Drill for oil? You mean drill into the ground to try and find oil? You're crazy. -- Drillers who Edwin L. Drake tried to enlist to his project to drill for oil in 1859. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: automatically naming scalars
Hi Jos: Thanks for the reply. At 05:44 PM 8/14/01 +0100, [EMAIL PROTECTED] wrote: I must agree with Jos on this ... I read the email and I saw that what Ron was asking for was soft reference ... like I mentioned before a lot of the situations (like I mentioned my experience) .. where you think that soft reference is the only way to do it is because your mindset had been stuck in that way but solutions using other data structures will do the job and everyone can understand it much better ... plus you get to keep strict which i never do without ... the use strict and #!perl lines have been programmed into my fingers already ... i had a situation once when one of my colleague was trying to get round a problem and he asked me how to do soft reference ... when i asked him why he explained what he was trying to do and suddenly we both realised that all he needed was a hash!! Look through the problem to make sure soft reference is what you want 'cos liek Jos said it is considered bad programming practice. Ok here's my original problem. I have 166 HTML tag pages that I'm processing one at a time. Each tag page can have 197 attributes and potentially more arguments. Once I process the tag section of the page, I have to address the attributes and arguments. The problem is that any given tag page can have none or 197 attributes or anywhere in between. I needed a method whereby I could create variables on the fly. What I ended up doing was taking the attribute name and appending it to an array. I then use the name to create a series of $attxxx{$attname} where xxx is a unique handle for a specific value that may or may not exist for that attribute. The name of the variable must come from the text on the page. Once I've gathered all of the attribute names into an array, I sort the array and begin processing the page. How can this be done while not using soft references? Do I make sense? Ron Woodall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Very simple newbie problem
Thank goodness for this kind of list. I'm very new and am experiencing some mass confusion of how things are done. I'm trying to write a simple script to interface with a router using Expect. This part works great, in the fact that it can log into the router and log to a file. The second part of the script looks in the file and searches for a particular connection type and prints the line. If I separate the two functions into separate scripts things work well. Combining them into the same script is driving me nuts. Here's the example: #!/usr/bin/perl -w # # This script is a test script to show what sites have active PPP sessions #use CGI; use Expect; use IO::Handle; use strict; my $count = 0; my $logfile = active-connections.txt; my $command; my $lines; check_active(); list_active(); sub check_active { system(rm -f $logfile); $command = Expect-spawn(telnet ip.add.re.ssB) or die Can not open telnet session to router: $!; $command-log_stdout(0); $command-log_file(active-connections.txt); print $command admin\n; print $command password\n; print $command sho caller\n; print $command exit\n; $command-soft_close(); #$command-hard_close(); } sub list_active { open (MYFILE, active-connections.txt) || die can not open file: $!; while ($lines = MYFILE) { print if $lines =~ /vty/; } } What's so difficult about this? - Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: automatically naming scalars
On Tue, Aug 14, 2001 at 02:38:54PM -0400, Ron Woodall wrote: Ok here's my original problem. I have 166 HTML tag pages that I'm processing one at a time. Each tag page can have 197 attributes and potentially more arguments. Once I process the tag section of the page, I have to address the attributes and arguments. The problem is that any given tag page can have none or 197 attributes or anywhere in between. I needed a method whereby I could create variables on the fly. What I ended up doing was taking the attribute name and appending it to an array. I then use the name to create a series of $attxxx{$attname} where xxx is a unique handle for a specific value that may or may not exist for that attribute. The name of the variable must come from the text on the page. Once I've gathered all of the attribute names into an array, I sort the array and begin processing the page. How can this be done while not using soft references? Your question has been answered in this thread already: use a hash. It can be done, really. Pull the variable portion out of the variable and use it as a key. So instead of $attxxx{$attname} use $att{xxx}{$attname}. The thing with using soft references is that you're, effectively, using the symbol table (the table of global variables and functions) as a hash. This has various points working against it that have been mentioned, including polluting an area used by other parts of the program, and making it difficult to track the variables you have in use. Instead of using the symbol table as a hash, use a hash as a hash; make a data structure that solves your problem. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Very simple newbie problem
Looking at the second sub in your script (list_active), I am wondering what you are trying to print. The script works as written (doesn't produce any errors), but the statement: print if $lines =~ /vty/; doesn't print anything. Try this: print $lines if $lines =~ /vty/; Hope this helps. Chris Rogers -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 14, 2001 2:43 PM To: [EMAIL PROTECTED] Subject: Very simple newbie problem Thank goodness for this kind of list. I'm very new and am experiencing some mass confusion of how things are done. I'm trying to write a simple script to interface with a router using Expect. This part works great, in the fact that it can log into the router and log to a file. The second part of the script looks in the file and searches for a particular connection type and prints the line. If I separate the two functions into separate scripts things work well. Combining them into the same script is driving me nuts. Here's the example: #!/usr/bin/perl -w # # This script is a test script to show what sites have active PPP sessions #use CGI; use Expect; use IO::Handle; use strict; my $count = 0; my $logfile = active-connections.txt; my $command; my $lines; check_active(); list_active(); sub check_active { system(rm -f $logfile); $command = Expect-spawn(telnet ip.add.re.ssB) or die Can not open telnet session to router: $!; $command-log_stdout(0); $command-log_file(active-connections.txt); print $command admin\n; print $command password\n; print $command sho caller\n; print $command exit\n; $command-soft_close(); #$command-hard_close(); } sub list_active { open (MYFILE, active-connections.txt) || die can not open file: $!; while ($lines = MYFILE) { print if $lines =~ /vty/; } } What's so difficult about this? - Scott -- 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: Very simple newbie problem
On Tue, Aug 14, 2001 at 02:43:29PM -0400, [EMAIL PROTECTED] wrote: The second part of the script looks in the file and searches for a particular connection type and prints the line. If I separate the two functions into separate scripts things work well. Combining them into the same script is driving me nuts. Here's the example: I need a little more elaboration on why it's driving you nuts. What are you getting? What did you expect. #!/usr/bin/perl -w -w, good. # # This script is a test script to show what sites have active PPP sessions #use CGI; use Expect; Why are you using Expect for this. Net::Telnet seems more appropriate. use IO::Handle; use strict; use strict, good. my $count = 0; I don't see this variable every used. I'm assuming it's a vestige from an earlier revision. my $logfile = active-connections.txt; You set this variable here, and use it in all of one place, meanwhile using the constant, active-connections.txt. You should use $logfile everywhere. my $command; my $lines; These variables should not be declared here, they should be declared in the smallest possible scope that needs them. See below. check_active(); list_active(); sub check_active { system(rm -f $logfile); Use unlink, perldoc -f unlink. Also, you need to check your return value, regardless of whether you use unlink or system. $command = Expect-spawn(telnet ip.add.re.ssB) or die Can not open telnet session to router: $!; Here is where you should declare $command. my $command = Expect-... $command-log_stdout(0); $command-log_file(active-connections.txt); print $command admin\n; print $command password\n; print $command sho caller\n; print $command exit\n; $command-soft_close(); #$command-hard_close(); } sub list_active { open (MYFILE, active-connections.txt) || die can not open file: $!; Here is where you should declare $lines. my $lines; And you probably shouldn't call it '$lines'; a plural variable name indicates it contains more than one value, this only ever contains one line. So, you should either rename it $line, or omit it altogether, as in: while (MYFILE) { print if /vty/; } while ($lines = MYFILE) { print if $lines =~ /vty/; } } I have no idea if the above suggestions will solve your problem. Once you give us a better idea of what your problem is we can give you some tips on what's wrong and how to fix it. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Very simple newbie problem
Thanks for the reply, Chris. Unfortunately, the script still doesn't print anything. The expect interface is to a Cisco router. The vty text pattern is always in the output file, but nothing prints. Like I mentioned before, if I take the second sub and make another script out of it, everything works ok. The vty connection type always exists when I telnet into the router. Eventually I will replace it with a PPP connection type and grep the name of the host connected. The result of the string I want looks like this (if searching for vty): vty 0admin VTY 00:00:00 00:00:00 - Scott On Tue, 14 Aug 2001, Chris Rogers wrote: Looking at the second sub in your script (list_active), I am wondering what you are trying to print. The script works as written (doesn't produce any errors), but the statement: print if $lines =~ /vty/; doesn't print anything. Try this: print $lines if $lines =~ /vty/; Hope this helps. Chris Rogers -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 14, 2001 2:43 PM To: [EMAIL PROTECTED] Subject: Very simple newbie problem Thank goodness for this kind of list. I'm very new and am experiencing some mass confusion of how things are done. I'm trying to write a simple script to interface with a router using Expect. This part works great, in the fact that it can log into the router and log to a file. The second part of the script looks in the file and searches for a particular connection type and prints the line. If I separate the two functions into separate scripts things work well. Combining them into the same script is driving me nuts. Here's the example: #!/usr/bin/perl -w # # This script is a test script to show what sites have active PPP sessions #use CGI; use Expect; use IO::Handle; use strict; my $count = 0; my $logfile = active-connections.txt; my $command; my $lines; check_active(); list_active(); sub check_active { system(rm -f $logfile); $command = Expect-spawn(telnet ip.add.re.ssB) or die Can not open telnet session to router: $!; $command-log_stdout(0); $command-log_file(active-connections.txt); print $command admin\n; print $command password\n; print $command sho caller\n; print $command exit\n; $command-soft_close(); #$command-hard_close(); } sub list_active { open (MYFILE, active-connections.txt) || die can not open file: $!; while ($lines = MYFILE) { print if $lines =~ /vty/; } } What's so difficult about this? - Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Very simple newbie problem
Thanks for the time you're helping me on this. Allow me to clarify. The file active-connections.txt contains this line: vty 0admin VTY 00:00:00 00:00:00 I ultimately want to modify the script to print /PPP/ stuff like: As88 mckinley_pm1 PPP 00:07:47 00:07:53 As of now, it doesn't print anything even if vty and PPP are in the file. The purpose, again, is to query a router of active PPP connections. The script then prints out a line like above. Expect works for me and logs the output to a file which is useful to me. When I run the script it queries the router, writes to the file and prints nothing. This is where I'm frustrated. Even though I know for sure there is something in that file, nothing is matched and printed. If I put sub list_active in it's own script by its lonesome, all is well. - Scott On Tue, 14 Aug 2001, Michael Fowler wrote: On Tue, Aug 14, 2001 at 02:43:29PM -0400, [EMAIL PROTECTED] wrote: The second part of the script looks in the file and searches for a particular connection type and prints the line. If I separate the two functions into separate scripts things work well. Combining them into the same script is driving me nuts. Here's the example: I need a little more elaboration on why it's driving you nuts. What are you getting? What did you expect. #!/usr/bin/perl -w -w, good. # # This script is a test script to show what sites have active PPP sessions #use CGI; use Expect; Why are you using Expect for this. Net::Telnet seems more appropriate. use IO::Handle; use strict; use strict, good. my $count = 0; I don't see this variable every used. I'm assuming it's a vestige from an earlier revision. my $logfile = active-connections.txt; You set this variable here, and use it in all of one place, meanwhile using the constant, active-connections.txt. You should use $logfile everywhere. Another vestige of earlier revisions. my $command; my $lines; These variables should not be declared here, they should be declared in the smallest possible scope that needs them. See below. check_active(); list_active(); sub check_active { system(rm -f $logfile); Use unlink, perldoc -f unlink. Also, you need to check your return value, regardless of whether you use unlink or system. Rookie error. Thanks. $command = Expect-spawn(telnet ip.add.re.ssB) or die Can not open telnet session to router: $!; Here is where you should declare $command. my $command = Expect-... $command-log_stdout(0); $command-log_file(active-connections.txt); print $command admin\n; print $command password\n; print $command sho caller\n; print $command exit\n; $command-soft_close(); #$command-hard_close(); } sub list_active { open (MYFILE, active-connections.txt) || die can not open file: $!; Here is where you should declare $lines. my $lines; And you probably shouldn't call it '$lines'; a plural variable name indicates it contains more than one value, this only ever contains one line. So, you should either rename it $line, or omit it altogether, as in: while (MYFILE) { print if /vty/; } while ($lines = MYFILE) { print if $lines =~ /vty/; } } I have no idea if the above suggestions will solve your problem. Once you give us a better idea of what your problem is we can give you some tips on what's wrong and how to fix it. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Very simple newbie problem
Ok, After taking into account all of your suggestions (except no Net::Telnet), the magic fix was for me to define my $command = Expect- ... inside the sub check_active. Thanks again! - Scott The new script functions On Tue, 14 Aug 2001, Michael Fowler wrote: On Tue, Aug 14, 2001 at 02:43:29PM -0400, [EMAIL PROTECTED] wrote: The second part of the script looks in the file and searches for a particular connection type and prints the line. If I separate the two functions into separate scripts things work well. Combining them into the same script is driving me nuts. Here's the example: I need a little more elaboration on why it's driving you nuts. What are you getting? What did you expect. #!/usr/bin/perl -w -w, good. # # This script is a test script to show what sites have active PPP sessions #use CGI; use Expect; Why are you using Expect for this. Net::Telnet seems more appropriate. use IO::Handle; use strict; use strict, good. my $count = 0; I don't see this variable every used. I'm assuming it's a vestige from an earlier revision. my $logfile = active-connections.txt; You set this variable here, and use it in all of one place, meanwhile using the constant, active-connections.txt. You should use $logfile everywhere. my $command; my $lines; These variables should not be declared here, they should be declared in the smallest possible scope that needs them. See below. check_active(); list_active(); sub check_active { system(rm -f $logfile); Use unlink, perldoc -f unlink. Also, you need to check your return value, regardless of whether you use unlink or system. $command = Expect-spawn(telnet ip.add.re.ssB) or die Can not open telnet session to router: $!; Here is where you should declare $command. my $command = Expect-... $command-log_stdout(0); $command-log_file(active-connections.txt); print $command admin\n; print $command password\n; print $command sho caller\n; print $command exit\n; $command-soft_close(); #$command-hard_close(); } sub list_active { open (MYFILE, active-connections.txt) || die can not open file: $!; Here is where you should declare $lines. my $lines; And you probably shouldn't call it '$lines'; a plural variable name indicates it contains more than one value, this only ever contains one line. So, you should either rename it $line, or omit it altogether, as in: while (MYFILE) { print if /vty/; } while ($lines = MYFILE) { print if $lines =~ /vty/; } } I have no idea if the above suggestions will solve your problem. Once you give us a better idea of what your problem is we can give you some tips on what's wrong and how to fix it. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Parameters
This is a very "abstract question-subject "but I'm counting on your help : It concerns functions'/methods' parameters - "threading" parametres into functions and methods (excuse me if that is not the right word but I 'm Greek and the dictionary won't help a lot!). Can anyone write me a few lines and explain all about them: what way is the whole thing done,alternatives,their range etc? Or redirect me somewhere where i can find reliable information from authoritative or reliable sources. Please if anyone who really does know the "theory" for the language can help , do so Thanks a lot .
Re: Very simple newbie problem
On Tue, Aug 14, 2001 at 04:03:51PM -0400, [EMAIL PROTECTED] wrote: When I run the script it queries the router, writes to the file and prints nothing. This is where I'm frustrated. Even though I know for sure there is something in that file, nothing is matched and printed. If I put sub list_active in it's own script by its lonesome, all is well. I see. It may very well be that the data is not flushed to the log file until the $command object is destroyed. Have you tried taking my suggestion regarding declaring $command within the subroutine it's used in? If not, do so. That may fix your problem. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Parameters
On Tue, Aug 14, 2001 at 11:20:00PM +0300, menihtas wrote: This is a very abstract question-subject but I'm counting on your help : It concerns functions'/methods' parameters - threading parametres into functions and methods You tell us what your question concerns, and what it's generally about, but you never ask it. What is your question? If you're trying to ask us to describe how, when, where, why, and how to use functions, methods, and method parameters then these questions are best answered in a basic Perl book. _Beginning Perl_ by Simon Cozens and _Learning Perl_ by Randal Schwartz are good basic Perl books. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to run FTP from a Perl Script
I have been looking at modules. But have not seen how to do an FTP session from a perl script that I can pass the appropriate info to. Any Suggestions? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Sendmail w/perl
That does indeed seem to be part of the problem. I added an or die statement to the open, and sure enough, it's dying with the error permission denied. However, nothing I do seems to fix that. It looks like the user mailnull is opening the perl script, with the shell /dev/null, which makes it difficult to work with. Thanks for the help though. Robert Aspinall Support Engineer V-ONE Corporation [EMAIL PROTECTED] - Original Message - From: Gary Stainburn [EMAIL PROTECTED] To: Robert Aspinall [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, August 14, 2001 9:19 AM Subject: Re: Sendmail w/perl I can't see anything wrong witth your code - as you say, there ain't that much of it. The one points I can mention (apart from the usual -w and use strict;) is that you don't chdir into anywhere so you may not be running where you think you're running. Also, there's no error checking, so if you are running in a directory where you don't have write access the open will fail without any warning. Hope these help. Gary On Tuesday 14 August 2001 2:04 pm, Robert Aspinall wrote: The aliases entry is ca: |caprocess.pl (since smrsh calls it and ignores the path anyway) The script has nothing of any substance in it, just something like #!/usr/bin/perl open (OUTPUT, output.txt); print OUTPUT testing!; print testing!; print STDERR testing!; Any ideas? Robert Aspinall Support Engineer V-ONE Corporation [EMAIL PROTECTED] - Original Message - From: Gary Stainburn [EMAIL PROTECTED] To: Robert Aspinall [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, August 14, 2001 8:54 AM Subject: Re: Sendmail w/perl Hows about giving us some code to look at? If it's a big un, just give us some snippets. Also, give us the aliases file entry that calls it. Gary On Tuesday 14 August 2001 1:51 pm, Robert Aspinall wrote: I have an alias that runs a perl script whenever mail is recieved for a certain account, but as far as I can tell, the perl script runs without doing a single thing. Is there a way to see the output of the script? I have it write hello to a text file (which never gets created), print hello to STDOUT, and even print hello to STDERR, and I don't see the slightest peep from it. Any suggestions? Robert Aspinall Support Engineer V-ONE Corporation [EMAIL PROTECTED] -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- 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: Sendmail w/perl
Hows about giving us some code to look at? If it's a big un, just give us some snippets. Also, give us the aliases file entry that calls it. Gary On Tuesday 14 August 2001 1:51 pm, Robert Aspinall wrote: I have an alias that runs a perl script whenever mail is recieved for a certain account, but as far as I can tell, the perl script runs without doing a single thing. Is there a way to see the output of the script? I have it write hello to a text file (which never gets created), print hello to STDOUT, and even print hello to STDERR, and I don't see the slightest peep from it. Any suggestions? Robert Aspinall Support Engineer V-ONE Corporation [EMAIL PROTECTED] -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to run FTP from a Perl Script
Net::FTP has a very nice interface to FTP. What in particular are you looking to pass? -Original Message- From: Russell Boyd [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 14, 2001 2:43 PM To: Subject: How to run FTP from a Perl Script I have been looking at modules. But have not seen how to do an FTP session from a perl script that I can pass the appropriate info to. Any Suggestions? -- 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: automatically naming scalars
a snippet of data you're trying to parse would probably be helpful in this case not all of it of course, but give us a fair idea =) Jos - Original Message - From: Ron Woodall [EMAIL PROTECTED] To: [EMAIL PROTECTED]; Jos I. Boumans [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, August 14, 2001 8:38 PM Subject: Re: automatically naming scalars Hi Jos: Thanks for the reply. At 05:44 PM 8/14/01 +0100, [EMAIL PROTECTED] wrote: I must agree with Jos on this ... I read the email and I saw that what Ron was asking for was soft reference ... like I mentioned before a lot of the situations (like I mentioned my experience) .. where you think that soft reference is the only way to do it is because your mindset had been stuck in that way but solutions using other data structures will do the job and everyone can understand it much better ... plus you get to keep strict which i never do without ... the use strict and #!perl lines have been programmed into my fingers already ... i had a situation once when one of my colleague was trying to get round a problem and he asked me how to do soft reference ... when i asked him why he explained what he was trying to do and suddenly we both realised that all he needed was a hash!! Look through the problem to make sure soft reference is what you want 'cos liek Jos said it is considered bad programming practice. Ok here's my original problem. I have 166 HTML tag pages that I'm processing one at a time. Each tag page can have 197 attributes and potentially more arguments. Once I process the tag section of the page, I have to address the attributes and arguments. The problem is that any given tag page can have none or 197 attributes or anywhere in between. I needed a method whereby I could create variables on the fly. What I ended up doing was taking the attribute name and appending it to an array. I then use the name to create a series of $attxxx{$attname} where xxx is a unique handle for a specific value that may or may not exist for that attribute. The name of the variable must come from the text on the page. Once I've gathered all of the attribute names into an array, I sort the array and begin processing the page. How can this be done while not using soft references? Do I make sense? Ron Woodall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Parameters (definition,or sort of!)
I' m afraid i can't aford that book or any such book-i tried every single store and here's the big problem:almost all books(and especially the descent ones!) concerning PERL cost about 50$ in Greece (15-2000 drh) and that is why i'm asking the list such stupid questions... The question is so abstract there is no ? !!! It's actually only about the parametres... Anyway , thanks for evrybody's help - book recomendations are welcome just like any answer, THANKS a vey lot,again and again! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
no need i'm gone
I have all of your addresses as well. see ya -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: modules
How do I know what modules are installed ? Does the CGI_Lite module come bundled by default? This question is a CPAN FAQ, which you can read here: http://www.cpan.org/misc/cpan-faq.html#How_installed_modules You may find the other CPAN FAQs useful; the url for the full list is slightly different: http://www.cpan.org/misc/cpan-faq.html Best wishes, Rachel -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Best Practices: Error Handling???
On Tue, Aug 14, 2001 at 09:04:06AM -0500, David Simcik wrote: I've been perusing the Camel book, the Cookbook, CGI Programming w/Perl, and Effective Perl for answers to this question, but have yet to find one or two definitive solutions. I've seen the standard die/eval() statements and the use of the various incarnations of Carp, but I have yet to see anyone say something along the lines of this is the most common approach. I find myself longing for the consistency of try/catch blocks. Can anyone shed some light on the situation? Use 'foo() or die' when a failure is truly unrecoverable in your program. For example, if you can't write to your output files, make a directory, locate a required program, etc. eval {} is *really* try {} with a different spelling. (Not to be confused with eval ; which is different.) The problem is that the subsequent catch statement is a little more unwieldy (if ($!) ... ), and there is no finally clause. die is pretty darn final. It's not a good idea to use die within a module (there are exceptions, and this rule is not written in stone). Use some variant of carp to throw an exception within a module, but return an error to the caller, and let the caller determine whether or not the error is truly unrecoverable. That's a reasonable snapshot of the basic language features. You can use Error.pm or other modules if you want something more structured. I believe there is an exceptions module on CPAN that uses try {} catch {} syntax (like C++/Perl6). HTH, Z. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Best Practices: Error Handling???
a while ago i had asked the same question (or one on similar lines). my specific need was error handling for modules to be used by somebody else. in such cases die/eval can become very cumbersome. error handling can be designed after two streams of logic: 1) error to be handled where the error occured. 2) error to be handled by the caller (which in turn might return an error indication to the caller without handling the error itself. the first option usually occurs only in small scripts. code which needs to recover from errors at the same sub-routine call level and at the caller level would look horrible with die/eval blocks IMO. so with that in mind i have designed a small OO error handling module which i use for the general purpose module that i am building. a user of this module could do something like this use Nix::Err; sub foo { sysopen (FH, 'boo', O_RDONLY) || return (Nix::Err-new ('sysopen')); } as the object is overloaded to return a false in boolean context it can be used by the caller as below if the caller is not interested in debugging and just needs to die foo () or die ('foo: failed'); or $retval = foo () or $retval-die ('foo: failed'); or $retval = foo () or $retval-warn ('foo: failed'); raising the debuglevel one could even get a Carp/Croak like stack backtrace at the point of error. Nix::Err-debuglevel (2); # now call die/warn methods i would be extremely glad to get criticisms, comments, suggestions, improvements, on it. here is the url for the code www.extremix.net/Err.pm karthik On Tue, Aug 14, 2001 at 08:53:34AM -0700, Peter Scott wrote: At 09:04 AM 8/14/01 -0500, David Simcik wrote: I've been perusing the Camel book, the Cookbook, CGI Programming w/Perl, and Effective Perl for answers to this question, but have yet to find one or two definitive solutions. I've seen the standard die/eval() statements and the use of the various incarnations of Carp, but I have yet to see anyone say something along the lines of this is the most common approach. I find myself longing for the consistency of try/catch blocks. Can anyone shed some light on the situation? try/catch blocks will be in Perl 6. If you want them in Perl 5, use the module Error.pm from CPAN. I do, and I like it. Some people think this is a needless embellishment on using die/eval, which is what Error.pm turns try/catch into anyway. To each his/her own. -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.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]
index inside foreach{ ..}
I have read something but could not find an answer: I had to do a foreach like this: A @a = (a,b,c,d,e); foreach $b (reverse @a) { print $b\n; }; Now i needed to access the index inside the foreach to do: B @a = (a,b,c,d,e); foreach $b (reverse @a) { print $index $b\n; }; which i did with a additional variable C @a = (a,b,c,d,e); $index =0; foreach $b (reverse @a) { $index++; print $index $b\n; }; Is there a way to acces the internal index of the foreach loop as $index in example B ? Thanks in advance Matth -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Sendmail w/perl
The aliases entry is ca: |caprocess.pl (since smrsh calls it and ignores the path anyway) The script has nothing of any substance in it, just something like #!/usr/bin/perl open (OUTPUT, output.txt); print OUTPUT testing!; print testing!; print STDERR testing!; Any ideas? Robert Aspinall Support Engineer V-ONE Corporation [EMAIL PROTECTED] - Original Message - From: Gary Stainburn [EMAIL PROTECTED] To: Robert Aspinall [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, August 14, 2001 8:54 AM Subject: Re: Sendmail w/perl Hows about giving us some code to look at? If it's a big un, just give us some snippets. Also, give us the aliases file entry that calls it. Gary On Tuesday 14 August 2001 1:51 pm, Robert Aspinall wrote: I have an alias that runs a perl script whenever mail is recieved for a certain account, but as far as I can tell, the perl script runs without doing a single thing. Is there a way to see the output of the script? I have it write hello to a text file (which never gets created), print hello to STDOUT, and even print hello to STDERR, and I don't see the slightest peep from it. Any suggestions? Robert Aspinall Support Engineer V-ONE Corporation [EMAIL PROTECTED] -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- 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: Sendmail w/perl
I can't see anything wrong witth your code - as you say, there ain't that much of it. The one points I can mention (apart from the usual -w and use strict;) is that you don't chdir into anywhere so you may not be running where you think you're running. Also, there's no error checking, so if you are running in a directory where you don't have write access the open will fail without any warning. Hope these help. Gary On Tuesday 14 August 2001 2:04 pm, Robert Aspinall wrote: The aliases entry is ca: |caprocess.pl (since smrsh calls it and ignores the path anyway) The script has nothing of any substance in it, just something like #!/usr/bin/perl open (OUTPUT, output.txt); print OUTPUT testing!; print testing!; print STDERR testing!; Any ideas? Robert Aspinall Support Engineer V-ONE Corporation [EMAIL PROTECTED] - Original Message - From: Gary Stainburn [EMAIL PROTECTED] To: Robert Aspinall [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, August 14, 2001 8:54 AM Subject: Re: Sendmail w/perl Hows about giving us some code to look at? If it's a big un, just give us some snippets. Also, give us the aliases file entry that calls it. Gary On Tuesday 14 August 2001 1:51 pm, Robert Aspinall wrote: I have an alias that runs a perl script whenever mail is recieved for a certain account, but as far as I can tell, the perl script runs without doing a single thing. Is there a way to see the output of the script? I have it write hello to a text file (which never gets created), print hello to STDOUT, and even print hello to STDERR, and I don't see the slightest peep from it. Any suggestions? Robert Aspinall Support Engineer V-ONE Corporation [EMAIL PROTECTED] -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Code for review
On Tue, Aug 14, 2001 at 10:33:31AM -0400, Yacketta, Ronald wrote: Please be open and honest, I am looking to speed up the script and make it more efficient as well sub get_oracle_time () { # Lets get the time it takes to connect to oracle my ( $key, $value ); $oratime = qx( (timex sqlplus $RTDUSER/$RTDPASS\@RTD_ORACLE_SID -!/dev/null quit ! ) 21); Here you're spawning a shell to connect to the database using sqlplus. How about use a DBI connection instead: use Benchmark; use DBI; $oratime = timeit( 1, sub { # Connect to the database. my $dbh = DBI-connect( $ENV{DBI_DSN}, $ENV{DBI_USER}, $ENV{DBI_PASS}, {RaiseError = 0, PrintError = 1} ); die $DBI::errstr if $DBI::err; # ... added error checking here $dbh-disconnect if $dbh; } ); print Connect/Disconnect : time: , timestr( $oratime ), \n; # Connect/Disconnect : time: 0 wallclock secs ( 0.06 usr + 0.01 sys = 0.07 CPU) @ 14.29/s (n=1) # Or an example using Time::HiRes, taken mostly from perldoc # Time::HiRes use Time::HiRes qw( gettimeofday tv_interval ); # measure elapsed time # (could also do by subtracting 2 gettimeofday return values) my $t0 = [gettimeofday]; # Connect to the database. my $dbh = DBI-connect( $ENV{DBI_DSN}, $ENV{DBI_USER}, $ENV{DBI_PASS}, {RaiseError = 0, PrintError = 1} ); die $DBI::errstr if $DBI::err; # ... added error checking here $dbh-disconnect if $dbh; $elapsed = tv_interval ($t0); # equivalent code print Connect/Disconnect : elapsed time: , $elapsed, \n; # Connect/Disconnect : elapsed time: 0.095902 _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
printing to a filehandle
I need some help figuring out where I'm going wrong with trying to print to this filehandle. The file is being created, but I can't print anything to the file. Oh, and for a twist, this is Perl v4, not my choice, but what I'm forced to live with for now. open (RENAME, renamedep.tmp); $test=blah; print RENAME ($test\n); close RENAME; I'm sure it's something trivial, but I've been staring at this for 3 hours now really am missing something. Thank you, Paul -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: printing to a filehandle
You need to quote blah. $test = blah; -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 14, 2001 6:04 PM To: [EMAIL PROTECTED] Subject: printing to a filehandle I need some help figuring out where I'm going wrong with trying to print to this filehandle. The file is being created, but I can't print anything to the file. Oh, and for a twist, this is Perl v4, not my choice, but what I'm forced to live with for now. open (RENAME, renamedep.tmp); $test=blah; print RENAME ($test\n); close RENAME; I'm sure it's something trivial, but I've been staring at this for 3 hours now really am missing something. Thank you, Paul -- 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]
test
test == VINTEK CONSULTING PTY LTD (ACN 088 825 209) Email: [EMAIL PROTECTED] WWW:http://www.vintek.net Tel:(08) 8523 5035 Fax:(08) 8523 2104 Snail: P.O. Box 312 Gawler SA 5118 == -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]