show job status
Hi, I have a CGI script that takes some time to finish searching the DB. In the meanwhile, how do I show that the job is being processed? I tried just simple printing the same, but it wouldnt show up until the search is over. I tried using threads with the same result. Thanks. -- P -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Send mail weirdness
Greetings, my client claims he never receives any email from his contact page! I however have set up a 'BCC' and am getting email via the script below. His connection to the 'net is via AOL, and when I mail him from my email client using [EMAIL PROTECTED] he receives it, but not from the script below. Do you see any errors or problems via AOL? What could be the issue, I just don't see anything! Thanks :) Dave Gilden --- #!/usr/local/bin/perl use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); use POSIX 'strftime'; use strict; my $mailprog = '/usr/lib/sendmail'; my $subject = Jakes's Lawn Care Contact Page; my $date = strftime('%A, %B %d, %Y %I:%M %p',localtime(time() + (2*60*60))); my $name = param('First Name') . . param('Last Name'); my $email= param('email'); $email = lc($email); # Send E-Mail send_mail; # Return HTML Page print redirect(/pages/thankyou.html); exit; sub send_mail { my $data; $email ||= '[EMAIL PROTECTED]'; open(MAIL, |$mailprog -t); print MAIL TO: [EMAIL PROTECTED]; print MAIL BCC: [EMAIL PROTECTED]; print MAIL From: $name $email\n; print MAIL Subject: $subject\n\n; print MAIL $subject: $date\n, '-' x 60, \n ; foreach my $val (param()){ $data = param($val); print MAIL $val: $data\n; } close(MAIL); } -- Words are like money; there is nothing so useless, unless when in actual use. -Samuel Butler, writer (1835-1902) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Send mail weirdness
It could be that AOL looks at the headers and sees that the message is being sent by [EMAIL PROTECTED], which is the user of many web servers, which is different than the from address. It thinks that a forgery is taking place and that the e-mail is spam and discards it. Just an idea which I am trying to prove with an ISP in Germany where I have experienced the same problem. Greg Smith -Original Message- From: David Gilden [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 10:41 AM To: [EMAIL PROTECTED] Subject: Send mail weirdness Greetings, my client claims he never receives any email from his contact page! I however have set up a 'BCC' and am getting email via the script below. His connection to the 'net is via AOL, and when I mail him from my email client using [EMAIL PROTECTED] he receives it, but not from the script below. Do you see any errors or problems via AOL? What could be the issue, I just don't see anything! Thanks :) Dave Gilden --- #!/usr/local/bin/perl use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); use POSIX 'strftime'; use strict; my $mailprog = '/usr/lib/sendmail'; my $subject = Jakes's Lawn Care Contact Page; my $date = strftime('%A, %B %d, %Y %I:%M %p',localtime(time() + (2*60*60))); my $name = param('First Name') . . param('Last Name'); my $email= param('email'); $email = lc($email); # Send E-Mail send_mail; # Return HTML Page print redirect(/pages/thankyou.html); exit; sub send_mail { my $data; $email ||= '[EMAIL PROTECTED]'; open(MAIL, |$mailprog -t); print MAIL TO: [EMAIL PROTECTED]; print MAIL BCC: [EMAIL PROTECTED]; print MAIL From: $name $email\n; print MAIL Subject: $subject\n\n; print MAIL $subject: $date\n, '-' x 60, \n ; foreach my $val (param()){ $data = param($val); print MAIL $val: $data\n; } close(MAIL); } -- Words are like money; there is nothing so useless, unless when in actual use. -Samuel Butler, writer (1835-1902) -- 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]
Apache Logs
Hello, I was wondering if someone knows of any Perl Modules that designed to read and process the various types of apache access_log files like common, combined..etc ?? thx's -- MikemickaloBlezien =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Thunder Rain Internet Publishing Providing Internet Solutions that work! http://www.thunder-rain.com Quality Web Hosting http://www.justlightening.net MSN: [EMAIL PROTECTED] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
easiest `cat` in perl
I'm just barely starting into the world of CGI. I think this is going to be the best thing I ever did. What I think I want to do is have a library of HTML snippets (like a generic header and footer), and then use perl to output them in order along with any custom content. What I'm interested in is what's the easiest way to print the contents of a file? For example, if I want to output my header file, header.incl, how can I print the contents of that file the easiest (and most generally compatible)? I've tended to shy away from backticks because I kind-of feel like they're not real perl, and somehow less portable. Should I feel that way? TIA. - Bryan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Thanks]: Re: Objects, threads and so on
david wrote: Fernando wants to send the following thanks to all people who helped him on this topic and some explanation of what he really wants to do. He somehow sent it to myself only. #- forward message started -# Hello all, OK, then. One subject at a time. It helps in focusing your efforts, both in posting to a list, and in designing your code. I want to have a class I won't instanciate Here I was badly trying to define a set of functions, procedures and attributes which you can use from anywhere in your program, and which are collected under a common class, but something you don't have to instanciate = which, in Perl, seems to be a namespace or package. Got it. An example could be a Config class which has methods like WriteConfig or ReadConfig -- like for reading .ini files, and it has no sense (for me) to instanciate such a class. Hmmm, I;m not sure about that. It seems to me that a common handler for such a purpose would allow it to be used for many programs, or for many users of the same program. If you want to make your preferences more granular, instantiation could be a benefit...but that is not what you are asking for. There is no reason that you cannot make a package to hold appropriately global data. We seldom encourae such approaches, because usually students are just avoiding certain challenges, such as strict compilation, thinking out scopes, etc. Never the less here is one that has not a hint of instances, and writes and reads an ini file. RJNConfig.pm: package RJNConfig; # less likely to step on existing modules than a # generic name like Config alone use strict; use warnings; use Exporter; our @ISA = ('Exporter'); our @EXPORT_OK = (); our @EXPORT = qw(get_specifications write_specifications $specifications); our $specifications = {}; use constant PROGRAM_NAME = 'test_single_config'; my $program_name = PROGRAM_NAME; sub get_specifications { open IN, $program_name.ini or return 0, 'Could not open program initiation file'; while (my $spec_line = IN) { chomp $spec_line; my ($specification, $value) = split /\s*=\s*/, $spec_line; $specifications-{$specification} = $value; } close IN; return $specifications, 0; } sub write_specifications { our $specifications = $_[0]; open OUT, $program_name.ini or return; foreach (keys %$specifications) { my $spec_line = $_ = $specifications-{$_}\n; print OUT $spec_line; } close OUT; } #!perl use strict; use warnings; use RJNConfig; my ($specs, $error) = get_specifications(); foreach (keys %$specs) { print the $_ of this program is $specs-{$_}\n; } print Now you set the specs, user-guy, since it IS your machine. Cry UNCLE when you've had enough\n; my %specs; my $line; while (defined ($line = STDIN) and !($line =~ /UNCLE/i)) { my $spec = $line; chomp $spec; my $value = STDIN; chomp $value; $specs{$spec} = $value; } write_specifications(\%specs) Testing at the command-line: Greetings! E:\d_drive\perlStufftest_single_config.pl the Program name of this program is test_single_config the Purpose of this program is To mess wit ya, man Now you set the specs, user-guy, since it IS your machine. Cry UNCLE when you've had enough Favorite Movie Lassie Come Home Favorite song Mr. Rogers' Neighborhood UNCLE Greetings! E:\d_drive\perlStufftest_single_config.pl the Favorite song of this program is Mr. Rogers' Neighborhood the Favorite Movie of this program is Lassie Come Home Now you set the specs, user-guy, since it IS your machine. Cry UNCLE when you've had enough Some silly-ass global spec A happenstance value sure to get me in trouble Another spec that came out of nowhere By serindipity, a value that actually makes sense. UNCLE Greetings! E:\d_drive\perlStuff Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
explicit vs implicit syntax
Is it really bad practice oneway or another with calling sub? doMe; doMe(); doMe; doMe(); Please explain in terms of performance and practice. thanks, -rkl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: explicit vs implicit syntax
Generally the use of the ampersand in subroutine calling is considered a bad habit even though it will work for most subs. For one thing, a sub called with the ampersand ignores any subroutine prototyping. As far as the parentheses go, I always use them even if there is nothing being passed because it makes for more legible code. Someone else can probably give you a more in-depth explanation of the two. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 12:14 AM To: [EMAIL PROTECTED] Subject: explicit vs implicit syntax Is it really bad practice oneway or another with calling sub? doMe; doMe(); doMe; doMe(); Please explain in terms of performance and practice. thanks, -rkl -- 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: explicit vs implicit syntax
Here's an excerpt about the from orielly and what the heck does it means: ...If a subroutine is called using the form, the argument list is optional. if ommitted, no @_ array is setup for the routine; the @_ array at the time of the call is visible to subroutine instead. So, is there a better or worse? both ways works for me. I just started going back and putting the onto the sub ;) I don't like it the but I thought that you need it. Anymore comment is good. -rkl Generally the use of the ampersand in subroutine calling is considered a bad habit even though it will work for most subs. For one thing, a sub called with the ampersand ignores any subroutine prototyping. As far as the parentheses go, I always use them even if there is nothing being passed because it makes for more legible code. Someone else can probably give you a more in-depth explanation of the two. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 12:14 AM To: [EMAIL PROTECTED] Subject: explicit vs implicit syntax Is it really bad practice oneway or another with calling sub? doMe; doMe(); doMe; doMe(); Please explain in terms of performance and practice. thanks, -rkl -- 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: problem with date routine
Perlwannabe wrote: I have a relatively simple script that needs to get two separate dates, today's date, and yesterday's date. The dates are in mmddyy format. Everything works great on days 2 - 31 of the month, but on the first of the month yesterday's date is not correct. For example, on October 1, 2003 the variable $dateyesterday was 13 when it needed to be 093003. Obviously, there is no 13. Is there a way to deal with this problem on the first day of every month? The easiest way is to get the results from the time() function which returns the number of seconds since the epoch and subtract the number of seconds in one day and pass that value to either the localtime() or gmtime() function. ## BEGIN SCRIPT my ($mday, $mon, $year) = (localtime)[3..5]; my $datetoday = sprintf (%02d%02d%02d, ++$mon, $mday, $year-100); ^ Why are you subtracting 100 from the year value returned from localtime? You do realize that if the year is 1999 or earlier the result will be a negative number and if the year is 2100 or later the result will be a three digit number? To always get a two digit value use modulo instead of subtraction. my $datetoday = sprintf '%02d%02d%02d', $mon + 1, $mday, $year % 100; print (the value of datetoday is $datetoday\n); my ($yesterdaymday, $yesterdaymon, $yesterdayyear) = (localtime)[3..5]; my $dateyesterday = sprintf (%02d%02d%02d, ++$yesterdaymon, $yesterdaymday-1, $yesterdayyear-100); # seconds in one day = 60 seconds * 60 minutes * 24 hours = 86400 seconds my ( $yesterdaymday, $yesterdaymon, $yesterdayyear ) = (localtime time - 86400)[ 3 .. 5 ]; my $dateyesterday = sprintf '%02d%02d%02d', $yesterdaymon + 1, $yesterdaymday, $yesterdayyear % 100; print (the value of datetoday is $dateyesterday\n); John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Group list elements
Hi, I'm looking for a solution for the following problem: This is the list I have : $kommalist =20,21,22,23,24,25,27,28,31,32,33; And I want to convert it into : $newlist =20..25,27,28,31..33; So, I only want to combine the elements if there are more than two like 20,21,23 Any hint or code will help. Thanks in advance. Götz -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: easiest `cat` in perl
On Wed, 01 Oct 2003 23:14:00 -0700 Bryan Harris [EMAIL PROTECTED] wrote: What I'm interested in is what's the easiest way to print the contents of a file? For example, if I want to output my header file, header.incl, how can I print the contents of that file the easiest (and most generally compatible)? Firstly specify the file; $file = /location/of/header.incl; Next open it for reading open (FH, $file) or die Cannot open file $file $!; Lastly, go through the file line by line and print them while(FH){ print $_; #$_ is the value of the current line } You may wish to change the print line to print $_br\n;if you want a new line on your html for each new line in your file. Owen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: explicit vs implicit syntax
[EMAIL PROTECTED] wrote: Here's an excerpt about the from orielly and what the heck does it means: ...If a subroutine is called using the form, the argument list is optional. if ommitted, no @_ array is setup for the routine; the @_ array at the time of the call is visible to subroutine instead. So, is there a better or worse? both ways works for me. I just started going back and putting the onto the sub ;) I don't like it the but I thought that you need it. No you don't need it and you shouldn't use it unless you do need it. And if you don't know whether you need it or not then you probably don't need it. perldoc perlsub [snip] A subroutine may be called using an explicit `' prefix. The `' is optional in modern Perl, as are parentheses if the subroutine has been predeclared. The `' is not optional when just naming the subroutine, such as when it's used as an argument to defined() or undef(). Nor is it optional when you want to do an indirect subroutine call with a subroutine name or reference using the `$sub ref()' or `{$subref}()' constructs, although the `$sub ref-()' notation solves that problem. See the perlref manpage for more about all that. Subroutines may be called recursively. If a subroutine is called using the `' form, the argument list is optional, and if omitted, no [EMAIL PROTECTED]' array is set up for the subrou tine: the [EMAIL PROTECTED]' array at the time of the call is visible to subroutine instead. This is an efficiency mechanism that new users may wish to avoid. foo(1,2,3);# pass three arguments foo(1,2,3); # the same foo(); # pass a null list foo(); # the same foo; # foo() get current args, like foo(@_) !! foo;# like foo() IFF sub foo predeclared, else foo Not only does the `' form make the argument list optional, it also disables any prototype checking on argu ments you do provide. This is partly for historical rea sons, and partly for having a convenient way to cheat if you know what you're doing. See the Prototypes manpage below. [snip] Constant Functions Functions with a prototype of `()' are potential candi dates for inlining. If the result after optimization and constant folding is either a constant or a lexically- scoped scalar which has no other references, then it will be used in place of function calls made without `'. Calls made using `' are never inlined. (See constant.pm for an easy way to declare most constants.) John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: easiest `cat` in perl
On Thursday 02 Oct 2003 10:25 am, Owen wrote: On Wed, 01 Oct 2003 23:14:00 -0700 Bryan Harris [EMAIL PROTECTED] wrote: What I'm interested in is what's the easiest way to print the contents of a file? For example, if I want to output my header file, header.incl, how can I print the contents of that file the easiest (and most generally compatible)? Firstly specify the file; $file = /location/of/header.incl; Next open it for reading open (FH, $file) or die Cannot open file $file $!; Lastly, go through the file line by line and print them while(FH){ print $_; #$_ is the value of the current line } You may wish to change the print line to print $_br\n;if you want a new line on your html for each new line in your file. Owen Hi Owen, One thing you forgot was to close the file. Also, don't forget that you can do it with less typing: $file = /location/of/header.incl; open (FH, $file) or die Cannot open file $file $!; print while(FH); close(FH); -- 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: explicit vs implicit syntax
[EMAIL PROTECTED] asked: Here's an excerpt about the from orielly and what the heck does it means: ...If a subroutine is called using the form, the argument list is optional. if ommitted, no @_ array is setup for the routine; the @_ array at the time of the call is visible to subroutine instead. If in doubt, run a test ;-) #!/usr/bin/perl -w use strict; sub showargs { print arguments are: . join(', ', @_) . \n; } sub test { print Arguments for test() are: . join(', ', @_) . \n; print Calling showargs - ; showargs; print Calling showargs() - ; showargs(); print Calling showargs - ; showargs; print Calling showargs() - ; showargs(); } test qw(foo baz bar); __END__ So, is there a better or worse? both ways works for me. I just started going back and putting the onto the sub ;) I don't like it the but I thought that you need it. See for yourself - there's only one use for the ampersand, and it's obscure. My advice would be to avoid using it even in the one situation where it would make sense - when passing @_ as an argument to your function. Sure, it is idiomatic Perl at its best, but it also makes a program harder to read and understand. In other words - save it for Perl Golf ;-) HTH, Thomas PS: Perl Golf - writing code with as little (key-)strokes as possible. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: explicit vs implicit syntax
In other words - save it for Perl Golf ;-) HTH, Thomas PS: Perl Golf - writing code with as little (key-)strokes as possible. Thomas, Beyond all the enlightenment that this list brings, I am stunned (ROTFLMAO) to realize that coding could be a sport. Cya at the 19th hole. Chuck -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: problem with date routine
perlwannabe [EMAIL PROTECTED] wrote: : : I have a relatively simple script that needs to get : two separate dates, today's date, and yesterday's : date. The dates are in mmddyy format. : Here is the script: : : : ## BEGIN SCRIPT : my ($mday, $mon, $year) = (localtime)[3..5]; : my $datetoday = sprintf (%02d%02d%02d, ++$mon, $mday, $year-100); : : print (the value of datetoday is $datetoday\n); : : : my ($yesterdaymday, $yesterdaymon, $yesterdayyear) = : (localtime)[3..5]; : my $dateyesterday = sprintf (%02d%02d%02d, ++$yesterdaymon, : $yesterdaymday-1, $yesterdayyear-100); : print (the value of datetoday is $dateyesterday\n); : : ### END SCRIPT # A couple of others have pointed out the errors above and fixes. I'd like to introduce you to the POSIX function 'strftime' and the perl variable '$^T'. One problem above involves testing very close to midnight. It is unlikely, but possible for a routine built on two calls to localtime() to return the same date for today and yesterday. The first call would need to be before midnight and the second call would have to be after midnight. Admittedly, this would be very uncommon, but certainly possible. The perl variable '$^T' is the time the script started. Using localtime( $^T ) provides the same date each time and may still be relevant to the current time. 'strftime' is very similar to the same unix function. The biggest problem is the POSIX documentation, which assumes you have access to the unix command line. Here is an online link to the 'strftime' function. http://www.scit.wlv.ac.uk/cgi-bin/mansec?3C+strftime Here's one solution using strftime() and '$^T': use POSIX 'strftime'; use constant DATE_FORMAT = '%m%d%y'; . . . my $yesterday = strftime DATE_FORMAT, localtime $^T - 86400; my $today = strftime DATE_FORMAT, localtime $^T; printf Today: %10s\nYesterday: %4s\n, $today, $yesterday; HTH, Charles K. Clarkson -- Head Bottle Washer, Clarkson Energy Homes, Inc. Mobile Home Specialists 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
perl -v produces different output each time
Hi all, May I start by thanking all the people who have helped me in the past, and I hope you can help me with this one. I have a Solaris 5.8 server with a version of Perl provided as part of Rational ClearCase, and I am getting very strange errors. Sometimes scripts fail when use'ing Getopt::Long because of the version requirements of Getopt::Long. The problem doesn't always appear so I tried to find the source of the problem, and I think it's this. I ran /usr/atria/bin/Perl -v many times and got different results. 109 fe2sk227 ccadmin /usr/atria/bin/Perl -v This is perl, version 4.864 with DEBUGGING EMBED Copyright 1987-1996, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5.0 source kit. 110 fe2sk227 ccadmin /usr/atria/bin/Perl -v This is perl, version 5.002 with DEBUGGING EMBED Copyright 1987-1996, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5.0 source kit. 111 fe2sk227 ccadmin /usr/atria/bin/Perl -v This is perl, version 4.864 with DEBUGGING EMBED Copyright 1987-1996, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5.0 source kit. Has anybody got any ideas? These are the errors from the script 116 fe2sk227 ccadmin /usr/atria/config/scheduler/tasks/sync_receive Perl 5 required--this is only version 4.864, stopped at /usr/atria/lib/perl5/Getopt/Long.pm line 12. BEGIN failed--compilation aborted at /usr/atria/config/scheduler/tasks/sync_receive.bat line 35. 117 fe2sk227 ccadmin /usr/atria/config/scheduler/tasks/sync_receive Perl 3.67001847483647 required--this is only version 4.864, stopped at /usr/atria/lib/perl5/Getopt/Long.pm line 12. BEGIN failed--compilation aborted at /usr/atria/config/scheduler/tasks/sync_receive.bat line 35. Cheers, Jim Jim Halkyard Configuration Management Engineer NEC Technologies (UK) Ltd Tel: +44 (0) 118 965 4632 www.nectech.co.uk mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
OT: Redirect perldoc to usb printer
Kind of off topic. How can you redirect to a usb printer from the shell in windows xp? Its getting really irritating having to perldoc -f function function.txt Open function.txt in notepad and then print. Thanks, Paul -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: perl -v produces different output each time
Hi, I would not try to understand the problem too much, but instead just get rid of it and improve the perl environment on your server. To do this I suggest that you upgrade to a late version of perl. You can get sources for 5.8.1 from http://www.perl.com/pub/a/language/info/software.html and build them yourself if you want. It's best to put them in /usr/local/ and not /usr/atria/ so you don't confuse the ClearCase installation. You can get perl 5.8.0 for Solaris 8 in Solaris pkg format from http://www.sunfreeware.com. That will install in /opt/ which is a good location too. When you have the late version of perl installed, then symlink it into the atria bin directory for compatibility with your current shell environment in term of PATH and the like, i.e from the solaris command line: mv /usr/atria/bin/Perl /usr/atria/bin/Perl.orig ln -s /usr/local/bin/perl /usr/atria/bin/Perl # sub /opt/...for /usr/local/...if needed Do the same for all other perl executables in /usr/atria/bin/, e.g. perldoc if it's there. I don't guarantee this will fix all the perl configuration problems on your server, but I think it will help and at least you will have a cleanly installed, late rev of the perl distribution on it. You may get some errors about missing modules, in which case they will have to be added to your new perl installation. -tristram -Original Message- From: Halkyard, Jim [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 8:52 AM To: '[EMAIL PROTECTED]' Subject: perl -v produces different output each time Hi all, May I start by thanking all the people who have helped me in the past, and I hope you can help me with this one. I have a Solaris 5.8 server with a version of Perl provided as part of Rational ClearCase, and I am getting very strange errors. Sometimes scripts fail when use'ing Getopt::Long because of the version requirements of Getopt::Long. The problem doesn't always appear so I tried to find the source of the problem, and I think it's this. I ran /usr/atria/bin/Perl -v many times and got different results. 109 fe2sk227 ccadmin /usr/atria/bin/Perl -v This is perl, version 4.864 with DEBUGGING EMBED Copyright 1987-1996, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5.0 source kit. 110 fe2sk227 ccadmin /usr/atria/bin/Perl -v This is perl, version 5.002 with DEBUGGING EMBED Copyright 1987-1996, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5.0 source kit. 111 fe2sk227 ccadmin /usr/atria/bin/Perl -v This is perl, version 4.864 with DEBUGGING EMBED Copyright 1987-1996, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5.0 source kit. Has anybody got any ideas? These are the errors from the script 116 fe2sk227 ccadmin /usr/atria/config/scheduler/tasks/sync_receive Perl 5 required--this is only version 4.864, stopped at /usr/atria/lib/perl5/Getopt/Long.pm line 12. BEGIN failed--compilation aborted at /usr/atria/config/scheduler/tasks/sync_receive.bat line 35. 117 fe2sk227 ccadmin /usr/atria/config/scheduler/tasks/sync_receive Perl 3.67001847483647 required--this is only version 4.864, stopped at /usr/atria/lib/perl5/Getopt/Long.pm line 12. BEGIN failed--compilation aborted at /usr/atria/config/scheduler/tasks/sync_receive.bat line 35. Cheers, Jim Jim Halkyard Configuration Management Engineer NEC Technologies (UK) Ltd Tel: +44 (0) 118 965 4632 www.nectech.co.uk mailto:[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: Getting started in Perl for OSX
James Edward Gray II wrote: On Wednesday, October 1, 2003, at 04:34 PM, McMahon, Chris wrote: But Perl doesn't come with OSX by default. You may or may not have an install CD called Developer Tools or some such, and Perl is on that. At the risk of sounding like a broken record, this still isn't true. Perl has shipped with ALL versions of Mac OS X and has NEVER required the Developer Tools. Apple is using Perl scripts in many OS X software install packages, so they need it to be there. Thanks James, This will help me tremendously. We have a G4, licensed for OSX, that went to the Mac shop for a power supply/switch faiure, and came back with OS 9.1 nuked and paved onto it. I've been too disgusted to deal with it for a couple months, but this information is enough to motivate me to get OSX back onto it. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Redirect perldoc to usb printer
In DOS you can run start /min notepad /P filename I've tested it and it works. This will print a text file even without having a .txt suffix With my cygwin setup notepad /P filename Works but a DOS window flashes for a split second before printing. Not sure where the DOS start command is, but by putting that in the cygwin bash PATH should enable its use in cygwin. -tristram -Original Message- From: Paul Kraus [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 9:12 AM To: [EMAIL PROTECTED] Subject: OT: Redirect perldoc to usb printer Kind of off topic. How can you redirect to a usb printer from the shell in windows xp? Its getting really irritating having to perldoc -f function function.txt Open function.txt in notepad and then print. Thanks, 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]
Perl and cron
Hi and Help, I have a perl script (A) that spawns a unix command and pipes that to a log file. Then at 23:59 I have a perl script (B) that kills script (A). At midnight script (A) is kicked off. My issue is my killing of srcipt (A) is not working. It either is showing under ps, but not doing anything or its still writing to the old log file, along with the new file. Are my perl scripts not correct? Is there an easier way to do this? Thanks up front.. Rob Script (A): #!/bin/perl -w use warnings; use strict; my ( $sec, $min, $hour, $day, $mon, $year ) = localtime; my $snoop = '/usr/sbin/snoop -d ge0 -ta'; my $date = `date +%W`; chop($date); my $dir = /var/weeks/03_week_$date; my $logfile = sprintf '/var/weeks/03_week_%d/%02d%02d%02d%02d%02d.sno', `date +%W`, $year % 100, $mon + 1, $day, $hour, $min; # create 03_week_dir if does not exist unless(-d $dir){ mkdir $dir,0660; } open LOG, '', $logfile or die Cannot open $logfile: $!; # set default output filehandle and autoflush select LOG; $| = 1; print '===' . localtime() . ==\n\n; open SNOOP, $snoop | or die Cannot open pipe from $snoop: $!; while ( SNOOP ) { print; } # # Script(B): #!/bin/perl @snp = `pgrep snp.pl`; pop(@snp); @snoop = `pgrep snoop`; push(@snp,@snoop); chomp(@snp); foreach (@snp) { #print(Killing $_\n); `kill -9 $_`; } Cron: #59 23 * * * /bin/pkill -9 snp.pl;/bin/pkill -9 snoop;/bin/pkill -9 snoop;/bin/pkill -9 snp.pl # test 59 23 * * * /opt/script/killsnp.pl /dev/null 21 # to kill 0 0 * * * /opt/script/snp.pl /dev/null 21 # to start This mornings ps -ef| nobody 5833 5823 2 00:00:00 ? 45:26 /usr/sbin/snoop -d ge0 -ta root 5823 1 0 00:00:00 ?0:07 /bin/perl -w /opt/script/snp.pl nobody 1928 1925 1 13:27:00 ? 58:07 /usr/sbin/snoop -d ge0 -ta root 1925 1 0 13:27:00 ?0:34 /bin/perl -w /opt/script/snp.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: invoking sub/methods shortcut
[EMAIL PROTECTED] wrote: Can I do something like this? from $sth = getVUser($dbh, $u, $d); return $sth-rows(); to return (getVUser($dbh,$u,$d))-rows(); What happened when you tried it? John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: invoking sub/methods shortcut
both of these works: return (getVUser($dbh,$u,$d))-rows(); and return getVUser($dbh,$u,$d)-rows(); -rkl [EMAIL PROTECTED] wrote: Can I do something like this? from $sth = getVUser($dbh, $u, $d); return $sth-rows(); to return (getVUser($dbh,$u,$d))-rows(); What happened when you tried it? John -- use Perl; program fulfillment -- 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: invoking sub/methods shortcut
John W. Krahn [EMAIL PROTECTED] writes: [EMAIL PROTECTED] wrote: Can I do something like this? from $sth = getVUser($dbh, $u, $d); return $sth-rows(); to return (getVUser($dbh,$u,$d))-rows(); I find this more readable return getVUser($dbh,$u,$d)-rows(); Cheers, jas. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: easiest `cat` in perl
Gary Stainburn [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Thursday 02 Oct 2003 10:25 am, Owen wrote: On Wed, 01 Oct 2003 23:14:00 -0700 Bryan Harris [EMAIL PROTECTED] wrote: What I'm interested in is what's the easiest way to print the contents of a file? For example, if I want to output my header file, header.incl, how can I print the contents of that file the easiest (and most generally compatible)? snip / You may wish to change the print line to print $_br\n;if you want a new line on your html for each new line in your file. Owen Hi Owen, One thing you forgot was to close the file. Also, don't forget that you can do it with less typing: $file = /location/of/header.incl; open (FH, $file) or die Cannot open file $file $!; print while(FH); close(FH); -- or simply: print FH; print takes a list of arguments: [EMAIL PROTECTED] trwww]$ perl use warnings; use strict; print DATA; __DATA__ one two three Ctrl-D one two three Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Redirect perldoc to usb printer
To print from cygwin avoiding the DOS window try: cmd /c start /min notepad /P filename This will print to the default printer which can be a USB printer. filename does not need a .txt suffix. -tristram -Original Message- From: TN [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 9:45 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: Redirect perldoc to usb printer In DOS you can run start /min notepad /P filename I've tested it and it works. This will print a text file even without having a .txt suffix With my cygwin setup notepad /P filename Works but a DOS window flashes for a split second before printing. Not sure where the DOS start command is, but by putting that in the cygwin bash PATH should enable its use in cygwin. -tristram -Original Message- From: Paul Kraus [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 9:12 AM To: [EMAIL PROTECTED] Subject: OT: Redirect perldoc to usb printer Kind of off topic. How can you redirect to a usb printer from the shell in windows xp? Its getting really irritating having to perldoc -f function function.txt Open function.txt in notepad and then print. Thanks, 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] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: uploadfiles
Hi, Howdy I'm trying to write a CGI script to upload a file from a #!/usr/bin/perl -w use strict; use CGI qw/:standard/ print Content-type: text/html\n\n; print $query-filefield('uploaded_file'); $filename = $query-param('uploaded_file'); $fh = $query-upload('uploaded_file'); I believe you have to do upload() before you print any headers. while ($fh) { print; } I am reading the CGI.pm from Lincoln Stein's webpage. But, -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Perl and cron
Hi, I'm confused by the listing of your crontab. Anyway, script A seems to be working ok. The problem seems to be with script B. But is this true? The snoop manpage (for Solaris 8, see http://docs.sun.com/db/doc/806-0625/6j9vfim06?q=snoopa=view) says that snoop requires an interactive interface. I think that means that it's supposed to be run from the command line and not from a batch script. Some other solaris commands such as truss are like that and it's hard to run them from batch scripts properly and doing that should be avoided. So maybe script A is not working exactly as expected, although the ps output shows that snoop was started. I strongly suggest switching from snoop to tcpdump which is meant to be run from batch scripts. You can get tcpdump-3.7.2 in solaris pkg format from www.sunfreeware.com. In any case, after script A is working to your satisfaction, I suggest that you then get script B working from the command line. Then get it working from cron. It will need to run as root because snoop|tcpdump must run as root. You can test how it works from cron by scheduling it to run just a couple of minutes in the future. After that works, then set it up to run at midnight. -tristan PS: For analyzing tcpdump traces, ethereal is great and can also be obtained in pkg format from www.sunfreeware.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: easiest `cat` in perl
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Todd Wade) writes: Gary Stainburn [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Thursday 02 Oct 2003 10:25 am, Owen wrote: On Wed, 01 Oct 2003 23:14:00 -0700 Bryan Harris [EMAIL PROTECTED] wrote: What I'm interested in is what's the easiest way to print the contents of a file? For example, if I want to output my header file, header.incl, how can I print the contents of that file the easiest (and most generally compatible)? snip / One thing you forgot was to close the file. Also, don't forget that you can do it with less typing: $file = /location/of/header.incl; open (FH, $file) or die Cannot open file $file $!; print while(FH); close(FH); -- or simply: print FH; Reasonable for short files, wastes memory for big ones. This file opening looks like too much work. I prefer: { local @ARGV = /location/of/header.incl; print while ; } -- Peter Scott http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Get email adress from AD or exchange?
Has anyone done this in Perl, is there an module that can help me? I am aware of that I can use the Win32::Ole, but what I really want is an more easier way of asking: use Mail::Internet; my $mail = Mail::Internet-new(\*STDIN); # see docs on how to use an array instead of a file handle my $headers = $mail-head-header_hashref; $headers-{'From'}-[0] $headers-{'Reply-To'}-[0] Each item in %{$headers} is an aaray reference to values for that header. Just put the header you want in there an voila it's all yours! For $user Could be in To, Cc, Bcc ( IE not intheir at all), Envelope-To, etc... Return mailadress Could be From, Reply-To, Etc... This can be done in VB quite easy, but I want to try and stay perlish here. Any one have an clue? Does anyone really have a clue? :) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Perl Beginners Portals
R. Joseph Newton [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Todd Wade wrote: I'm willing to pester the site owners to let you do the site. But it will probably take more than just you and I. The lack of responses to your OP might indicate the amount of help the rest of the group is willing to contribute. I think you may be misinterpreting the silence. Although the OP makes a very positive offer of his efforts, he does not communicte it very well. Unfortunately, he starts off with a litany of what is wrong with... which tends to turn people away before they get to the proposal itself. I was. I got a couple emails referring me to the archive of the OP's thread in perl.advocacy. There were many suggestions made by him to fix things that were not broken. If I had read that thread, I wouldve ignored the post also. As I was replying to it, I was thinking of something simple like a faq of faqs. Now I understand he what is proposing is just too grandiose and unimplementable for the resources we have available. Im _glad_ nobody else responded so it didn't start over again. FWIW, the core group of helpers posting here is generally hroic in its patience and energy, with an emphasis on the former. While I cetainly agree that new members should read the FAQ and at least skim the archives before asking a repetitive question, that is somewhat to be expected on a list targeted toward beginners. On this mailing list, we expect a certain amount of repitition. Some of us may remind posters that they should read the archives and other traffic on the list, but that is usually not the top priority. Oh I agree. I dont mind the repetitive posting. As you say, this list is for perl curious people to ask anything they want ( about perl ) without being criticized for it. Although I have noticed a small few taking advantage of that fact. Just a small few, though. Not near enough to affect me. snip / So what exactly is learn.perl.org, anyway? I am subscribed to, and received this message through, the beginners-perl mailing list, [EMAIL PROTECTED]. I use http://www.perl.org/ for my perl portal, and it has many virtual hosts there. For instance, check out http://datetime.perl.org/ or http://use.perl.org/. Along with the mailing lists from that domain, there is also an nntp server there. I am replying to your mailing list submission using outlook newsgroups connected to perl.beginners on nntp.perl.org. There's software running that posts all your messages to the news server, and also emails all my posts to the list subscribers. Pretty slick, really. Its increased the amount of questions I respond to, because I hate mailing lists. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Redirect perldoc to usb printer
Not running cygwin. This works but still requires I redirect to a text file first. I want to be able to pipe. Perldoc -f localtime | command Then have it just dump to the usb printer. -Original Message- From: TN [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 10:28 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: Redirect perldoc to usb printer To print from cygwin avoiding the DOS window try: cmd /c start /min notepad /P filename This will print to the default printer which can be a USB printer. filename does not need a .txt suffix. -tristram -Original Message- From: TN [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 9:45 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: Redirect perldoc to usb printer In DOS you can run start /min notepad /P filename I've tested it and it works. This will print a text file even without having a .txt suffix With my cygwin setup notepad /P filename Works but a DOS window flashes for a split second before printing. Not sure where the DOS start command is, but by putting that in the cygwin bash PATH should enable its use in cygwin. -tristram -Original Message- From: Paul Kraus [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 9:12 AM To: [EMAIL PROTECTED] Subject: OT: Redirect perldoc to usb printer Kind of off topic. How can you redirect to a usb printer from the shell in windows xp? Its getting really irritating having to perldoc -f function function.txt Open function.txt in notepad and then print. Thanks, 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] -- 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: easiest `cat` in perl
# Set $header_file to the PATH to header.incl my $header_file = 'header.incl'; # Call load_file() which takes a filename as an argument and # returns the contents of that file. Then print what load_file() # returns. print load_file($header_file); sub load_file { my($file,$html) = shift; $html = ''; open(FILE, $file) or die Cannot open $file for reading: $! while(FILE) { $html .= $_; } return $html; } # Hope that helps. On Wed, 2003-10-01 at 23:14, Bryan Harris wrote: I'm just barely starting into the world of CGI. I think this is going to be the best thing I ever did. What I think I want to do is have a library of HTML snippets (like a generic header and footer), and then use perl to output them in order along with any custom content. What I'm interested in is what's the easiest way to print the contents of a file? For example, if I want to output my header file, header.incl, how can I print the contents of that file the easiest (and most generally compatible)? I've tended to shy away from backticks because I kind-of feel like they're not real perl, and somehow less portable. Should I feel that way? TIA. - Bryan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Redirect perldoc to usb printer
Paul Kraus wrote: Not running cygwin. This works but still requires I redirect to a text file first. I want to be able to pipe. Perldoc -f localtime | command Then have it just dump to the usb printer. This should work (assuming ActiveState) C:\ perl c:\perl\bin\perldoc.bat -f localtime | command -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: easiest `cat` in perl
Bryan == Bryan Harris [EMAIL PROTECTED] writes: Bryan What I'm interested in is what's the easiest way to print the Bryan contents of a file? For example, if I want to output my header Bryan file, header.incl, how can I print the contents of that file Bryan the easiest (and most generally compatible)? Easy, and efficient: use File::Copy; copy header.incl, \*STDOUT; Accept no substitutes. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: easiest `cat` in perl
Todd Wade [EMAIL PROTECTED] wrote: Gary Stainburn [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [...] One thing you forgot was to close the file. Also, don't forget that you can do it with less typing: Closing files is optional in Perl ;-) Filehandles will either be closed when the program terminates when the filehandle is opened the next time. $file = /location/of/header.incl; open (FH, $file) or die Cannot open file $file $!; If you wanted to pipe other stuff than just plain text, then binmode(FH); would be a good idea for portability. print while(FH); This is bad because it first pulls in the file to build the list. close(FH); print FH; print takes a list of arguments: Just to be nit-picking (and to repeat what I learned from a M.J. Dominus talk at YAPC::EU this year ;-)) print'ing a list is slower than printing a single (large) scalar. In this particular case it might be worthwhile to use slurping: We create a scope in which the input record separator $/ is temporarily set to undef. Reading from IN then returns just a single record. The payoff - printing is nearly twice as fast. #!/usr/bin/perl -w use strict; use Benchmark; my $file = out.txt; my $count = 2; open( OUT, $file) or die Can't open '$file':$!; print print using a scalar:\n; timethis( $count, 'open(IN, $0); { local $/; undef $/; print OUT IN; }; close( IN)' ); close( OUT ); unlink $file; open( OUT, $file) or die Can't open '$file':$!; print print using a list:\n; timethis( $count, 'open(IN, $0); print OUT IN; close( IN)' ); close( OUT ); unlink $file; __END__ print using a scalar: timethis 2: 6 wallclock secs ( 2.85 usr + 2.44 sys = 5.30 CPU) @ 3775.72/s (n=2) print using a list: timethis 2: 11 wallclock secs ( 7.88 usr + 2.67 sys = 10.56 CPU) @ 1894.84/s (n=2) Cheers, Thomas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: easiest `cat` in perl
Joshua Colson [mailto:[EMAIL PROTECTED] suggested: sub load_file { my($file,$html) = shift; $html = ''; open(FILE, $file) or die Cannot open $file for reading: $! while(FILE) { $html .= $_; } return $html; } Instead of while(FILE) { $html .= $_; }, you could use $html = join(, FILE). HTH, Thomas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: easiest `cat` in perl
On Thu, Oct 02, 2003 at 05:17:34PM +0200, Thomas B?tzler wrote: Todd Wade [EMAIL PROTECTED] wrote: Gary Stainburn [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] print while(FH); This is bad because it first pulls in the file to build the list. It doesn't. The while modifier is a looping construct. Except for the lack of a block, these are exactly the same. print while FH; while (FH) { print } They both read and print one-line-at-a-time. print FH; print takes a list of arguments: Just to be nit-picking (and to repeat what I learned from a M.J. Dominus talk at YAPC::EU this year ;-)) print'ing a list is slower than printing a single (large) scalar. In this particular case it might be worthwhile to use slurping: But this does load the whole file in memory, and that really is sloppy. Sometimes you know the file is going to be small, and so the sloppiness is acceptable, but the general rule is: don't slurp files unless you have to. It doesn't scale. -- Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Perl Beginners Portals
On Thu, 2 Oct 2003, Todd Wade wrote: R. Joseph Newton [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Todd Wade wrote: I'm willing to pester the site owners to let you do the site. But it will probably take more than just you and I. The lack of responses to your OP might indicate the amount of help the rest of the group is willing to contribute. I think you may be misinterpreting the silence. Although the OP makes a very positive offer of his efforts, he does not communicte it very well. Unfortunately, he starts off with a litany of what is wrong with... which tends to turn people away before they get to the proposal itself. I was. I got a couple emails referring me to the archive of the OP's thread in perl.advocacy. There were many suggestions made by him to fix things that were not broken. If I had read that thread, I wouldve ignored the post also. As I was replying to it, I was thinking of something simple like a faq of faqs. Now I understand he what is proposing is just too grandiose and unimplementable for the resources we have available. Im _glad_ nobody else responded so it didn't start over again. What I'm suggesting is not too grandoise or unimplementable. In any case, what I suggested regarding the Perl world in general, has little to do with learn.perl.org vs. perl-begin.berlios.de. I find learn.perl.org inadequate as the main community portal for people who are trying to learn Perl. I have constructed perl-begin.berlios.de which is much better. I am willing to perform some work on learn.perl.org to make it better. However, I cannot because I don't have access to its source code, and its maintainers have not been responsive lately. The other suggestions in regard to the Perl world in general are not directly related to my recent post to this list. And if you think my suggestions are grandoise, you have to take into account that I prepared perl-begin all by myself, with some input by other people (which I still had to input into the site). And I am a university student and have many other endeavours as well. [1] FWIW, the core group of helpers posting here is generally hroic in its patience and energy, with an emphasis on the former. While I cetainly agree that new members should read the FAQ and at least skim the archives before asking a repetitive question, that is somewhat to be expected on a list targeted toward beginners. On this mailing list, we expect a certain amount of repitition. Some of us may remind posters that they should read the archives and other traffic on the list, but that is usually not the top priority. Oh I agree. I dont mind the repetitive posting. As you say, this list is for perl curious people to ask anything they want ( about perl ) without being criticized for it. Although I have noticed a small few taking advantage of that fact. Just a small few, though. Not near enough to affect me. I agree here too. One cannot expect beginners to read the FAQ or skim through the archives, or search Google. They may not be aware of netiquette as more experienced people are. I think having one global list for all newbie questions is not such a good idea, because the volume is quite overwhelming. However, in any such list, one should be prepared to answer as many of these questions as possible, times and again. That's also a reason in support of having several separate mailing lists: you get to hear the same old question less. Regards, Shlomi Fish [1] - and please - how hard it is to designate #perl as the channel for newbie discussions and to move the advanced discussions and talk to #perlcafe? Not hard at all. -- Shlomi Fish[EMAIL PROTECTED] Home Page: http://t2.technion.ac.il/~shlomif/ An apple a day will keep a doctor away. Two apples a day will keep two doctors away. Falk Fish -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: problem with date routine
-Original Message- From: Charles K. Clarkson [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 4:42 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: problem with date routine perlwannabe [EMAIL PROTECTED] wrote: : : I have a relatively simple script that needs to get : two separate dates, today's date, and yesterday's : date. The dates are in mmddyy format. : Here is the script: : : : ## BEGIN SCRIPT : my ($mday, $mon, $year) = (localtime)[3..5]; : my $datetoday = sprintf (%02d%02d%02d, ++$mon, $mday, $year-100); : : print (the value of datetoday is $datetoday\n); : : : my ($yesterdaymday, $yesterdaymon, $yesterdayyear) = : (localtime)[3..5]; : my $dateyesterday = sprintf (%02d%02d%02d, ++$yesterdaymon, : $yesterdaymday-1, $yesterdayyear-100); : print (the value of datetoday is $dateyesterday\n); : : ### END SCRIPT # A couple of others have pointed out the errors above and fixes. I'd like to introduce you to the POSIX function 'strftime' and the perl variable '$^T'. One problem above involves testing very close to midnight. It is unlikely, but possible for a routine built on two calls to localtime() to return the same date for today and yesterday. The first call would need to be before midnight and the second call would have to be after midnight. Admittedly, this would be very uncommon, but certainly possible. Actually, more common when time changes. Best to create a new time using the current day, month, and year, with the hour set to 12, then do the +-86400 thing, then extract the new day, month, and year. Check out Time::Local to create the time variable. -Mark -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: owner's name of a file
Josimar Nunes de Oliveira wrote: Hi Michel, Thanks for your help, but the code will run on windows2000server and the mapped drive points to a folder on novell server. The getpwuid is unimplemented in windows2000server perl. I would like to take the file´s ownership related to novell server NDS users. Sound like you need to go to novell.com, and start looking about there for command-line utilities or APIs. The information is readily available from the GUI of Windows, of course, by right-clicking on the file name, and choosing /^Trustee .*\.\.\./. I use this as a shortcut when I look for user names to set up as users on individual Windows workstations I'm not sure that files on Novell servers have owners per-se. Novell, like NT, uses access control lists [ACL] to manage permissions, rather than the OGW paradigm of 'nix. To the best of my knowledge, there is not much in Perl that is Netware-specific, Since search.cpan.org seems to be broken right now [it reponds to ping, but does not seem to deliver any web output] I can't check this out at the moment. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Group list elements
GTz Verdieck wrote: Hi, I'm looking for a solution for the following problem: This is the list I have : $kommalist =20,21,22,23,24,25,27,28,31,32,33; And I want to convert it into : $newlist =20..25,27,28,31..33; So, I only want to combine the elements if there are more than two like 20,21,23 assume your list is in order as you specify, try: #!/usr/bin/perl -w use strict; my ($s,$n) = '0,1,2,3,4,5,8,9,20,21,22,23,24,25,27,28,31,32,33',''; while($s =~ s/\d+//){ my $o = my $t = $; $t = $1 while($s =~ s/,(@{[$t+1]})(?=,|\z)//); $n .= $t - $o 1 ? $o..$t, : $t == $o ? $t, : $o,$t,; } substr($n,-1)=''; print $n,\n; __END__ prints: 0..5,8,9,20..25,27,28,31..33 david -- $_=q,015001450154015401570040016701570162015401440041,,*,=*|=*_,split+local$; map{~$_1{$,=1,[EMAIL PROTECTED]||3])=~}}0..s~.~~g-1;*_=*#, goto=print+eval -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: owner's name of a file
Suggest also that you talk with your network and novell admins to find out how authentication is mapped from the novell server to the win2k server. Based on my experience with nfs and samba that could result in the loss of visibility of novell file ownership - for example on an nfs share all file ownership may be mapped to nobody and although your could still see usernames in directory listings they would be mapped by their UIDs through the local passwd service as configured in /etc/nsswitch.conf on Unix/Linux systems. -tristram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
explain regex statement?
Howdy: I have a statement and I'm trying to see if I understand what it is really is doing (not my code). The code does this: [snip] result ~ '^ *-?[0-9]+[.]?[0-9]* *\$' [/snip] I break out the meaning as this: [snip example] ^ = beginning of line plus a white space *- = everything up to, and including, to the ' - ' ?[0-9] = 1 or 0 times of a number +[.] = 1 or more times any character ?[0-9]* *\$ = 1 or more times any number plus any other character and a white space and then any MORE characters to the end of the line [/snip example] How far off am I? Thanks! -X
Excel to HTML
I am using Perl's Spreadsheet Module to write a nicely formatted Report. Now the customer want to convert it into HTML format, keeping the same formatting. I was wondering if there is a module or something which will convert the original Excel Spreadsheet and convert into HTML. I know if you open spreadsheet you can save it as *.html and it takes care of conversion. But I intend to do it on Unix side on an automatic basis. Any ideas/thoughts TIA Shelly - Do you Yahoo!? The New Yahoo! Shopping - with improved product search
Testing Uninitialized Vars
I wan to write a sub return true or false if the var was initialized. Can someone correct this sub or is it good? ... if(isNULL($x) { print it is null\n); else { print it is NOT null\n); ... sub isNULL { return $_[0] =~ // } thanks, -rkl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Testing Uninitialized Vars
On Thursday, October 2, 2003, at 04:25 PM, [EMAIL PROTECTED] wrote: I wan to write a sub return true or false if the var was initialized. We can do that, but I really don't think we need a sub for it, since there is a built-in. Can someone correct this sub or is it good? No, I wouldn't call it good. ... if(isNULL($x) { print it is null\n); if ( ! defined $x ) { ... } else { print it is NOT null\n); ... sub isNULL { return $_[0] =~ // This Regex doesn't do what you think. It reuses the last successful match. You don't want a Regex here anyway, you meant: $_[0] eq ''; Since I could set a variable to the empty string though, that doesn't really answer your question. Hope that helps. James } thanks, -rkl -- 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]
using 3 arrays
Thanks for helping me on my previous question; I was able to get it afterwards. I have another question. First, I have 3 arrays and wanted to print out the items of corresponding places in a sequential order. I have tried using foreach function, like below foreach $a (@1){ foreach$b (@2){ foreach $c (@3){ $tog=$a.\t.$b.\t.$c\n; print $tog; } } } But, it gets stuck in the first round with 1st items of @1 and @2 with all the items of @3; then, it goes next with 2nd items of @1 and @2 with all the items of @3 and on and on until the end. I thought that I could use a push or pop function to not print all the items of @3 every time. But, I couldn't. How can I get the loop to print one items of @3 at each time and get out of the third inner loop after one group of items? Following is what I am trying to do: @1@2@3 item1aitem1bitem1c item2aitem2bitem2c . . . . . . . . . They all have an equal number of items. I think there is a function I could use. Can you tell me what it is called and I can look up the information. Thanks for your help. A - Do you Yahoo!? The New Yahoo! Shopping - with improved product search
RE: explain regex statement?
Close, not quite. The quantifier (i.e. ?,+,*) appear AFTER the atom (i.e. char or special symbol). The syntax is also off a bit. It should be =~ and /../ (not single ticks). $result =~ /^ *-?[0-9]+[.]?[0-9]* *\$/; ^ = beginning of line (also called an anchor) * = zero or more spaces (not whitespace). I suggest using \s* instead, which is zero or more whitespace (includes spaces, tabs, returns, and newlines in some situations) -? = Matches an optional - char (0 or 1 times). [0-9]+ = 1 or more numbers (use \d+ instead) [.]? = optional char (any char). Brackets not needed, use .? instead. [0-9]* = 0 or more digits, again use \d* instead. * = 0 or more spaces, again use \s* instead. \$ = matches an actual $ char. So the new regex looks like this... $result =~ /^\s*-?\d+.?\d*\s*\$/; Or using the x modifier (a good thing to do) to space it out, and add comments... $result =~ / ^# start of string \s* # 0+ whitespace -? # 0-1 - \d+ # 1+ digits .? # 0-1 any char \d* # 0+ digits \s* # 0+ whitespace \$ # $ char /x; The regex is starting to look like it is supposed to match numbers like 21.25$ and -50.00. ...In which case the .? is supposed to be a real period, not an any char. If it should be a real period (or decimal point), use \.? instead. Rob -Original Message- From: Johnson, Shaunn [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 5:20 PM To: [EMAIL PROTECTED] Subject: explain regex statement? Howdy: I have a statement and I'm trying to see if I understand what it is really is doing (not my code). The code does this: [snip] result ~ '^ *-?[0-9]+[.]?[0-9]* *\$' [/snip] I break out the meaning as this: [snip example] ^ = beginning of line plus a white space *- = everything up to, and including, to the ' - ' ?[0-9] = 1 or 0 times of a number +[.] = 1 or more times any character ?[0-9]* *\$ = 1 or more times any number plus any other character and a white space and then any MORE characters to the end of the line [/snip example] How far off am I? Thanks! -X -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: explicit vs implicit syntax
Thanks I understand what you're saying. If I could ask, which one of these would you use? showargs; #NOT this is the tricky showargs(); showargs; showargs(); thanks, -rkl [EMAIL PROTECTED] asked: Here's an excerpt about the from orielly and what the heck does it means: ...If a subroutine is called using the form, the argument list is optional. if ommitted, no @_ array is setup for the routine; the @_ array at the time of the call is visible to subroutine instead. If in doubt, run a test ;-) #!/usr/bin/perl -w use strict; sub showargs { print arguments are: . join(', ', @_) . \n; } sub test { print Arguments for test() are: . join(', ', @_) . \n; print Calling showargs - ; showargs; print Calling showargs() - ; showargs(); print Calling showargs - ; showargs; print Calling showargs() - ; showargs(); } test qw(foo baz bar); __END__ So, is there a better or worse? both ways works for me. I just started going back and putting the onto the sub ;) I don't like it the but I thought that you need it. See for yourself - there's only one use for the ampersand, and it's obscure. My advice would be to avoid using it even in the one situation where it would make sense - when passing @_ as an argument to your function. Sure, it is idiomatic Perl at its best, but it also makes a program harder to read and understand. In other words - save it for Perl Golf ;-) HTH, Thomas PS: Perl Golf - writing code with as little (key-)strokes as possible. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using 3 arrays
On Thursday, October 2, 2003, at 04:31 PM, A L wrote: Thanks for helping me on my previous question; I was able to get it afterwards. I have another question. First, I have 3 arrays and wanted to print out the items of corresponding places in a sequential order. I have tried using foreach function, like below foreach $a (@1){ foreach$b (@2){ foreach $c (@3){ $tog=$a.\t.$b.\t.$c\n; print $tog; } } } for (my $i = 0; $i @1: $i++) { print $1[$i] $2[$i] $3[$i]\n; } # or .. print $1[$_] $2[$_] $3[$_]\n foreach 0..$#1; Hope that helps. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: using 3 arrays
A L wrote: Thanks for helping me on my previous question; I was able to get it afterwards. I have another question. First, I have 3 arrays and wanted to print out the items of corresponding places in a sequential order. I have tried using foreach function, like below foreach $a (@1){ foreach$b (@2){ foreach $c (@3){ $tog=$a.\t.$b.\t.$c\n; print $tog; } The way that it is handled would be the most inner loop would keep printing over and over while looping through 2 and then back to 1 and down. The easiest way would be to find the largest array (ie scalar(@a), scalar(@b)) Then use that number for the highest loop. Create an id and loop through. If you know the arrays are ALWAYS the same size fine, but if different then would either need a check or set an undefined item to say a space. for(my $MyId=0;$MyId $MyLaregstArray : $MyId++ ) { printf %-26s -26s %-26s\n, $a[$MyId}, $b[$MyId}, $c[$MyId]; } Should give you a start. Wags ;) } } But, it gets stuck in the first round with 1st items of @1 and @2 with all the items of @3; then, it goes next with 2nd items of @1 and @2 with all the items of @3 and on and on until the end. I thought that I could use a push or pop function to not print all the items of @3 every time. But, I couldn't. How can I get the loop to print one items of @3 at each time and get out of the third inner loop after one group of items? Following is what I am trying to do: @1@2@3 item1aitem1bitem1c item2aitem2b item2c . . . . . . . . . They all have an equal number of items. I think there is a function I could use. Can you tell me what it is called and I can look up the information. Thanks for your help. A - Do you Yahoo!? The New Yahoo! Shopping - with improved product search ** This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using 3 arrays
--On Thursday, October 2, 2003 14:31 -0700 A L [EMAIL PROTECTED] wrote: @1@2@3 item1aitem1bitem1c item2aitem2bitem2c . . . . . . . . . They all have an equal number of items. I think there is a function I could use. Can you tell me what it is called and I can look up the information. Thanks for your help. Ok, if you can guarantee that each array has the same number of items, here is what you want: (There are more Perlish ways to do this, but this way is clear on what is happening.) for ( $i = 0; $i @1; $i++; ) { print $1[$i]\t$2[$i]\t$3[$i]\n; } What we are doing here is stepping through the arrays simultaneously, starting at the bottom. We assume all the arrays are exactly as long as @1. (Um, you do have better names in the real code, right?) $i is the index of our current place in all the arrays, and will cycle from 0 to the length of @1 minus 1. You didn't need all the .'s and 's, so I left them out. ;-) Daniel T. Staal --- This email copyright the author. Unless otherwise noted, you are expressly allowed to retransmit, quote, or otherwise use the contents for non-commercial purposes. This copyright will expire 5 years after the author's death, or in 30 years, whichever is longer, unless such a period is in excess of local copyright law. --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: explicit vs implicit syntax
My preference... showargs(); Ick. I use this one when it is required (references and overriding prototypes), otherwise it isn't what I mean. If I mean to just execute the method, then I don't use it. showargs; Yuk. It saves a few keystrokes, but I tend to avoid it. showargs(); I like this one. It's the usual way to program. In most languages the parens are required, so it's just easier to stick with one habit. Rob -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 5:43 PM To: Thomas Bätzler Cc: '[EMAIL PROTECTED]'; Tim Johnson; [EMAIL PROTECTED] Subject: RE: explicit vs implicit syntax Thanks I understand what you're saying. If I could ask, which one of these would you use? showargs; #NOT this is the tricky showargs(); showargs; showargs(); thanks, -rkl [EMAIL PROTECTED] asked: Here's an excerpt about the from orielly and what the heck does it means: ...If a subroutine is called using the form, the argument list is optional. if ommitted, no @_ array is setup for the routine; the @_ array at the time of the call is visible to subroutine instead. If in doubt, run a test ;-) #!/usr/bin/perl -w use strict; sub showargs { print arguments are: . join(', ', @_) . \n; } sub test { print Arguments for test() are: . join(', ', @_) . \n; print Calling showargs - ; showargs; print Calling showargs() - ; showargs(); print Calling showargs - ; showargs; print Calling showargs() - ; showargs(); } test qw(foo baz bar); __END__ So, is there a better or worse? both ways works for me. I just started going back and putting the onto the sub ;) I don't like it the but I thought that you need it. See for yourself - there's only one use for the ampersand, and it's obscure. My advice would be to avoid using it even in the one situation where it would make sense - when passing @_ as an argument to your function. Sure, it is idiomatic Perl at its best, but it also makes a program harder to read and understand. In other words - save it for Perl Golf ;-) HTH, Thomas PS: Perl Golf - writing code with as little (key-)strokes as possible. -- 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]
How do I RegExp Match a ? without using \X{3F}?
Is there a way to match a question mark using a regular expression without looking for a \X{3F} ? Thanks in advance, -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: problem with date routine THANKS!!
Thank you for all of the responses to my date/time problem. I have rewritten the routine with the information and feel confident it is far, far better than what I had. Thanks... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How do I RegExp Match a ? without using \X{3F}?
--On Thursday, October 2, 2003 17:54 -0400 Dan Anderson [EMAIL PROTECTED] wrote: Is there a way to match a question mark using a regular expression without looking for a \X{3F} ? Just escape it: \? Daniel T. Staal --- This email copyright the author. Unless otherwise noted, you are expressly allowed to retransmit, quote, or otherwise use the contents for non-commercial purposes. This copyright will expire 5 years after the author's death, or in 30 years, whichever is longer, unless such a period is in excess of local copyright law. --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How do I RegExp Match a ? without using \X{3F}?
On Thursday, October 2, 2003, at 04:54 PM, Dan Anderson wrote: Is there a way to match a question mark using a regular expression without looking for a \X{3F} ? ~ perl -e 'print Matched a ?\n if A question? =~ /\?/' Matched a ? James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Testing Uninitialized Vars
if ( ! defined $x ) I read up on defined and undefined. But I'm looking for a test that will this return true or false to a var condition: ... sub isNULL { return undefined $_[0] $_[0] eq '' $_[0] eq ; } # my goal is all three return the same as # my proposed sub isNULL() my $x; # undefined $x=; # zero length $x=''; # zero length ... Would the new sub do or is there a better? -rkl Can someone correct this sub or is it good? No, I wouldn't call it good. I didn't mean that this is good code but good enough to work. Apparently it didn't! thanks, -rkl On Thursday, October 2, 2003, at 04:25 PM, [EMAIL PROTECTED] wrote: I wan to write a sub return true or false if the var was initialized. We can do that, but I really don't think we need a sub for it, since there is a built-in. Can someone correct this sub or is it good? No, I wouldn't call it good. ... if(isNULL($x) { print it is null\n); if ( ! defined $x ) { ... } else { print it is NOT null\n); ... sub isNULL { return $_[0] =~ // This Regex doesn't do what you think. It reuses the last successful match. You don't want a Regex here anyway, you meant: $_[0] eq ''; Since I could set a variable to the empty string though, that doesn't really answer your question. Hope that helps. James } thanks, -rkl -- 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: explicit vs implicit syntax
I agree it looks like the best standardized candidate for use. But Orielly says showargs() is slower than showargs when not passing arguments. It's just a minor point but its something I read. In any case, I'm used to the showarg() style. thanks, -rkl showargs(); I like this one. It's the usual way to program. In most languages the parens are required, so it's just easier to stick with one habit. My preference... showargs(); Ick. I use this one when it is required (references and overriding prototypes), otherwise it isn't what I mean. If I mean to just execute the method, then I don't use it. showargs; Yuk. It saves a few keystrokes, but I tend to avoid it. showargs(); I like this one. It's the usual way to program. In most languages the parens are required, so it's just easier to stick with one habit. Rob -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 5:43 PM To: Thomas Bätzler Cc: '[EMAIL PROTECTED]'; Tim Johnson; [EMAIL PROTECTED] Subject: RE: explicit vs implicit syntax Thanks I understand what you're saying. If I could ask, which one of these would you use? showargs; #NOT this is the tricky showargs(); showargs; showargs(); thanks, -rkl [EMAIL PROTECTED] asked: Here's an excerpt about the from orielly and what the heck does it means: ...If a subroutine is called using the form, the argument list is optional. if ommitted, no @_ array is setup for the routine; the @_ array at the time of the call is visible to subroutine instead. If in doubt, run a test ;-) #!/usr/bin/perl -w use strict; sub showargs { print arguments are: . join(', ', @_) . \n; } sub test { print Arguments for test() are: . join(', ', @_) . \n; print Calling showargs - ; showargs; print Calling showargs() - ; showargs(); print Calling showargs - ; showargs; print Calling showargs() - ; showargs(); } test qw(foo baz bar); __END__ So, is there a better or worse? both ways works for me. I just started going back and putting the onto the sub ;) I don't like it the but I thought that you need it. See for yourself - there's only one use for the ampersand, and it's obscure. My advice would be to avoid using it even in the one situation where it would make sense - when passing @_ as an argument to your function. Sure, it is idiomatic Perl at its best, but it also makes a program harder to read and understand. In other words - save it for Perl Golf ;-) HTH, Thomas PS: Perl Golf - writing code with as little (key-)strokes as possible. -- 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: explicit vs implicit syntax
But Orielly says showargs() is slower than showargs That's a good point, and something I didn't know. ...I'm not sure if it will make me change my ways though. Do you know where you read that? I'm not sure why it would be slower, I would think that this would be optimized when the code is compiled to be the same speed. Rob -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 6:15 PM To: Hanson, Rob Cc: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: explicit vs implicit syntax I agree it looks like the best standardized candidate for use. But Orielly says showargs() is slower than showargs when not passing arguments. It's just a minor point but its something I read. In any case, I'm used to the showarg() style. thanks, -rkl showargs(); I like this one. It's the usual way to program. In most languages the parens are required, so it's just easier to stick with one habit. My preference... showargs(); Ick. I use this one when it is required (references and overriding prototypes), otherwise it isn't what I mean. If I mean to just execute the method, then I don't use it. showargs; Yuk. It saves a few keystrokes, but I tend to avoid it. showargs(); I like this one. It's the usual way to program. In most languages the parens are required, so it's just easier to stick with one habit. Rob -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 5:43 PM To: Thomas Bätzler Cc: '[EMAIL PROTECTED]'; Tim Johnson; [EMAIL PROTECTED] Subject: RE: explicit vs implicit syntax Thanks I understand what you're saying. If I could ask, which one of these would you use? showargs; #NOT this is the tricky showargs(); showargs; showargs(); thanks, -rkl [EMAIL PROTECTED] asked: Here's an excerpt about the from orielly and what the heck does it means: ...If a subroutine is called using the form, the argument list is optional. if ommitted, no @_ array is setup for the routine; the @_ array at the time of the call is visible to subroutine instead. If in doubt, run a test ;-) #!/usr/bin/perl -w use strict; sub showargs { print arguments are: . join(', ', @_) . \n; } sub test { print Arguments for test() are: . join(', ', @_) . \n; print Calling showargs - ; showargs; print Calling showargs() - ; showargs(); print Calling showargs - ; showargs; print Calling showargs() - ; showargs(); } test qw(foo baz bar); __END__ So, is there a better or worse? both ways works for me. I just started going back and putting the onto the sub ;) I don't like it the but I thought that you need it. See for yourself - there's only one use for the ampersand, and it's obscure. My advice would be to avoid using it even in the one situation where it would make sense - when passing @_ as an argument to your function. Sure, it is idiomatic Perl at its best, but it also makes a program harder to read and understand. In other words - save it for Perl Golf ;-) HTH, Thomas PS: Perl Golf - writing code with as little (key-)strokes as possible. -- 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: Why is unlinking a directory bad or worse then rmdir
Using unlink may do what you want...and more in terms of unexpected side effects later on that could have dire consequences. For that reason on most Unix systems the use of unlink (and unlink()) requires root access and the use of rmdir (and rmdir()) is strongly encouraged because it permits only the unlinking of empty directories. One of the dangers of unlink used on directories is that there may be running processes that have open files in an unlinked directory. Normally the processes will keep these files open and that might|should block the unlink call -- but the behavior is not specified or standardized. Unlink can be quite useful for removing certain files (because it has no command line options, unlink can remove files beginning with -). But unlinking some directories that are not empty, even trivial directories in the root filesystem for example, could cause a system crash, while doing this in any filesystem will require doing a clean-up file system check and repair (fsck) and could confuse troubleshooting another problem such as disk errors. -tristram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Testing Uninitialized Vars
On Thursday, October 2, 2003, at 05:09 PM, [EMAIL PROTECTED] wrote: if ( ! defined $x ) I read up on defined and undefined. But I'm looking for a test that will this return true or false to a var condition: perldoc -f defined perldoc -f undef The second is a little different than what you think though. sub isNULL { if ( ! defined($_[0]) || $_[0] eq '') { return 1; } else { return; } } # my goal is all three return the same as # my proposed sub isNULL() my $x; # undefined $x=; # zero length $x=''; # zero length That last two are identical. If you don't mind considering 0s NULL too, you can do even better: do_something() if $x; # won't happen on undef, '' or 0 values for $x Would the new sub do or is there a better? A sub is better for a complex check most likely. Especially if you intend to do it repeatedly. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: explicit vs implicit syntax
All this is in the same paragraph of oreilly Programming perl page 100 - pub in 1991. I guess it is kinda old. Anyway, it actually says ...more efficient... But I'm still sticking with showarg(); style too. -rkl But Orielly says showargs() is slower than showargs That's a good point, and something I didn't know. ...I'm not sure if it will make me change my ways though. Do you know where you read that? I'm not sure why it would be slower, I would think that this would be optimized when the code is compiled to be the same speed. Rob -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 6:15 PM To: Hanson, Rob Cc: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: explicit vs implicit syntax I agree it looks like the best standardized candidate for use. But Orielly says showargs() is slower than showargs when not passing arguments. It's just a minor point but its something I read. In any case, I'm used to the showarg() style. thanks, -rkl showargs(); I like this one. It's the usual way to program. In most languages the parens are required, so it's just easier to stick with one habit. My preference... showargs(); Ick. I use this one when it is required (references and overriding prototypes), otherwise it isn't what I mean. If I mean to just execute the method, then I don't use it. showargs; Yuk. It saves a few keystrokes, but I tend to avoid it. showargs(); I like this one. It's the usual way to program. In most languages the parens are required, so it's just easier to stick with one habit. Rob -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 5:43 PM To: Thomas Bätzler Cc: '[EMAIL PROTECTED]'; Tim Johnson; [EMAIL PROTECTED] Subject: RE: explicit vs implicit syntax Thanks I understand what you're saying. If I could ask, which one of these would you use? showargs; #NOT this is the tricky showargs(); showargs; showargs(); thanks, -rkl [EMAIL PROTECTED] asked: Here's an excerpt about the from orielly and what the heck does it means: ...If a subroutine is called using the form, the argument list is optional. if ommitted, no @_ array is setup for the routine; the @_ array at the time of the call is visible to subroutine instead. If in doubt, run a test ;-) #!/usr/bin/perl -w use strict; sub showargs { print arguments are: . join(', ', @_) . \n; } sub test { print Arguments for test() are: . join(', ', @_) . \n; print Calling showargs - ; showargs; print Calling showargs() - ; showargs(); print Calling showargs - ; showargs; print Calling showargs() - ; showargs(); } test qw(foo baz bar); __END__ So, is there a better or worse? both ways works for me. I just started going back and putting the onto the sub ;) I don't like it the but I thought that you need it. See for yourself - there's only one use for the ampersand, and it's obscure. My advice would be to avoid using it even in the one situation where it would make sense - when passing @_ as an argument to your function. Sure, it is idiomatic Perl at its best, but it also makes a program harder to read and understand. In other words - save it for Perl Golf ;-) HTH, Thomas PS: Perl Golf - writing code with as little (key-)strokes as possible. -- 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: Testing Uninitialized Vars
Are you saying this would do everything that I want? #I'm considering undefined var and '' and 0s are the same thing. if($x) ... true - do_something -rkl On Thursday, October 2, 2003, at 05:09 PM, [EMAIL PROTECTED] wrote: if ( ! defined $x ) I read up on defined and undefined. But I'm looking for a test that will this return true or false to a var condition: perldoc -f defined perldoc -f undef The second is a little different than what you think though. sub isNULL { if ( ! defined($_[0]) || $_[0] eq '') { return 1; } else { return; } } # my goal is all three return the same as # my proposed sub isNULL() my $x; # undefined $x=; # zero length $x=''; # zero length That last two are identical. If you don't mind considering 0s NULL too, you can do even better: do_something() if $x; # won't happen on undef, '' or 0 values for $x Would the new sub do or is there a better? A sub is better for a complex check most likely. Especially if you intend to do it repeatedly. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Testing Uninitialized Vars
On Thursday, October 2, 2003, at 06:29 PM, [EMAIL PROTECTED] wrote: Are you saying this would do everything that I want? #I'm considering undefined var and '' and 0s are the same thing. if($x) ... true - do_something I said it would, if you don't mind 0 being false. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Testing Uninitialized Vars
you mean $x=0; would be false? On Thursday, October 2, 2003, at 06:29 PM, [EMAIL PROTECTED] wrote: Are you saying this would do everything that I want? #I'm considering undefined var and '' and 0s are the same thing. if($x) ... true - do_something I said it would, if you don't mind 0 being false. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Testing Uninitialized Vars
On Thursday, October 2, 2003, at 07:08 PM, [EMAIL PROTECTED] wrote: you mean $x=0; would be false? Yep. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Testing Uninitialized Vars
-Original Message- From: James Edward Gray II [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 5:20 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Testing Uninitialized Vars On Thursday, October 2, 2003, at 07:08 PM, [EMAIL PROTECTED] wrote: you mean $x=0; would be false? Yep. James Gotcha. You meant to ask if $x==0 would be false... (I'm guessing). -Mark -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Testing Uninitialized Vars
On Thursday, October 2, 2003, at 07:23 PM, LoBue, Mark wrote: -Original Message- From: James Edward Gray II [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 5:20 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Testing Uninitialized Vars On Thursday, October 2, 2003, at 07:08 PM, [EMAIL PROTECTED] wrote: you mean $x=0; would be false? Yep. James Gotcha. You meant to ask if $x==0 would be false... (I'm guessing). No, he meant that: if ($x) { } # would be false and not execute, if he set $x first with $x = 0; 0 is false in Perl, just as it is in C. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Testing Uninitialized Vars
James has my intention correctly: my $x=0; if($x) #this would return false which is NOT I was looking for. To recap, I want to test if a var is undefined or ''. Thus, this would be equivalent to my isNULL() approach? if(undefined $x length($x)==0) thanks, -rkl -Original Message- From: James Edward Gray II [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 5:20 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Testing Uninitialized Vars On Thursday, October 2, 2003, at 07:08 PM, [EMAIL PROTECTED] wrote: you mean $x=0; would be false? Yep. James Gotcha. You meant to ask if $x==0 would be false... (I'm guessing). -Mark -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Testing Uninitialized Vars
On Oct 2, [EMAIL PROTECTED] said: To recap, I want to test if a var is undefined or ''. if(undefined $x length($x)==0) There IS no 'undefined' function in Perl, and you don't want to use , you'd want to use ||, since the empty string IS defined. if (not defined($x) or length($x) == 0) { # it's undef OR } Or, do it the other way: if (defined $x and length $x) { # it's NOT undef, and it's NOT } -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Testing Uninitialized Vars
if (defined $x and length $x) So, is this the opposite? if (! defined $x and length $x) or do I have to parenthesis if (! (defined $x and length $x)) -rkl On Oct 2, [EMAIL PROTECTED] said: To recap, I want to test if a var is undefined or ''. if(undefined $x length($x)==0) There IS no 'undefined' function in Perl, and you don't want to use , you'd want to use ||, since the empty string IS defined. if (not defined($x) or length($x) == 0) { # it's undef OR } Or, do it the other way: if (defined $x and length $x) { # it's NOT undef, and it's NOT } -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Testing Uninitialized Vars
On Thu, Oct 02, 2003 at 07:03:02PM -0700, [EMAIL PROTECTED] wrote: if (defined $x and length $x) So, is this the opposite? if (! defined $x and length $x) Nope; you've got a precedence problem. unless( defined $x and length $x ) { } -- Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Group list elements
GöTz Verdieck wrote: Hi, Hello, I'm looking for a solution for the following problem: This is the list I have : $kommalist =20,21,22,23,24,25,27,28,31,32,33; And I want to convert it into : $newlist =20..25,27,28,31..33; So, I only want to combine the elements if there are more than two like 20,21,23 Any hint or code will help. Perhaps this will help: $ perl -le' use Set::IntSpan; my $kommalist = 20,21,22,23,24,25,27,28,31,32,33; my $set = new Set::IntSpan $kommalist; my $newlist = Set::IntSpan::run_list $set; print $newlist; ' 20-25,27-28,31-33 John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Group list elements
John W. Krahn wrote: GöTz Verdieck wrote: I'm looking for a solution for the following problem: This is the list I have : $kommalist =20,21,22,23,24,25,27,28,31,32,33; And I want to convert it into : $newlist =20..25,27,28,31..33; So, I only want to combine the elements if there are more than two like 20,21,23 Any hint or code will help. Perhaps this will help: $ perl -le' use Set::IntSpan; my $kommalist = 20,21,22,23,24,25,27,28,31,32,33; my $set = new Set::IntSpan $kommalist; my $newlist = Set::IntSpan::run_list $set; print $newlist; ' 20-25,27-28,31-33 Or perhaps this: $ perl -le' $kommalist = 20,21,22,23,24,25,27,28,31,32,33; ( $newlist = $kommalist ) =~ s/(\d+),(?=(\d+))/$1 + 1 == $2 ? $1.. : $1,/eg; $newlist =~ s/\.\.\d+(?=\.\.)//g; print $newlist; ' 20..25,27..28,31..33 John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Testing Uninitialized Vars
unless understood, how about this. if (defined $x and length $x) So, is this the opposite? if (! defined $x and ! length $x) -rkl On Thu, Oct 02, 2003 at 07:03:02PM -0700, [EMAIL PROTECTED] wrote: if (defined $x and length $x) So, is this the opposite? if (! defined $x and length $x) Nope; you've got a precedence problem. unless( defined $x and length $x ) { } -- Steve -- 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: Testing Uninitialized Vars
On Thu, Oct 02, 2003 at 07:41:41PM -0700, [EMAIL PROTECTED] wrote: unless understood, how about this. if (defined $x and length $x) So, is this the opposite? if (! defined $x and ! length $x) Nope; now you've got a boolean logic problem. Either of these would work, but unless() is nicer. if ( !(defined $x and length $x) ) { ... } if ( !(defined $x) or !(length $x) ) { ... } -- Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Testing Uninitialized Vars
if (defined $x and length $x) So, is this the opposite? if (! defined $x and ! length $x) I don't think so. It's basic Aristotelian logic and can be determined by truth tables or testing. Questions are mere conjecture :) The negative of a statement, A, is: not A. That can be writted as: ! A (with a difference in precedence binding. See http://www.perldoc.com/perl5.6/pod/perlop.html) Now, A may be a conjunctive statement, such as ( B and C ). That means the negative would be: 1. not ( B and C ) or 2. ! (B and C) By truth tables or experimentation that be be proved equivilant to the following disjunctive statement: 3. ( (! B) or (!C) ) or 4. ( (not B) or (not C) ) It is not equivilant to 5. ( (! A) and (!B) ) or 6. ( ! (A and (!B) ) Because (B and C) is true only if (B is true and C is true), and it is false if either (B is false xor C is false) or (both B and C are false). If you use parenthesis as in statements (3) and (4) above, then you do not need to worry about operator binding rules. If you want to craft very compact statements and programs to win perl golf tournaments, that is the time to rely on the operator associativity and precedence rules to eliminate all the parentheses you can! (unless the game is to confound your opponent with a lot of parentheses) If you get really good at using a plethora of parentheses in even small programs, then maybe you will like Lisp - (car '(a (b (c (d (e (f (g (h (i (j (l (m n) o) p) q) r) s) t) u) v) w) y) z)) = a (http://www.lns.cornell.edu/public/COMP/info/emacs-lisp-intro/emacs-lisp -intro_8.html) -tristram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Validate String w/required period
I'm trying to validate if a string contains \w and required atleas one period (.) This one check but does not require a period. Can someone change it please? sub isValidDomain { return shift =~ /^[\w\.]{3,}$/ } thanks, -rkl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
invoking sub/methods shortcut
Can I do something like this? from $sth = getVUser($dbh, $u, $d); return $sth-rows(); to return (getVUser($dbh,$u,$d))-rows(); a move from java-perl ;) thanks, -rkl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]