Re: How to run a process in background?
Hi and thank you. I've tried the script sample and it works fine but it doesn't work with the following line: fork exit; I need to type just: fork; because otherwise the browser (IE) keeps Opening page Can you tell me, is it OK if I use the script with the line for closing STDIN, STDOUT, and STDERR uncommented? In this case all works fine. Is it any danger to create zombies? And what do you recommend, to use exec, or system? I don't need to get the output from the child process, but I don't know how is better, to let the parent process to wait for the child, or not. Thank you. Teddy's Center for the blind: http://teddy.fcc.ro/ Email: [EMAIL PROTECTED] - Original Message - From: zentara [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, September 30, 2002 3:17 PM Subject: Re: How to run a process in background? On Sun, 29 Sep 2002 16:40:07 +0200, [EMAIL PROTECTED] (Octavian Rasnita) wrote: I want to make a script that is activated from a browser but it might take a long time to send all the messages using the Net::SMTP. So I think that it could be a good idea to make a background process to run it. Can you give me some hints about how I should use the fork, to run the process in background? Your biggest problem is to close the pipes to apache from the forked children, else your clients will see their browser's hang. Merlyn has a good column on this at www.stonehenge.com column 20. Here is a simple example to demonstrate the problem. Make up some long process to test this with, like while(1){sleep(1)} Then try running it as a cgi script with and without the line which closes STDOUT, STDIN, and STDERR. With it commented out, your browser will hang. ## #!/usr/bin/perl use warnings; use strict; $| = 1; # need either this or to explicitly flush stdout, etc. # before forking print Content-type: text/plain\n\n; print Going to start the fork now\n; fork exit; #try running with the following line commented out close STDOUT;close STDIN;close STDERR; exec('./fork-long-process-test-process') || warn funniness $!; #if you use system here, instead of exec, the parent process #hangs around for child to exit, even though the cgi exits. # -- 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]
replacing text in a file
Hi, can you help a begnner with this?? I have a file with the following repeated several times. The date and time will vary. UPDATED=06/18/2002 18:42:25 I wnat to replace what ver text is between the quotes with NOT APPLICABLE ie UPDATED=NOT APPLICABLE Regards, Gary The information contained in or attached to this email is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient, you are not authorised to and must not disclose, copy, distribute, or retain this message or any part of it. It may contain information which is confidential and/or covered by legal professional or other privilege (or other rules or laws with similar effect in jurisdictions outside England and Wales). The views expressed in this email are not necessarily the views of Centrica plc, and the company, its directors, officers or employees make no representation or accept any liability for its accuracy or completeness unless expressly stated to the contrary. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: replacing text in a file
Hello Gary, God bless you. On Wed, Oct 09, 2002 at 04:19:42PM +0100, Egleton, Gary wrote: I have a file with the following repeated several times. The date and time will vary. UPDATED=06/18/2002 18:42:25 I wnat to replace what ver text is between the quotes with NOT APPLICABLE ie UPDATED=NOT APPLICABLE Assuming you are asking to do that with a CGI script, you can do something like: open OLDF, file.txt || die ERROR; open NEWF, newfile.txt || die ERROR; while(OLDF) { if ( /UPDATED=(.*?)/ ) { s/$1/NOT APPLICABLE/; } print NEWF; } close OLDF; close NEWF; # CAUTION: Investigate and uncomment the following only if right. #system('rm', 'file.txt'); # assuming no errors!!! #system('mv', 'newfile.txt', 'file.txt'); # from memory not tested... Note that on a CGI script you have to be very carefully about where file.txt and newfile.txt are. I mean, you have to give/have write access to the appropiate user under which your web server run CGI scripts. If you are working from the command line, try: perl -p -i.old -e 's/$1/NOT APPLICABLE/ if /UPDATED=(.*?)/' file.txt This would save your original file.txt as file.txt.old and write the modified version directly to file.txt HTH, Roberto Ruiz. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: replacing text in a file
my $line = 'UPDATED=06/18/2002 18:42:25'; $line =~ s/(.*?)/NOT APPLICABLE/sig; try this. --- Egleton, Gary [EMAIL PROTECTED] wrote: Hi, can you help a begnner with this?? I have a file with the following repeated several times. The date and time will vary. UPDATED=06/18/2002 18:42:25 I wnat to replace what ver text is between the quotes with NOT APPLICABLE ie UPDATED=NOT APPLICABLE Regards, Gary The information contained in or attached to this email is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient, you are not authorised to and must not disclose, copy, distribute, or retain this message or any part of it. It may contain information which is confidential and/or covered by legal professional or other privilege (or other rules or laws with similar effect in jurisdictions outside England and Wales). The views expressed in this email are not necessarily the views of Centrica plc, and the company, its directors, officers or employees make no representation or accept any liability for its accuracy or completeness unless expressly stated to the contrary. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos More http://faith.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Sending HTML mail?
Hello all, Could you please tell me what module should I use to send HTML mail? Can I use Net::SMTP? And what module could I use to send attachments? Thank you. Teddy's Center for the blind: http://teddy.fcc.ro/ Email: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run a process in background?
Hi and thank you. I want to create a script that is activated when someone visits a .shtml page. That script is launched by a server side includes line. The script need to check if a database was updated, and send mail to more email addresses about this. This mailing process might take a long time, and I don't want the page visitor to need waiting until the mailing is complete. The server is not mine and I can't use other methods to check the database from time to time and send mail, so the visitor is not interested in sending those emails at all. They don't even know that a mailing process is started by them. So I don't need to get the results from the child process. If I need this, I might print the results to a log file. I want the child process to continue working and the web page to finish loading after initiating the process, not waiting for it. I also want the child process to terminate fine without creating zombies. It is pretty hard to understand zombies very well, because I don't know Unix too well. Thank you. Teddy's Center for the blind: http://teddy.fcc.ro/ Email: [EMAIL PROTECTED] - Original Message - From: zentara [EMAIL PROTECTED] To: Octavian Rasnita [EMAIL PROTECTED] Sent: Wednesday, October 09, 2002 2:22 PM Subject: Re: How to run a process in background? On Wed, 9 Oct 2002 18:10:42 +0200 Octavian Rasnita [EMAIL PROTECTED] wrote: I've tried the script sample and it works fine but it doesn't work with the following line: fork exit; I need to type just: fork; ... because otherwise the browser (IE) keeps Opening page The script was just to demonstrate what closing STDOUT does to release the browser. Can you tell me, is it OK if I use the script with the line for closing STDIN, STDOUT, and STDERR uncommented? Sure, but your browser will stay connected as long as the child process is running, or the server times out. Wasn't that your original problem? In this case all works fine. Is it any danger to create zombies? Zombies could get created if you kill off the parents before the children. And what do you recommend, to use exec, or system? What are you trying to do exactly? system runs and returns results to the calling process, when you do an exec, the calling process terminates and the exec'd process goes on. I don't need to get the output from the child process, but I don't know how is better, to let the parent process to wait for the child, or not. If you don't need output from the child process, what is the child process doing? There is alot of intricacies with forking, and I can't say what you should do without know what you want to do. It would be best for you to post your code to the list, many brains are better than one. Post what you are trying to do, not just generalized questions about forking in a cgi. -- use Perl; #powerful programmable prestidigitation -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Perl / CGI - User Authentication ...
Kevin wrote: Hello, I am in the process of developing a CGI application that requires user authentication. In the past I have developed a simple login screen where I validated the user and forwarded the request based on the result. I would like to progress to the next level and pass the authentication to Apache. I am limited in the sense that mod_perl is not available. Can this be done without mod_perl? Please keep in mind that the username / password are stored in a mySQL table? CGI::Session can do all that stuff and make it easy. Depends on Apache::Session, but does NOT depend on mod_perl. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
spaces in a variable
Hi, How to remove spaces in a variable? For eg if i have variable $te $te = $attr_tag . $date; chomp$te; print $te; Gives me output as follows: SYNC_CHECKWed Oct 9 12:20:53 2002 I want to remove all the spaces in output variable $te. Regards javeed
RE: spaces in a variable
-Original Message- From: Javeed SAR [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 09, 2002 5:05 PM To: [EMAIL PROTECTED] Subject: spaces in a variable Hi, How to remove spaces in a variable? For eg if i have variable $te $te = $attr_tag . $date; chomp$te; print $te; Gives me output as follows: SYNC_CHECKWed Oct 9 12:20:53 2002 I want to remove all the spaces in output variable $te. $te =~ s/\s+//g; Regards javeed -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
(forw) [bootscat@bellsouth.net: Re: FW: Need urgent help]
- Forwarded message from Bootscat [EMAIL PROTECTED] - From: Bootscat [EMAIL PROTECTED] To: Mat Harris [EMAIL PROTECTED] Subject: Re: FW: Need urgent help Date: Tue, 8 Oct 2002 20:04:38 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600. X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600. X-MS-WARNING: Warning: This email was written on a microsoft product, and should be considered unsafe Hello Mat, I tried require './config.cgi'; I still get the same error. Any other idea's. This one really has me stumped. Thanks Dan - Original Message - From: Mat Harris [EMAIL PROTECTED] To: Bootscat [EMAIL PROTECTED] Cc: Beginners (E-mail) [EMAIL PROTECTED] Sent: Tuesday, October 08, 2002 5:36 PM Subject: Re: FW: Need urgent help - End forwarded message - -- Mat Harris OpenGPG Public Key ID: C37D57D9 [EMAIL PROTECTED]matthewh.genestate.com msg31942/pgp0.pgp Description: PGP signature
Re: Number of open sockets
Jessee Parker wrote: Is there a way to keep track of the number of open sockets your program might have that are in a TIME_WAIT (I think it is) state? If you want can trye this script for to track the socket open on the ports feel free for every change that you want to do. thio script exec the scan on a range of ports that you can handle like oyu prefer and for exec more fast the scan i use 2 process simultaneosly I hope can useful. Sorry for my ugly english. Regards. Saffioti Goffredo. #!/usr/bin/perl -w #Written by *SAFFIOTI GOFFREDO* #script for scannning of open socket on ports. use IO::Socket; use IPC::Open2; use Term::ANSIColor; use POSIX :sys_wait_h; my ($port, $sock, @servers); my $pid = 0; my($server, $begin, $end) = @ARGV; usage if (!$server); $begin = 0 if (!$begin); $end = 65000 if (!$end); print Scanning from $begin to $end\n; my $status; $pid = fork; if ($pid != 0) { for ($port=$begin;$port=(($begin + $end)/2);$port++) { scan;; if ( $sock ) { print color 'bold blue'; print $$ Connected on port $port\n; # print $!; } else { print color 'bold blue'; print $$ $port not connected\n; } } my $childpid; # $status = 1; while ($status = waitpid(-1, WNOHANG) 0) { wait; } } else { #for ($port=(($begin + $end)/2);$port=$end;$port++){ for ($port=($end/2)+1;$port=$end;$port++){ scan; if ( $sock ) { print color 'bold white'; print $$ Connected on port $port\n ; } else { print color 'bold white'; print $$ $port not connected\n; } } } sub usage{ print Usage: portscan hostname [start from port to port number]\n; exit(0); } sub scan{ $sock = IO::Socket::INET-new(PeerAddr = $server, PeerPort = $port, Proto = 'tcp'); } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
I need help for handling text log file
Hi Perl experts, I need your help. I am absolute Perl beginner. I am writing perl with Windows 95 machine. I download Perl from activestate and my version 5.6.1. It works properly and I can run some program. Currently I am writing log file processing with perl. I can write normal program as read the log file and write to formatted log file. What I am facing now is when I write to format text file, suppose I was currently in line 10 for my formatted text file and I want to append some word in line 5 of formatted text file. I want to know how to do it. Which function should I use. I use seek() function to write but it add additional machine words. Thanks in advance for your help. Best regards, Winn Thu Myanmar __ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos More http://faith.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: I need help for handling text log file
Not an expert in perl (nor in english), but let's try ;-) if your output file is not supposed to get too big, consider 'writing' first your output lines in a hash ... $hash{1} = line 1; and so on (later, writing line 10 for eg.) if (whatever) { $hash{5} .= these few words; } when finished, drop all the lines in the hash to output file ... foreach (sort(keys(%hash)) { print OUTPUTFILE $hash{$_}, \n; } Hope this helps. Hello Buddy a écrit : Hi Perl experts, I need your help. I am absolute Perl beginner. I am writing perl with Windows 95 machine. I download Perl from activestate and my version 5.6.1. It works properly and I can run some program. Currently I am writing log file processing with perl. I can write normal program as read the log file and write to formatted log file. What I am facing now is when I write to format text file, suppose I was currently in line 10 for my formatted text file and I want to append some word in line 5 of formatted text file. I want to know how to do it. Which function should I use. I use seek() function to write but it add additional machine words. Thanks in advance for your help. Best regards, Winn Thu Myanmar __ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos More http://faith.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to deploy a Perl Application
my 2 cents... Distributed GUI apps are legacy. Write web based software. You right ! That's what I was thinking about ... Do you have some reasons in which case Distributed GUI will be the winner against Browser Client ? Should I continue learning Perl/Tk then ? :-) José. DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: I need help for handling text log file
Why not just use Tie::File module ? http://search.cpan.org/author/JHI/perl-5.8.0/lib/Tie/File.pm#SYNOPSIS José. -Original Message- From: Hello Buddy [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 09, 2002 11:29 AM To: [EMAIL PROTECTED] Subject: I need help for handling text log file Hi Perl experts, I need your help. I am absolute Perl beginner. I am writing perl with Windows 95 machine. I download Perl from activestate and my version 5.6.1. It works properly and I can run some program. Currently I am writing log file processing with perl. I can write normal program as read the log file and write to formatted log file. What I am facing now is when I write to format text file, suppose I was currently in line 10 for my formatted text file and I want to append some word in line 5 of formatted text file. I want to know how to do it. Which function should I use. I use seek() function to write but it add additional machine words. Thanks in advance for your help. Best regards, Winn Thu Myanmar __ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos More http://faith.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: (forw) [bootscat@bellsouth.net: Re: FW: Need urgent help]
On Wed, 9 Oct 2002 09:00:20 +0100, [EMAIL PROTECTED] (Mat Harris) wrote: I tried require './config.cgi'; I still get the same error. Any other idea's. This one really has me stumped. Your config.cgi needs to have a 1; on it's last line. Also check permissions on the file. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: I need help for handling text log file
Thanks Jean, But I am afraid to say that my log file is at least over 60 K lines. I do not know how to do it. How can I insert any words in any place of open text file? Regards Winn --- Jean Padilla [EMAIL PROTECTED] wrote: Not an expert in perl (nor in english), but let's try ;-) if your output file is not supposed to get too big, consider 'writing' first your output lines in a hash ... $hash{1} = line 1; and so on (later, writing line 10 for eg.) if (whatever) { $hash{5} .= these few words; } when finished, drop all the lines in the hash to output file ... foreach (sort(keys(%hash)) { print OUTPUTFILE $hash{$_}, \n; } Hope this helps. Hello Buddy a écrit : Hi Perl experts, I need your help. I am absolute Perl beginner. I am writing perl with Windows 95 machine. I download Perl from activestate and my version 5.6.1. It works properly and I can run some program. Currently I am writing log file processing with perl. I can write normal program as read the log file and write to formatted log file. What I am facing now is when I write to format text file, suppose I was currently in line 10 for my formatted text file and I want to append some word in line 5 of formatted text file. I want to know how to do it. Which function should I use. I use seek() function to write but it add additional machine words. Thanks in advance for your help. Best regards, Winn Thu Myanmar __ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos More http://faith.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos More http://faith.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Win32API::Net
Due to an bad and old software i need to do an fix. i have problems though, i need to list all the users in a global group. (Active directory), this was easy to do. I need to put these users in an local group on a server, this is easy aswell! The problem i get is that when i list the global group for members it only lists the users, not any more groups in this global group. Script, this gets users. use strict; use Win32API::Net; my (@users,$user); my $group = GLOBALGROUP; my $server = SERVER; Win32API::Net::GroupGetUsers($server, $group, \@users); for $user (@users) { print $user\n; } Then its easy aswell to add these to an local group. There is alot of users belonging in groups in this global group (nested groups) how do i get those out? the groupgetusers doesnt even show the group names in there. So i cant go around it and list that group for users aswell..any ideas? another quick question aswell. How do i check if an array contains data or is empty? any quick way? //Dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: evaluating expressions in here documents
From: Jim Ockers [EMAIL PROTECTED] Is there any concise method of fully evaluating the arithmetic expressions in here documents, rather than just one level of substitution?: sub RotationMatrix { my $theta = $_[0] * 3.14159265 / 180.0; my $m = cos($theta); my $n = sin($theta); my $T = Math::MatrixReal-new_from_string(ROTMATRIX); [ $m**2 $n**2 2*$m*$n ] [ $n**2 $m**2 -2*$m*$n ] [ -$m*$n $m*$n $m**2-$n**2 ] ROTMATRIX return $T }; use Interpolation '=' = 'eval'; my $T = Math::MatrixReal-new_from_string(ROTMATRIX); [ $={$m**2} $={$n**2} $={2*$m*$n} ] [ $={$n**2} $={$m**2} $={-2*$m*$n}] [ $={-$m*$n} $={$m*$n} $={$m**2-$n**2} ] ROTMATRIX You may find Interpolation.pm on CPAN and http://Jenda.Krynicky.cz/#Interpolation HTH, Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to deploy a Perl Application
From: NYIMI Jose (BMB) [EMAIL PROTECTED] my 2 cents... Distributed GUI apps are legacy. Write web based software. You right ! That's what I was thinking about ... Do you have some reasons in which case Distributed GUI will be the winner against Browser Client ? Yeah ... Browser Client applications tend to take longer to do anything in. The interface cannot contain all the features and rings and bells a normal GUI can (unless you use Java and use the browser just to download and host the application). Another thing ... browser is a general ussage program, therefore it uses much more memory and processor power than a small program that only does one thing. Which on less equiped computers may mean that the user will spend more time waiting. I would not want to have write my programs in web browser based editor, read my emails in web based mail, listen to my MP3s using a web based interface etc. etc. etc. If the application is something you use twice a week I'd say it would be better if it was web based (so you did not have to install upgrades almost as often as you use it), if you use it most of the time you'd go crazy. (I'm going crazy from the ##%*%@^#%*$^#$ PVCS written in Java, even that is t slow and restricted.) Should I continue learning Perl/Tk then ? :-) Depends on what do you need. I think if I needed to do GUI in Perl I'd go with wxPerl or maybe gTk. But please don't take this as a wizard's advice, I have never done any GUI in Perl. Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
variables in regexp
Hi to all, I feel myself very stupid, but I've tried to do it in different ways and I cannot do it. I need to clear a text, to tokenize it, for instance to delete some things and to transform some others: .. at this time I use this regexp: a) to delete s/=+\n//g; s/-+\n//g; b) to transform s/-+/-/g; s/\*+/\*/g; s/\^+/\^/g; s/\_+/\_/g; s/ +/ /g; (this one doesn't works very well: at the end there are several blank spaces) and I used this one: s/\s+/ /g; but I understand this is not very useful: I need to change a multiple \n|\r|\t|\f in a single \n|\r|\t|\f. BUT, when I try to create an array (@tochange = (-, \*, \^, \n, \t,\r,\f,\+,\_,=, ); and I also used a my $tochange=...;) the regexp s/$tochange+/$tochange/g; does not work. May you help me? Thanks a lot! adr -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
file handles!
HI I define a file the following way: $FILE_HANDLE = somefile; then I openit open(FILEHANDLE); i perform some operations.. and then I want to transfer this somefile to some other directory but I am not able to use mv comand to do it for e.g ` mv $FILE_HANDLE /home/pravesh ` ; doesnt work!!! help needed! pravesh -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: file handles!
Hi, pravesh 1 - You are saying mv somefile /home/pravesh ! 2 - a file handle is *not* to be confused with a file name try : my $file_name = somefile; open(FILE_HANDLE, $file_name) or die ... ... your 'move' is now `mv $file_name /home/pravesh`; regards. Pravesh Biyani a écrit : HI I define a file the following way: $FILE_HANDLE = somefile; then I openit open(FILEHANDLE); i perform some operations.. and then I want to transfer this somefile to some other directory but I am not able to use mv comand to do it for e.g ` mv $FILE_HANDLE /home/pravesh ` ; doesnt work!!! help needed! pravesh -- 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: I need help for handling text log file
Hi, I've downloaded Tie::File module from http://search.cpan.org/author/MJD/Tie-File-0.93/ and given it a little try : works fine. (even for me : Just Another Perl Newbie). Thanks, José. NYIMI Jose (BMB) a écrit : Why not just use Tie::File module ? http://search.cpan.org/author/JHI/perl-5.8.0/lib/Tie/File.pm#SYNOPSIS José. -Original Message- From: Hello Buddy [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 09, 2002 11:29 AM To: [EMAIL PROTECTED] Subject: I need help for handling text log file Hi Perl experts, I need your help. I am absolute Perl beginner. I am writing perl with Windows 95 machine. I download Perl from activestate and my version 5.6.1. It works properly and I can run some program. Currently I am writing log file processing with perl. I can write normal program as read the log file and write to formatted log file. What I am facing now is when I write to format text file, suppose I was currently in line 10 for my formatted text file and I want to append some word in line 5 of formatted text file. I want to know how to do it. Which function should I use. I use seek() function to write but it add additional machine words. Thanks in advance for your help. Best regards, Winn Thu Myanmar __ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos More http://faith.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: variables in regexp
Adriano Allora wrote: b) to transform s/-+/-/g; s/\*+/\*/g; s/\^+/\^/g; s/\_+/\_/g; s/ +/ /g; (this one doesn't works very well: at the end there are several blank spaces) and I used this one: s/\s+/ /g; but I understand this is not very useful: I need to change a multiple \n|\r|\t|\f in a single \n|\r|\t|\f. Or more general, you want to substitute more occurences of -, *, ^, _, \s with only one. To implement this, you can use first a character class and second a capture: s/([*^_\s-])+/$1/g; Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
regex is working , then not?
Hi! I do not understand why my regex works , then does not. regex: my (dat) = /(\w+\s+\w+\s+)=\s+(\w+)_(\w+)_(\w+)_/; Works! Process Name = D4_jerry_5LM_1.91_BF Returns: Process Name DM4 15C035 5LM Does NOT work: Process Name = d4_jerry_5lm Is there a better way to write this regex? Thanks, Jerry
removal of a line in a file
Perl gurus, I was wondering if there is a one liner that searches a file for a string and then removes that line and the following four lines in the file? Thanks, Chad -- Chad Kellerman Jr. Systems Administrator Alabanza Inc 410-234-3305 signature.asc Description: This is a digitally signed message part
RE: regex is working , then not?
See inline comments -Original Message- From: Jerry Preston [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 09, 2002 10:36 AM To: Beginners Perl Subject: regex is working , then not? Hi! I do not understand why my regex works , then does not. regex: my (@dat) = /(\w+\s+\w+\s+)=\s+(\w+)_(\w+)_(\w+)_/; Works! Process Name = D4_jerry_5LM_1.91_BF This one has 3 _ (underscores) Returns: Process Name DM4 15C035 5LM Does NOT work: Process Name = d4_jerry_5lm This one has 2 _ (you are matching for 3 in your regex) perhaps you should gather the last half and then split on _: my (@dat) = /(\w+\s+\w+\s+)=\s+([.\w]+)/; push @dat = split /_/, pop @dat; [untested] Is there a better way to write this regex? Thanks, Jerry The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: regex is working , then not?
Jerry Preston wrote: Hi! I do not understand why my regex works , then does not. regex: my (@dat) = /(\w+\s+\w+\s+)=\s+(\w+)_(\w+)_(\w+)_/; ^ This last underscore is expected. Works! Process Name = D4_jerry_5LM_1.91_BF Returns: Process Name DM4 15C035 5LM Does NOT work: Process Name = d4_jerry_5lm So only Process Name = d4_jerry_5lm_ would work Is there a better way to write this regex? Just remove the unneccessary underscore or add a ? after it. BTW: I believe I would choose a completely different way: my ($key,$name) = split /\s+=\s+/; my @name_part = split /_/, $name; Greetings, -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: regex is working , then not?
OK! I see 2 as to 3. Is there a way to make this regex smart enough to handle both string? Is there a way that (\w+)_ can be changed to 2 to 10? my (@dat) = /(\w+\s+\w+\s+)=\s+(\w+)_(\w+)_(\w+)_/; Thanks, Jerry -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 09, 2002 9:41 AM To: '[EMAIL PROTECTED]'; Beginners Perl Subject: RE: regex is working , then not? See inline comments -Original Message- From: Jerry Preston [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 09, 2002 10:36 AM To: Beginners Perl Subject: regex is working , then not? Hi! I do not understand why my regex works , then does not. regex: my (@dat) = /(\w+\s+\w+\s+)=\s+(\w+)_(\w+)_(\w+)_/; Works! Process Name = D4_jerry_5LM_1.91_BF This one has 3 _ (underscores) Returns: Process Name DM4 15C035 5LM Does NOT work: Process Name = d4_jerry_5lm This one has 2 _ (you are matching for 3 in your regex) perhaps you should gather the last half and then split on _: my (@dat) = /(\w+\s+\w+\s+)=\s+([.\w]+)/; push @dat = split /_/, pop @dat; [untested] Is there a better way to write this regex? Thanks, Jerry The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to deploy a Perl Application
The Browser's interface cannot contain all the features and rings and bells a normal GUI can (unless you use Java and use the browser just to download and host the application) What about Perl for the aforementioned functionality. It's seems that Java is the Guru in GUI matters ? :( José. DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: regex is working , then not?
... regex: my (@dat) = /(\w+\s+\w+\s+)=\s+(\w+)_(\w+)_(\w+)_/; Works! Process Name = D4_jerry_5LM_1.91_BF Returns: Process Name DM4 15C035 5LM Does NOT work: Process Name = d4_jerry_5lm ... Hi, is that 3rd _ intended ? If yes, it would work on Process Name = d4_jerry_5lm_ ? HTH, Thorsten -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Odd and even numbers
Greetings, I am trying to write a script that at one point needs to look at a number and divide it by two. The results must always be an integer, but the numerator can potentially be an odd number. What I want to do is if the numerator is odd, increment it to the next highest even number. Is there a function in PERL that will allow me to test weather or not an integer is odd or even so that I can increment the number before I do the division? Rz -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Odd and even numbers
Hi, $num += $num % 2; this increments $num if $num modulo 2 is 1 (ie. if $num was odd) regards. Zielfelder, Robert a écrit : Greetings, I am trying to write a script that at one point needs to look at a number and divide it by two. The results must always be an integer, but the numerator can potentially be an odd number. What I want to do is if the numerator is odd, increment it to the next highest even number. Is there a function in PERL that will allow me to test weather or not an integer is odd or even so that I can increment the number before I do the division? Rz -- 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: Odd and even numbers
Robert Zielfelder wrote: I am trying to write a script that at one point needs to look at a number and divide it by two. The results must always be an integer, but the numerator can potentially be an odd number. So you just want to divide by 2 rounding up the result. use POSIX qw/ceil/; my $half = ceil( $nr / 2 ); Of course, you could also use a direct Perl hack: my $half = int( $nr + 1 ); What I want to do is if the numerator is odd, increment it to the next highest even number. Is there a function in PERL that will allow me to test weather or not an integer is odd or even so that I can increment the number before I do the division? I would always suggest to express the algorithm directly, but it's of course also possible to find out whether a number is even or odd. One way is to use the modulo operator: if (($nr % 2) == 0) { # nr is even } else { # nr is odd } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: regex is working , then not?
Jerry Preston wrote: Is there a way to make this regex smart enough to handle both string? Is there a way that (\w+)_ can be changed to 2 to 10? my (@dat) = /(\w+\s+\w+\s+)=\s+(\w+)_(\w+)_(\w+)_/; Use the split function instead. Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Odd and even numbers
perl -e 'printf %.0d\n, $ARGV[0]/2 if @ARGV' 5 Weird why doesn't this work they way I expect it to? it returns 2 not 3. -Original Message- From: Zielfelder, Robert [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 09, 2002 10:58 AM To: Perl Beginners List (E-mail) Subject: Odd and even numbers Greetings, I am trying to write a script that at one point needs to look at a number and divide it by two. The results must always be an integer, but the numerator can potentially be an odd number. What I want to do is if the numerator is odd, increment it to the next highest even number. Is there a function in PERL that will allow me to test weather or not an integer is odd or even so that I can increment the number before I do the division? Rz The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to deploy a Perl Application
From: NYIMI Jose (BMB) [EMAIL PROTECTED] The Browser's interface cannot contain all the features and rings and bells a normal GUI can (unless you use Java and use the browser just to download and host the application) What about Perl for the aforementioned functionality. It's seems that Java is the Guru in GUI matters ? :( Jos. You can't use Perl for aplets, that's all. Java is only better in that it's already installed on most places. That's its only advantage. You could use it as a client scripting language instead of JavaScript, but AFAIK only if the user(s) had Windows, MSIE and PerlScript installed. Not too likely :-( Jenda P.S.: Please don't CC me. The mail is going to be filtered into Perl- Lists folder anyway.=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Odd and even numbers
From: Zielfelder, Robert [EMAIL PROTECTED] I am trying to write a script that at one point needs to look at a number and divide it by two. The results must always be an integer, but the numerator can potentially be an odd number. What I want to do is if the numerator is odd, increment it to the next highest even number. Is there a function in PERL that will allow me to test weather or not an integer is odd or even so that I can increment the number before I do the division? TIMTOWTDI $num++ if $num % 2; # if modulo 2 is 1 $num++ if $num 1; # if the lowest bit is set Jenda=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Odd and even numbers
On Oct 9, Nikola Janceski said: perl -e 'printf %.0d\n, $ARGV[0]/2 if @ARGV' 5 Weird why doesn't this work they way I expect it to? it returns 2 not 3. Blame C and the IEEE standards. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** 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: variables in regexp
Adriano Allora wrote: Hi to all, Hello, I feel myself very stupid, but I've tried to do it in different ways and I cannot do it. I need to clear a text, to tokenize it, for instance to delete some things and to transform some others: .. at this time I use this regexp: a) to delete s/=+\n//g; s/-+\n//g; b) to transform s/-+/-/g; s/\*+/\*/g; s/\^+/\^/g; s/\_+/\_/g; s/ +/ /g; (this one doesn't works very well: at the end there are several blank spaces) and I used this one: s/\s+/ /g; but I understand this is not very useful: I need to change a multiple \n|\r|\t|\f in a single \n|\r|\t|\f. BUT, when I try to create an array (@tochange = (-, \*, \^, \n, \t,\r,\f,\+,\_,=, ); and I also used a my $tochange=...;) the regexp s/$tochange+/$tochange/g; does not work. If you want to transform multiple characters to a single character: $ perl -le' $_ = q/***^^^---___/; print; tr/-*^_//s; print; ' ***^^^---___ -*^_^*-_ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to deploy a Perl Application
On Wednesday, October 9, 2002, at 05:28 AM, NYIMI Jose (BMB) wrote: Do you have some reasons in which case Distributed GUI will be the winner against Browser Client ? Sure, tons. Neither Photoshop nor Warcraft III are going to see a HTML interface in their next revision. Don't get me wrong, I'm not knocking the web application solution, I'm just saying that I don't think it's all encompassing. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: removal of a line in a file
On 9 Oct 2002, chad kellerman wrote: Perl gurus, I was wondering if there is a one liner that searches a file for a string and then removes that line and the following four lines in the file? Any particular reason for a one-liner? perl -i~ -pe '((/string/and$ln=$.)..($.-$ln==4))undef $_' file Note: In the case where string is 'efgh' and input is like this efgh 1 efgh 2 3 4 5 The above one-liner will delete the first 'efgh' and the 4 lines following it. It will not do an incremental delete. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: regex is working , then not?
Jerry Preston wrote: Hi! Hello, I do not understand why my regex works , then does not. regex: my (@dat) = /(\w+\s+\w+\s+)=\s+(\w+)_(\w+)_(\w+)_/; Works! Process Name = D4_jerry_5LM_1.91_BF Returns: Process Name DM4 15C035 5LM Does NOT work: Process Name = d4_jerry_5lm Is there a better way to write this regex? $ perl -le' $_ = q/Process Name = D4_jerry_5LM_1.91_BF/; @dat = split /\s*[=_]\s*/; print for @dat; $_ = q/Process Name = d4_jerry_5lm/; @dat = split /\s*[=_]\s*/; print for @dat; ' Process Name D4 jerry 5LM 1.91 BF Process Name d4 jerry 5lm John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
GD::Graph::lines - x axis tick labels - using time
I am trying to create a graph showing que length in relation to time. My problem is that the script below does not put the time in the x-axis, it just puts 5,10,15,20 etc. I think the problem is with the x axis commands. I've changed the x_tick_number to auto and null, but the actual values are never displayed. My environment is RH7.2, perl v. 5.6.0. Please reply to this email address as well as posting to the group. TIA, Lance #!/usr/bin/perl use GD::Graph::lines; @data = ( [ 15:44, 15:49, 15:54, 15:59, 16:04, 16:09, 16:14, 16:19, 16:24, 16:29, 16:34, 16:39, 16:44, 16:49, 16:54, 16:59, 17:04, 17:09, 17:14, 17:19, 17:24, 17:29, 17:34, 17:39, 17:44, 17:49, 17:54, 17:59, 18:04, 18:09, 18:14, 18:19, 18:24, 18:29, 18:34, 18:39, 18:44, 18:49, 18:54, 18:59, 19:04, 19:09, 19:14, 19:19, 19:24, 19:29, 19:34, 19:39, 19:44, 19:49, 19:54, 19:59, 07:04, 07:09, 07:14, 07:19, 07:24, 07:29, 07:34, 07:39, 07:44, 07:49, 07:54, 07:59, 08:04, 08:09, 08:14, 08:19, 08:24, 08:29, 08:34, 08:39, 08:44, 08:49, 08:54, 08:59, 09:04, 09:09, 09:14, 09:19, 09:24, 09:29, 09:34, 09:39, 09:44, 09:49, 09:54, 09:59, 10:04, 10:09, 10:14, 10:19, 10:24, 10:29, 10:34, ], [ 1.51, 1.53, 1.16, 1.07, 0.68, 0.73, 0.68, 0.69, 0.67, 0.70, 0.61, 0.56, 0.85, 0.83, 0.59, 0.50, 0.57, 0.47, 0.70, 0.41, 0.43, 0.40, 0.45, 0.33, 0.25, 0.30, 0.26, 0.25, 0.27, 0.32, 0.29, 0.27, 0.28, 0.22, 0.44, 0.34, 0.27, 0.28, 0.43, 0.49, 0.39, 0.27, 0.18, 0.20, 0.25, 0.15, 0.10, 0.08, 0.10, 0.14, 0.11, 0.13, 0.21, 0.18, 0.34, 0.33, 0.20, 0.22, 0.32, 0.26, 0.33, 0.48, 0.55, 0.53, 0.58, 0.60, 0.36, 0.37, 0.45, 0.56, 0.51, 0.62, 0.72, 1.02, 1.05, 1.00, 0.96, 0.77, 0.85, 0.84, 0.91, 0.73, 0.78, 0.99, 1.21, 1.90, 2.52, 1.85, 1.23, 1.26, 1.11, 1.46, 0.92, 0.91, 0.79, ], ); my $graph = new GD::Graph::lines(950,150); $graph-set( x_label = 'Time', y_label = 'Processes Waiting', title = 'Processes Waiting vs. Time', y_max_value = 3, y_min_value = 0, y_tick_number = 5, x_tick_number = 10, box_axis = 1, line_width = 2, show_values = 0, long_ticks = 0, ); $graph-plot(\@data); open(OUTPUT, /usr/local/apache2/htdocs/output7.png) or die Can't open output7.png: $!\n; print OUTPUT $graph-gd-png(); close(OUTPUT); _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to deploy a Perl Application
On Wednesday, October 9, 2002, at 07:08 AM, Jenda Krynicky wrote: Yeah ... Browser Client applications tend to take longer to do anything in. Of course, this can be as much a fault of bad interface design as the medium. The interface cannot contain all the features and rings and bells a normal GUI can ... And on the flip side, some programs don't need that many bells to do their job. Another thing ... browser is a general ussage program, therefore it uses much more memory and processor power than a small program that only does one thing. Which on less equiped computers may mean that the user will spend more time waiting. This too can be a plus, in a way. A browser is one of the most common general usage programs around. You can generally just count on the fact that a computer can display vanilla HTML no matter what it is or who made it. ...read my emails in web based mail... I would say this example could be well suited to a web application. Granted I have yet to see an implementation as good as my favored client, but they are improving and they do have their advantages (again, available anywhere, just to name one). If the application is something you use twice a week I'd say it would be better if it was web based (so you did not have to install upgrades almost as often as you use it), if you use it most of the time you'd go crazy. (I'm going crazy from the ##%*%@^#%*$^#$ PVCS written in Java, even that is t slow and restricted.) My advice here would be to let the interface of the application be your guide. Is it well suited to an HTML interface? What would you gain that way, in addition to instant universal upgrades? What would you lose, in addition to the typical faults Jenda pointed out? Like most choices, there are plenty of tradeoffs here, I think. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: removal of a line in a file
Chad Kellerman wrote: I was wondering if there is a one liner that searches a file for a string and then removes that line and the following four lines in the file? grep 'string' -A 4 yourfile.txt | grep -v -f - yourfile.txt :-) John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mixing long and short options
Robert Citek wrote: Can someone show me an example of how I can mix long and short options with Getopt? I would like to pass options to a perl script that can take both short and long options. For example, all of these commands work (this is GNU tar): # tar -tzvf foo.tar.gz # tar --list zvf foo.tar.gz # tar --list --ungzip -vf foo.tar.gz # tar --list -z --verbose -f foo.tar.gz # tar --list --ungzip --verbose -f foo.tar.gz # tar --list --ungzip --verbose --file foo.tar.gz Any examples of how to mix long and short options or pointers to example would be greatly appreciated. perldoc Getopt::Long John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
what is $self-verbose
from some modules,i found this expression if ($self-verbose) . is this verbose is a special method or something else? thanks - Do you Yahoo!? Faith Hill - Exclusive Performances, Videos, more faith.yahoo.com
RE: mixing long and short option
Hello, The documentation for GetOpt::Long on CPAN includes a section on configuring the module. Several properties of interest to be configured are auto_abbrev, bundling, and bundling_override. Says the blurb on the bundling description, for example: Enabling this option will allow single-character options to be bundled. To distinguish bundles from long option names, long options must be introduced with -- and bundles with -. So GetOpt::Long supports single-char as well as word-like option, allows bundling of the single-char type like UNIX, etc. I would give the documentation a thorough read and see what you can mangle from it. Cheers, Nathanae Kuipers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
$RIDLINE = 'RID\s+=\s+(\d+-\d+-\d+)';
what is the meaning of $RIDLINE = 'RID\s+=\s+(\d+-\d+-\d+)'; i found it from the begin block of a module. thanks - Do you Yahoo!? Faith Hill - Exclusive Performances, Videos, more faith.yahoo.com
RE: $RIDLINE = 'RID\s+=\s+(\d+-\d+-\d+)';
It might help to say what module you found it in, since that would supply more context. Most generally, it looks like $RIDLINE is going to be put into a regular expression, perhaps something along the lines of m/$RIDLINE/ If you are asking about the \s+ sort of notation, then you need to read up on regexes. Please see chapters 5 and 6 of Programming Perl 3rd Ed., Friedl's Mastering Regular Expressions, and of course perldoc perlre Cheers, Nathanael Kuipers = Original Message From stanley [EMAIL PROTECTED] = what is the meaning of $RIDLINE = 'RID\s+=\s+(\d+-\d+-\d+)'; i found it from the begin block of a module. thanks - Do you Yahoo!? Faith Hill - Exclusive Performances, Videos, more faith.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: what is $self-verbose
Supplying module names makes answering it easier to give a better answer. Idiomatically, $self usually refers to the scalar being blessed into a class, in other words, an object. So $self-verbose is indeed calling a method on the object using the indirect syntax, though whether or not this method is an instance method or optionally also a class method can't be said with certainty from the one line of code you gave. Please see perldoc perlobj, perldoc perltoot, and perldoc perltootc. Cheers, Nathanael Kuipers = Original Message From stanley [EMAIL PROTECTED] = from some modules,i found this expression if ($self-verbose) . is this verbose is a special method or something else? thanks - Do you Yahoo!? Faith Hill - Exclusive Performances, Videos, more faith.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: file handles!
Jean Padilla [EMAIL PROTECTED] wrote: Hi, pravesh 1 - You are saying mv somefile /home/pravesh ! 2 - a file handle is *not* to be confused with a file name Actually - Perl will let you do our $FH = 'path'; open FH or die...; # open FH, '', $FH Doesn't work with 'my' variables, though. try : my $file_name = somefile; open(FILE_HANDLE, $file_name) or die ... ... your 'move' is now `mv $file_name /home/pravesh`; And now you can do: `mv $FH /home/pravesh`; The whole thing would be better written: #!/usr/bin/perl use warnings; use File::Copy; my $path = 'somefile'; open FH, $path or die open: $path: $!; ... move $path, '/home/pravesh' or die move: $path = /home/pravesh: $! -- Steve perldoc -qa.j | perl -lpe '($_)=m((.*))' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Promoting to a Subclass
If I have an object and I want to increase it's functionality by upgrading/promoting it to a subclass if certain conditions are met during a method call, could/should I use something like: sub some_method { my $self = $_[0]; # ... if (PROMOTE_CONDITION) { $_[0] = Subclass-copy_constructor($self); } } That will change the reference in the calling code, right? Any reason I shouldn't do this? James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Promoting to a Subclass
On Wed, Oct 09, 2002 at 02:34:49PM -0500, James Edward Gray II wrote: If I have an object and I want to increase it's functionality by upgrading/promoting it to a subclass if certain conditions are met during a method call, could/should I use something like: sub some_method { my $self = $_[0]; # ... if (PROMOTE_CONDITION) { $_[0] = Subclass-copy_constructor($self); } } That will change the reference in the calling code, right? Right. Any reason I shouldn't do this? Not if you know what you are doing. Presumably your copy constructor is simply reblessing the object and maybe doing some initialisation. Be careful if your original object had a destructor. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Promoting to a Subclass
--- James Edward Gray II [EMAIL PROTECTED] wrote: If I have an object and I want to increase it's functionality by upgrading/promoting it to a subclass if certain conditions are met during a method call, could/should I use something like: sub some_method { my $self = $_[0]; # ... if (PROMOTE_CONDITION) { $_[0] = Subclass-copy_constructor($self); } } That will change the reference in the calling code, right? Any reason I shouldn't do this? James As for whether or not you should do that, it really depends upon what you're trying to do and since I don't know what that is, I can't comment. You are correct that the above code will work. However, since this *is* a reference, you don't need to worry about keeping @_ intact. bless affects the reference and leaves the referent intact. Here's a little test script that demonstrates how this works. --- #!/usr/bin/perl -w use strict; package Foo; sub new { bless { this = 1 }, shift; } sub promote { my $self = shift; $self = Foo::Bar-copy_constructor( $self ); } sub inherited_method { print Houston, we have inheritance!\n; } package Foo::Bar; use base 'Foo'; sub copy_constructor { my ( $class, $object ) = @_; bless $object, $class; } sub not_in_parent { print We're ok!\n; } package main; use Data::Dumper; my $object = Foo-new; eval { $object-not_in_parent }; print \nWarning: $@\n; $object-promote; $object-not_in_parent; $object-inherited_method; print Dumper $object; --- Cheers, Ovid = Ovid on http://www.perlmonks.org/ Someone asked me how to count to 10 in Perl: push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//; shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A __ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos More http://faith.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: I need help for handling text log file
On Wed, Oct 09, 2002 at 02:28:58AM -0700, Hello Buddy wrote: What I am facing now is when I write to format text file, suppose I was currently in line 10 for my formatted text file and I want to append some word in line 5 of formatted text file. Please see perldoc -q line in a file, or http://www.perldoc.com/perl5.6.1/pod/perlfaq5.html (second question) for discussion on inserting a line in a file. The short answer is you can't; you'll have to essentially copy the file, inserting the line you need as you go. If the file you're editing has fixed lines it is possible to overwrite a line, but to insert one you'd have to overwrite a line, then write each following line in to the end of the file. Given that, it would appear that the file is not the appropriate solution to your problem. You may want to look into a DBM (perldoc DB_File), or a DBMS (mysql, PostgreSQL, etc.). Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
sort a hash
Hi, @array = qx{egrep -n '\{' file); foreach $el (@array) { ($num,@other} = split(/\:/,$el); $thenum{$num} = $num; } foreach $ele (sort keys %thenum) { print$ele\n; } except this one sort by string and not by integer, so 100 is before 99 Do you have an idea to sort that by interger and not by string, 99 before 100? I tried to rebuild the key and even using the function int() but i'm stuck. Thank you Pierre _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: sort a hash
Replace the following foreach $ele (sort keys %thenum with foreach $ele (sort {$a = $b} keys %thenum) This will do ascending numeric or if descending switch the a and b around. Wags ;) -Original Message- From: P lerenard [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 09, 2002 13:21 To: [EMAIL PROTECTED] Subject: sort a hash Hi, @array = qx{egrep -n '\{' file); foreach $el (@array) { ($num,@other} = split(/\:/,$el); $thenum{$num} = $num; } foreach $ele (sort keys %thenum) { print$ele\n; } except this one sort by string and not by integer, so 100 is before 99 Do you have an idea to sort that by interger and not by string, 99 before 100? I tried to rebuild the key and even using the function int() but i'm stuck. Thank you Pierre _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** 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: sort a hash
see bottom... -Original Message- From: P lerenard [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 09, 2002 1:21 PM To: [EMAIL PROTECTED] Subject: sort a hash Hi, @array = qx{egrep -n '\{' file); foreach $el (@array) { ($num,@other} = split(/\:/,$el); $thenum{$num} = $num; } foreach $ele (sort keys %thenum) { print$ele\n; } except this one sort by string and not by integer, so 100 is before 99 Do you have an idea to sort that by interger and not by string, 99 before 100? -Response Text- You are using the default sort operation (string). You want to use a numeric sort, so you will need to provide your own block for sorting. perldoc -f sort foreach $ele (sort {$a = $b} keys %thenum) /\/\ark -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: sort a hash
thanks working fine From: Wagner, David --- Senior Programmer Analyst --- WGO [EMAIL PROTECTED] To: 'P lerenard' [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: RE: sort a hash Date: Wed, 9 Oct 2002 15:25:23 -0500 Replace the following foreach $ele (sort keys %thenum with foreach $ele (sort {$a = $b} keys %thenum) This will do ascending numeric or if descending switch the a and b around. Wags ;) -Original Message- From: P lerenard [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 09, 2002 13:21 To: [EMAIL PROTECTED] Subject: sort a hash Hi, @array = qx{egrep -n '\{' file); foreach $el (@array) { ($num,@other} = split(/\:/,$el); $thenum{$num} = $num; } foreach $ele (sort keys %thenum) { print$ele\n; } except this one sort by string and not by integer, so 100 is before 99 Do you have an idea to sort that by interger and not by string, 99 before 100? I tried to rebuild the key and even using the function int() but i'm stuck. Thank you Pierre _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** 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. _ Chat with friends online, try MSN Messenger: http://messenger.msn.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: sort a hash
On Wed, Oct 09, 2002 at 08:21:27PM +, P lerenard wrote: except this one sort by string and not by integer, so 100 is before 99 Do you have an idea to sort that by interger and not by string, 99 before 100? See perldoc -f sort. It has many fine examples of how to sort various types of data, including numbers. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Thanks Re: sort a hash
thank you all really really quik answer Pierre From: Michael Fowler [EMAIL PROTECTED] To: P lerenard [EMAIL PROTECTED] CC: [EMAIL PROTECTED] Subject: Re: sort a hash Date: Wed, 9 Oct 2002 12:33:28 -0800 On Wed, Oct 09, 2002 at 08:21:27PM +, P lerenard wrote: except this one sort by string and not by integer, so 100 is before 99 Do you have an idea to sort that by interger and not by string, 99 before 100? See perldoc -f sort. It has many fine examples of how to sort various types of data, including numbers. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
thanks RE: sort a hash
thank you all special thanks for the first 3 on the podium Pierre From: Mark Anderson [EMAIL PROTECTED] To: P lerenard [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: RE: sort a hash Date: Wed, 9 Oct 2002 13:28:40 -0700 see bottom... -Original Message- From: P lerenard [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 09, 2002 1:21 PM To: [EMAIL PROTECTED] Subject: sort a hash Hi, @array = qx{egrep -n '\{' file); foreach $el (@array) { ($num,@other} = split(/\:/,$el); $thenum{$num} = $num; } foreach $ele (sort keys %thenum) { print$ele\n; } except this one sort by string and not by integer, so 100 is before 99 Do you have an idea to sort that by interger and not by string, 99 before 100? -Response Text- You are using the default sort operation (string). You want to use a numeric sort, so you will need to provide your own block for sorting. perldoc -f sort foreach $ele (sort {$a = $b} keys %thenum) /\/\ark -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
list literal stuff
Hello everyone, The following is from page 75 in the Camel: List assignment in scalar context returns the number of elements produced by the expression on the iright/i side of the assignment: $x = ( ($a, $b) = (7,7,7) ); #set $x to 3, not 2 It goes on to explain how this is useful but from previous reading in the same section I don't understand how or why this works. When I first saw this, I worked out the assignment where $a and $b each get a 7 and the third 7 is discarded, then $x gets the last value in the list of $a and $b because of the comma operator for list literals in a scalar context...or does the presence of vars in the list mean that this isn't a list literal, more like an array in behavior? So really, I guess I don't understand either side of the assignment and how it behaves in scalar context due to $x. :) So I guess this could end up being something I just memorize, but I'd rather understand what's happening... Sorry if this was confusing. TIA, Nathanael -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: list literal stuff
On Wed, Oct 09, 2002 at 02:16:52PM -0700, nkuipers wrote: When I first saw this, I worked out the assignment where $a and $b each get a 7 and the third 7 is discarded, then $x gets the last value in the list of $a and $b because of the comma operator for list literals in a scalar context...or does the presence of vars in the list mean that this isn't a list literal, more like an array in behavior? You go into a sort of ramble here, but I think this is where your confusion lies. You're trying to equate list assignment with either how an array behaves, or how a list behaves. List assignment is neither an array nor a list, it's a list assignment, so it behaves differently in different contexts. So really, I guess I don't understand either side of the assignment and how it behaves in scalar context due to $x. :) So I guess this could end up being something I just memorize, but I'd rather understand what's happening... Well, it's both; this is something you'll have to memorize, and with that, understand what's happening when a list assignment is encountered. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Rephrase the list literal question
The following is from page 75 in the Camel: List assignment in scalar context returns the number of elements produced by the expression on the iright/i side of the assignment: $x = ( ($a, $b) = (7,7,7) ); #set $x to 3, not 2 why. how. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Promoting to a Subclass
James Edward Gray II wrote: If I have an object and I want to increase it's functionality by upgrading/promoting it to a subclass if certain conditions are met during a method call, could/should I use something like: sub some_method { my $self = $_[0]; # ... if (PROMOTE_CONDITION) { $_[0] = Subclass-copy_constructor($self); } } That will change the reference in the calling code, right? yes. that's true. Any reason I shouldn't do this? a well define OO design tries to maximize code reuseability and share as much as possible. be very careful of the sharing portion as to avoid circular reference. if your child reference something in the parent and later when the parent upgrade to the child again, the child class return back this reference to the newly upgraded object(now a child object), you just get youself a circular reference. Perl never warn you able this and as you upgrade more and more parent objects to child objects, you create more and more circular reference. just watch out for that. just curious: if you want child's functionality, why wouldn't you want to have the child object in the first place? david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Rephrase the list literal question
Nkuipers wrote: The following is from page 75 in the Camel: List assignment in scalar context returns the number of elements produced by the expression on the iright/i side of the assignment: $x = ( ($a, $b) = (7,7,7) ); #set $x to 3, not 2 can you guess what $x is now: $x = ($a,$b) = (7,7,7); make sense now right? :-) if still doesn't make sense, it's time to check the associativity of the '=' operator. yes, i know nowaday no one is mentioning that anymore :-) david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Rephrase the list literal question
On Wed, Oct 09, 2002 at 03:22:20PM -0700, nkuipers wrote: The following is from page 75 in the Camel: List assignment in scalar context returns the number of elements produced by the expression on the iright/i side of the assignment: $x = ( ($a, $b) = (7,7,7) ); #set $x to 3, not 2 why. how. Note that this is the same as $x = ($a, $b) = (7,7,7); = is right associative. ($a, $b) = (7,7,7) you already understand. This is the list assignment mentioned above. It is in a scalar context because of the assignment to $x, which is a scalar. But the right side of the assignment is still talking about the list assignment, and thus $x gets the number of elements in (7,7,7), which is 3, not ($a, $b) which would be 2. This allows you to do useful things like $x = () = some_function; which evaluates some_function in list context, and sets $x to the number of elements returned. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Promoting to a Subclass
On Wednesday, October 9, 2002, at 05:15 PM, david wrote: just curious: if you want child's functionality, why wouldn't you want to have the child object in the first place? Glad, you asked; I would love a second opinion! My server manages vanilla Telnet connections with a Connection object. All the Telnet protocol stuff is in an easily replaced method though, for subclassing. I want to keep it so Telnet is always supported, and thus the default connection type. But connections can be upgraded to a higher protocol, if they ask for it. That's why I thought it would be cool to just upgrade the object reference when the request comes in. Tell me if you see chinks in that suit of armor though, I'm all ears. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
newbie user-pass attempt
After trying my hand at perl, realizing it was above my head, going back at starting with python, and now trying again at perl this is my first (failed) attempt at a user-pass program attempt, except it never accepts the username. What is wrong with it? %up = { 'kyle' = 123, 'jason' = 123, 'chelsea' = 123, 'john' = 123, 'cheryl' = 123 }; while (1) { print Please enter your username: \n; $u = STDIN; chomp($u); if (exists $up{$u}) { print Please enter your password: \n; $p = STDIN; chomp($p); if ($up{$u} eq $p) { print Access granted\n; } else { print Incorrect password\n; } } else { print Incorrect username\n; } }; Thank you, -- Kyle -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: list literal stuff
Nkuipers [EMAIL PROTECTED] wrote: Hello everyone, The following is from page 75 in the Camel: List assignment in scalar context returns the number of elements produced by the expression on the iright/i side of the assignment: $x = ( ($a, $b) = (7,7,7) ); #set $x to 3, not 2 It goes on to explain how this is useful but from previous reading in the same section I don't understand how or why this works. When I first saw this, I worked out the assignment where $a and $b each get a 7 and the third 7 is discarded, then $x gets the last value in the list of $a and $b because of the comma operator for list literals in a scalar context... The result of scalar assignment is the lvalue on the left hand side: $x = $y = 2; # $x = 2 ($x = 1) = 2; # $x = 2 print $x = 2; # prints 2 In list context, the result of list assignment is the list of values on left hand side: @x = () = 0..10;# @x = () @x = ($y) = 0..10; # @x = (0) @x = ($y, $z) = 0..10; # @x = (0,1) These are consistent, and it's easy to infer the simple, but incomplete, rule: assigment returns its left hand side Which can lead a person to believe that compound assignments can always be broken down into two or more steps: $x = $y = 1; # or: $y = 1; $x = $y The problem is that list assignment in scalar context breaks the pattern. $x = ($y) = 0..10; # $x = 11 There's no way to explain why $x = ($y) ought to yield 11 here. (In fact, it shouldn't.) You just have to accept that list assigment in scalar context *doesn't* return its LHS. It returns the number of elements on the RHS. HTH -- Steve perldoc -qa.j | perl -lpe '($_)=m((.*))' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: newbie user-pass attempt
On Thu, Oct 10, 2002 at 12:01:31AM +, Kyle Babich wrote: %up = { 'kyle' = 123, 'jason' = 123, 'chelsea' = 123, 'john' = 123, 'cheryl' = 123 }; This is your problem. You've constructed an anonymous hash and assigned it to %up. You should be using parens, not curly braces: %up = (...); This is a good time to tell you that you should always run your code with -w and use strict. I.e. your script should start with: #!/usr/bin/perl -w use strict; Had you done that, you would have been warned of a possibly problem in the %up assignment. Please note, the use strict will require you to declare your variables ($u, $p, and %up). The best way to learn Perl is with a good beginning Perl book, such as Learning Perl or Beginning Perl. See learn.perl.org for further references. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Promoting to a Subclass
James Edward Gray II wrote: On Wednesday, October 9, 2002, at 05:15 PM, david wrote: just curious: if you want child's functionality, why wouldn't you want to have the child object in the first place? Glad, you asked; I would love a second opinion! My server manages vanilla Telnet connections with a Connection object. All the Telnet protocol stuff is in an easily replaced method though, for subclassing. I want to keep it so Telnet is always supported, and thus the default connection type. But connections can be upgraded to a higher protocol, if they ask for it. That's why I thought it would be cool to just upgrade the object reference when the request comes in. Tell me if you see chinks in that suit of armor though, I'm all ears. James forgive me if i am wrong but you basically have: 1. a server of some kind 2. this server uses the Connection object(class) 3. the Connection object has a method that handles the Telnet protocol 4. when you subclass Connection, you still want your Connection object to still be able to handle the Telnet protocol but also be able to handle the protocol that the child class is designed to handle 5. this way your Connection object not only handles the Telnet protocal(because it already know that from the beginning) but also the child class's protocal(because you upgrade Connection to the child class). if that's what you want, i really don't see any advantage of doing this. you are basically making the parent back to the child but the child is already a parent! instead of subclassing Connection, i would just decouple Connection into 2 separate modules: one for handling the actual Telnet protocal(really genertic) and another one for handling connection to the Telnet protocal so you will have: 1. a class(call it TelnetPro) for handling the Telnet protocal only. 2. subclass TelnetPro into Connect for handling connection for Telnet now say that you want to add HTTP support to your server, you will code another class(call it HTTPPro) for handling the HTTP protocal and subclass(yes, multiple inheritence) Connect from it again. hopefully all you have to change is one line in Connect from: @ISA=qw(Exporter TelnetPro); to: @ISA=qw(Exporter TelnetPro HTTPPro); all the sudden, Connect knows how to handle Telnet as well as HTTP. as you add more and more protocal support, you will keep adding to Connect's @ISA to support those. this might not work depends on the actual spec and requirment of the project that you are working on. just my 2cent :-) david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: sort a hash
P Lerenard wrote: Hi, Hello, @array = qx{egrep -n '\{' file); foreach $el (@array) { ($num,@other} = split(/\:/,$el); $thenum{$num} = $num; } foreach $ele (sort keys %thenum) { print$ele\n; } except this one sort by string and not by integer, so 100 is before 99 Do you have an idea to sort that by interger and not by string, 99 before 100? I tried to rebuild the key and even using the function int() but i'm stuck. #!/usr/bin/perl -w use strict; my $file = 'file'; my %thenum; open FILE, $file or die Cannot open $file: $!; while ( FILE ) { $thenum{$.} = $. if /{/; } for my $ele ( sort { $a = $b } keys %thenum ) { print $ele\n; } __END__ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Promoting to a Subclass
Thanks a lot for the advice! I'll factor this into my thinking and see what I come up with. James On Wednesday, October 9, 2002, at 07:07 PM, david wrote: James Edward Gray II wrote: On Wednesday, October 9, 2002, at 05:15 PM, david wrote: just curious: if you want child's functionality, why wouldn't you want to have the child object in the first place? Glad, you asked; I would love a second opinion! My server manages vanilla Telnet connections with a Connection object. All the Telnet protocol stuff is in an easily replaced method though, for subclassing. I want to keep it so Telnet is always supported, and thus the default connection type. But connections can be upgraded to a higher protocol, if they ask for it. That's why I thought it would be cool to just upgrade the object reference when the request comes in. Tell me if you see chinks in that suit of armor though, I'm all ears. James forgive me if i am wrong but you basically have: 1. a server of some kind 2. this server uses the Connection object(class) 3. the Connection object has a method that handles the Telnet protocol 4. when you subclass Connection, you still want your Connection object to still be able to handle the Telnet protocol but also be able to handle the protocol that the child class is designed to handle 5. this way your Connection object not only handles the Telnet protocal(because it already know that from the beginning) but also the child class's protocal(because you upgrade Connection to the child class). if that's what you want, i really don't see any advantage of doing this. you are basically making the parent back to the child but the child is already a parent! instead of subclassing Connection, i would just decouple Connection into 2 separate modules: one for handling the actual Telnet protocal(really genertic) and another one for handling connection to the Telnet protocal so you will have: 1. a class(call it TelnetPro) for handling the Telnet protocal only. 2. subclass TelnetPro into Connect for handling connection for Telnet now say that you want to add HTTP support to your server, you will code another class(call it HTTPPro) for handling the HTTP protocal and subclass(yes, multiple inheritence) Connect from it again. hopefully all you have to change is one line in Connect from: @ISA=qw(Exporter TelnetPro); to: @ISA=qw(Exporter TelnetPro HTTPPro); all the sudden, Connect knows how to handle Telnet as well as HTTP. as you add more and more protocal support, you will keep adding to Connect's @ISA to support those. this might not work depends on the actual spec and requirment of the project that you are working on. just my 2cent :-) david -- 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]
use warnings; doesn't work
i use solaris and ihave no root right.the version of perl5.005_03 in a simple script if i try to add use warnings,it will say Can't locate warnings in inc(inc..) instead if i use perl -w my.pl,it will give me the warning information. so how can i modify my configuration or what modules should i download? thanks - Do you Yahoo!? Faith Hill - Exclusive Performances, Videos, more faith.yahoo.com
Re: use warnings; doesn't work
Stanley wrote: i use solaris and ihave no root right.the version of perl5.005_03 in a simple script if i try to add use warnings,it will say Can't locate warnings in @inc(@inc..) instead if i use perl -w my.pl,it will give me the warning information. so how can i modify my configuration or what modules should i download? thanks You would have to upgrade perl to use the use warnings; pragma. Untill I get perl6, I just use the -w switch on the shebang line and fiddle with the corresponding global variables to turn warnings on and off (Actually, I think Ive only ever written one piece of code where id DID turn warnings off). Anyways, it does the same thing. Instead of putting the -w switch on the command line when you run the program, put it on the shebang: #!/path/to/perl -w No matter how you execute the program, warnings will always get turned on. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: use warnings; doesn't work
both #!/usr/bin/perl -w and perl -w my.pl will do the warnings work,but use warnings will throw exception. if i setup a file called warnings.pm(it only conatins 1) in my lib and don't use directive or option,there is no warning and exception stanley nkuipers wrote: If you put the -w flag in your shebang line like this #!/usr/bin/perl -w does it still throw an exception or do the warnings work? = Original Message From stanley = i use solaris and ihave no root right.the version of perl5.005_03 in a simple script if i try to add use warnings,it will say Can't locate warnings in inc(inc..) instead if i use perl -w my.pl,it will give me the warning information. so how can i modify my configuration or what modules should i download? thanks - Do you Yahoo!? Faith Hill - Exclusive Performances, Videos, more faith.yahoo.com
Re: use warnings; doesn't work
Todd how do you turn off the warning ? stanley i use solaris and ihave no root right.the version of perl5.005_03 in a simple script if i try to add use warnings,it will say Can't locate warnings in @inc(@inc..) instead if i use perl -w my.pl,it will give me the warning information. so how can i modify my configuration or what modules should i download? thanks You would have to upgrade perl to use the use warnings; pragma. Untill I get perl6, I just use the -w switch on the shebang line and fiddle with the corresponding global variables to turn warnings on and off (Actually, I think Ive only ever written one piece of code where id DID turn warnings off). Anyways, it does the same thing. Instead of putting the -w switch on the command line when you run the program, put it on the shebang: #!/path/to/perl -w No matter how you execute the program, warnings will always get turned on. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Do you Yahoo!? Faith Hill - Exclusive Performances, Videos, more faith.yahoo.com
Re: use warnings; doesn't work
On Wed, Oct 09, 2002 at 07:55:13PM -0700, stanley wrote: #!/usr/bin/perl -w does it still throw an exception or do the warnings work? -w on the shebang or command lines will work with any version of Perl. The use warnings pragma was added in 5.6.0, and this is why you're getting the error. Also, rather than asking us if it'll work, you should try it and see for yourself. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to deploy a Perl Application
Nyimi Jose wrote: The Browser's interface cannot contain all the features and rings and bells a normal GUI can (unless you use Java and use the browser just to download and host the application) What about Perl for the aforementioned functionality. It's seems that Java is the Guru in GUI matters ? :( Im all XML these days. The logic is handled on the server side, and any bells and whistles my gui needs come from DHTML via the DOM in the browser. Really not much it cant do (right-click, tooltips, css), and (one day soon) will be universally implemented. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help with database generated pop up menu
Hello, Can someone help me with creating a script to return certain information from a Postgres database to a drop down box on a webpage? #!/usr/bin/perl use CGI; use DBI; #Define connection values $DBSource = 'dbi:Pg:dbname=mydb'; $DBUsername = 'test'; $DBAuth = 'test'; #Open db connection $dbh = DBI-connect($DBSource,$DBUsername,$DBAuth) or die Can't connect to SQL Database; #Prepare and execute SQL statement $sqlstatement=SELECT $value FROM $table WHERE username LIKE '[EMAIL PROTECTED]'; $sth = $dbh-prepare($sqlstatement); $sth-execute || die Could not execute SQL statement ... maybe invalid?; #Output database results to pop up menu HTML BODY formselect name=test; while ( my @row = $sth-fetchrow_array() ) { option value=$row[0]$row[0]; } /select; /form; /BODY /HTML $sth-finish; $dbh-disconnect;
pass a hash to a subroutine
how can i pass a hash variable to a subrotine? such as %a=(m=1,n=2); %b=(k=4,j=6); sub givename(%a) { #here how can make %c get the subroutine argument(a hash variable)) my %c=???; print %c; } - Do you Yahoo!? Faith Hill - Exclusive Performances, Videos, more faith.yahoo.com
Re: pass a hash to a subroutine
On Wed, 9 Oct 2002, stanley wrote: how can i pass a hash variable to a subrotine? such as %a=(m=1,n=2); %b=(k=4,j=6); sub givename(%a) { #here how can make %c get the subroutine argument(a hash variable)) my %c=???; print %c; } Read through perldoc perlsub -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: pass a hash to a subroutine
On Oct 9, stanley said: sub givename(%a) DO NOT try to put variables in the declaration of a function. Unless you are into HEAVY MAGIC, your subroutine declarations (or definitions) should look like sub function_name { # ... } No () there. When you CALL the function, THEN you use (). foobar(%x); sub foobar { my %copy_of_x = @_; # ... } -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** 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]