Learning to 'fork()' the right way
Hello all, I'd like to learn how to use fork properly. I'm monitoring a running process and when it stops, I use a script to start it. The script will most likely become a cron job. To test everything I created a test script to run as a process which is written as follows: #!/usr/bin/perl use warnings; use strict; while (1) { print Hello, I'm running.\n; sleep 10; } The monitoring script is as follows: #!/usr/bin/perl use warnings; use strict; my $ps_check = `ps -ef | grep testScript.pl | grep -v grep`; if ($ps_check) { print testScript.pl is running.\n; } else { print testScript.pl is not running. I'll start it.\n; my $pid = fork(); if (!defined($pid)) { die Could not fork: $!\n; } elsif ($pid == 0) { exec(/home/scripts/utils/develop/ron/testScript.pl); exit; } else { waitpid($pid, 0); } } I was wondering if this script is written correctly and if there's a way to have the monitoring script release the shell and get the prompt back, or is it running in the child process shell and that's why it's getting output? Ron Smith geeksatla...@yahoo.com (213)300-9448 -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: I'm trying to install 'Net::SSH::Perl' on a Windows Box.
--- On Sun, 3/15/09, Chas. Owens chas.ow...@gmail.com wrote: From: Chas. Owens chas.ow...@gmail.com Subject: Re: I'm trying to install 'Net::SSH::Perl' on a Windows Box. To: geeksatla...@yahoo.com Cc: Perl beginners@perl.org Date: Sunday, March 15, 2009, 5:46 AM On Sun, Mar 15, 2009 at 04:56, Ron Smith geeksatla...@yahoo.com wrote: snip Can't locate object method rvalidate via package PPM::XML::PPD::html at C:/strawberry/perl/site/lib/PPM.pm line 16 87. snip Odd, I thought the point of Strawberry Perl was to make it so that CPAN just worked on Windows and to avoid the whole ActiveState PPM mess. Try this instead: cpan Net::SSH::Perl Thanks again! Yeah, that worked just fine. There are other issues getting 'Net::SSH::Perl' installed though. When I do the install from CPAN I get: All tests successful. Files=12, Tests=106, 2 wallclock secs ( 0.13 usr + 0.06 sys = 0.19 CPU) Result: PASS TURNSTEP/Net-SSH-Perl-1.34.tar.gz Tests succeeded but one dependency not OK (Math::GMP) TURNSTEP/Net-SSH-Perl-1.34.tar.gz [dependencies] -- NA Running make install make test had returned bad status, won't install without force Then when I try installing 'Math::GMP' I get: PS C:\Documents and Settings\Ron Smith cpan Math::GMP Database was generated on Mon, 16 Mar 2009 05:39:02 GMT Running install for module 'Math::GMP' Running make for T/TU/TURNSTEP/Math-GMP-2.05.tar.gz Checksum for C:\strawberry\cpan\sources\authors\id\T\TU\TURNSTEP\Math-GMP-2.05.tar.gz ok CPAN.pm: Going to build T/TU/TURNSTEP/Math-GMP-2.05.tar.gz Checking if your kit is complete... Looks good Writing Makefile for Math::GMP == WARNING! No GMP libraries were detected! Please see the INSTALL file. === Warning: No success on command[C:\strawberry\perl\bin\perl.exe Makefile.PL] TURNSTEP/Math-GMP-2.05.tar.gz C:\strawberry\perl\bin\perl.exe Makefile.PL -- NOT OK Running make test Make had some problems, won't test Running make install Make had some problems, won't install PS C:\Documents and Settings\Ron Smith So, I'll be taking a look at that 'INSTALL' file first. Ron Smith geeksatla...@yahoo.com -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: I'm trying to install 'Net::SSH::Perl' on a Windows Box.
--- On Mon, 3/16/09, Chas. Owens chas.ow...@gmail.com wrote: From: Chas. Owens chas.ow...@gmail.com Subject: Re: I'm trying to install 'Net::SSH::Perl' on a Windows Box. To: geeksatla...@yahoo.com Cc: Perl beginners@perl.org Date: Monday, March 16, 2009, 6:51 AM On Mon, Mar 16, 2009 at 03:51, Ron Smith geeksatla...@yahoo.com wrote: snip Then when I try installing 'Math::GMP' I get: snip WARNING! No GMP libraries were detected! snip Warning: No success on command[C:\strawberry\perl\bin\perl.exe Makefile.PL] TURNSTEP/Math-GMP-2.05.tar.gz snip The Net::SSH::Perl library depends on Math::GMP or Math::Pari to do the heavy math stuff of the SSH protocol. They are both thin wrappers around C libraries. It looks like the makefile is trying to install the library for you, but is having difficulty decompressing the source due to the lack of the compress command in Windows. It looks like some other people have had your problem and found ways around it: http://www.nntp.perl.org/group/perl.win32.vanilla/2008/07/msg49.html http://win32.perl.org/wiki/index.php?title=Install_Math-Pari_on_Strawberry_Perl -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. I installed 'Math::Pari' and still get 'WARNING! No GMP libraries were detected!'. So, I tried to install 'Math::GMP, but get really lost in the process of doing that. ...any further suggestions would be appreciated. Thanks. Ron Smith geeksatla...@yahoo.com -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: I'm sure this is a common question, but I can't find the solution.
Ron Smith wrote: Hello all, Hello, How do you print elements of an array, each on its own line, in a Windows' console? I'm doing the following: E:\My Documentsperl -e use ExtUtils::Installed; my $inst = ExtUtils::Installed-new(); my @modules = $inst-modules(); print @modules it returns: Archive::TarArchive::ZipArray::CompareAutoLoaderCPANCPAN::ChecksumsCPAN::DistnameInfo ...etc. I need: Archive::Tar Archive::Zip Array::CompareAutoLoaderCPAN CPAN::Checksums CPAN::DistnameInfo ...etc. I tried \n, '\n' and a 'foreach' loop, but nothing I do seems to work. ..any suggestions? I don't have Windows to test this on but this should work: perl -MExtUtils::Installed -lemy $inst = ExtUtils::Installed-new(); print for $inst-modules() Thanks, John. It does work. And, I've found that my original command also works when I added the -l and 'for' like: perl -le use ExtUtils::Installed; my $inst = ExtUtils::Installed-new(); my @modules = $inst-modules(); print for @modules I don't know if mine is correct form though. 'perl -h' reveals that -l enables line ending processing, specifies line terminator. Is that the idea? Ron Smith geeksatla...@yahoo.com -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: I'm sure this is a common question, but I can't find the solution.
From: Beau E. Cox beau.e@gmail.com Subject: Re: I'm sure this is a common question, but I can't find the solution. To: geeksatla...@yahoo.com Date: Saturday, March 14, 2009, 10:51 PM Ron, On Sat, Mar 14, 2009 at 7:28 PM, Ron Smith geeksatla...@yahoo.com wrote: Hello all, How do you print elements of an array, each on its own line, in a Windows' console? I'm doing the following: E:\My Documentsperl -e use ExtUtils::Installed; my $inst = ExtUtils::Installed-new(); my @modules = $inst-modules(); print @modules it returns: Archive::TarArchive::ZipArray::CompareAutoLoaderCPANCPAN::ChecksumsCPAN::DistnameInfo ...etc. I need: Archive::Tar Archive::Zip Array::CompareAutoLoaderCPAN CPAN::Checksums CPAN::DistnameInfo ...etc. I tried \n, '\n' and a 'foreach' loop, but nothing I do seems to work. ..any suggestions? Use the join' command to join the elements of the array with \n: perl -e use ExtUtils::Installed; my $inst = ExtUtils::Installed-new(); my @modules = $inst-modules(); print join \\n\,@modules, \n\ Yes, I tried 'join' also but ran into the following message on using more than 1 set of double quotes: String found where operator expected at -e line 1, at end of line (Missing semicolon on previous line?) Can't find string terminator '' anywhere before EOF at -e line 1. And, when I tried single quotes, I got: Backslash found where operator expected at -e line 1, near '\n\',@modules, '\ (Missing operator before \?) Backslash found where operator expected at -e line 1, near n\ syntax error at -e line 1, near '\n\',@modules, '\ Can't find string terminator ' anywhere before EOF at -e line 1. Ron Smith geeksatla...@yahoo.com -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
I'm trying to install 'Net::SSH::Perl' on a Windows Box.
Hi everyone, I'm trying to install 'Net::SSH::Perl' on a Windows Box. I'm reading from 'perldoc ppm'. First I did 'ppm search Net::SSH::Perl' and got Packages available from http://cpan.uwinnipeg.ca/PPMPackages/10xx: Net-SSH-Perl [1.30] Perl client interface to SSH Then I used the command: 'ppm install --location=http://cpan.uwinnipeg.ca/PPMPackages/10xx Net::SSH::Perl' and got Installing package 'Net-SSH-Perl'... Can't locate object method rvalidate via package PPM::XML::PPD::html at C:/strawberry/perl/site/lib/PPM.pm line 16 87. The package did not install so I googled this response but didn't come up with any clear-cut direction. ...any suggestions? I also ran accross the following while searching CPAN: Net::SSH::W32Perl MSWin32 compatibility layer for Net::SSH::Perl Is this also needed; does anyone know where I've gone astray? Ron Smith geeksatla...@yahoo.com -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
I'm sure this is a common question, but I can't find the solution.
Hello all, How do you print elements of an array, each on its own line, in a Windows' console? I'm doing the following: E:\My Documentsperl -e use ExtUtils::Installed; my $inst = ExtUtils::Installed-new(); my @modules = $inst-modules(); print @modules it returns: Archive::TarArchive::ZipArray::CompareAutoLoaderCPANCPAN::ChecksumsCPAN::DistnameInfo ...etc. I need: Archive::Tar Archive::Zip Array::CompareAutoLoaderCPAN CPAN::Checksums CPAN::DistnameInfo ...etc. I tried \n, '\n' and a 'foreach' loop, but nothing I do seems to work. ..any suggestions? Ron Smith geeksatla...@yahoo.com -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
I'd like to monitor a running script.
I'd like to monitor a running script and if the script stops running, restart it and continue to monitor it. I need a little help from the community on the ins-and-outs of the details. But, basically I need someone to look at the following code/pseudo-code and give suggestions. 1) Check a script running. 2) If it's running, sleep for 30 seconds then check again. 3) If it's not running, restart it and continue to check after that. This is on a Red Hat box, so the first thing would be something like: While (1) { my $process = `ps -ef | grep process name | grep -v grep`; if ($process) { sleep 30} else { exec (./process name) or print STDERR couldn't exec process name: $!; } } Ron Smith geeksatla...@yahoo.com (213)300-9448 -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Line ending with Gary^M on UNIX
--- Moon, John [EMAIL PROTECTED] wrote: Can someone please give me the octal values or a method of removing ^M from the end of an input line, if present? Thank you in advance jwm -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response I use the following command in vi. :1,$s/ctrl-v folllowed by ctrl-m// It's a simple substitution (of the whole file) where you literally hold down the keys indicated, at those spots in the substitution. Hope this helps. Ron Smith [EMAIL PROTECTED] Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: how to print \n in the output file
--- Mazhar [EMAIL PROTECTED] wrote: On 11/4/06, Mihir Kamdar [EMAIL PROTECTED] wrote: hi, I am a beginner in Perl. I am trying to automatically generate a perl test case file which, on executing, would return HTTP response code and response time,etc. In the output file that I am getting I want the following line: print \n ; Any Suggestions?? Would the following help? perl -e 'print \\n\n' Escape the backslash. This prints \n on a new line. Ron Smith [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Undefined subroutine Main::BadData called at line 42
Hi all, I get the error: Undefined subroutine Main::BadData called at line 42 when executing the following '.cgi' script, with nothing entered in all of the text fields. I'm unfamiliar with this error. Could someone give me an explaination behind this error? Here's the code: use strict; use warnings; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); print header(), start_html(Which Triangle Is It?); print p(This page tells you what type of triangle you've entered.), br(), A triangle with each side being equal is equilateral., br(), A triangle with two sides being equal is an isosceles triangle., br(), A right triangle is one where the square of one side is equal to, br(), the sum of the squares of the other two sides., br(); print br(); print 'FORM method=post action=pg250ex7.7_whichTriangle.pl'; print 'TABLE bgcolor=lightblue'; print Tr( td(Enter length of first side: ), td('INPUT type=text name=side1') ); print Tr( td(Enter length of second side: ), td('INPUT type=text name=side2') ); print Tr( td(Enter length of third side: ), td('INPUT type=text name=side3') ); print Tr( td('INPUT type=reset value=Clear'), td('INPUT type=submit value=Submit') ); print /TABLE/FORM; my $firstSide = param(side1); my $secondSide = param(side2); my $thirdSide = param(side3); if ($firstSide =~ /^(\d+)$/) { $firstSide = $1; if ($secondSide =~ /^(\d+)$/) { $secondSide = $1; if ($thirdSide =~ /^(\d+)$/) { $thirdSide = $1; if ($firstSide == $secondSide $firstSide == $thirdSide) { print p(That's an equilateral triangle!\n); } elsif ($firstSide == $secondSide || $firstSide == $thirdSide || $secondSide == $thirdSide) { print p(That's an Isosceles triangle!\n); } } } } else { BadData(); } sub BadInput { print p(Please, enter numbers only!); die Click the \Clear\ button and try again.\n; } print end_html(); TIA, Ron Smith [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Hi
--- Kaushal Shriyan [EMAIL PROTECTED] wrote: Hi All I am a novice to perl,I would like to learn perl in a systematic way, Whats the best way to start with,I dont have any experience of programming Language, But I came to know that perl is a Good Programming Language Try Learning Perl, Fourth Edition (Paperback) by Randal L. Schwartz, Tom Phoenix, brian d foy. Here's one of many links: http://www.amazon.com/gp/product/0596101058/sr=8-2/qid=1147704150/ref=pd_bbs_2/103-0184362-2216600?%5Fencoding=UTF8 Ron Smith Thanks Kaushal -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Local Server/Perl/HTML question...
--- Jim [EMAIL PROTECTED] wrote: I have just downloaded xitami and gotten it configured - I hope correctly - on my W2K professional system. I've installed PERL as well. I put a PERL .PL in c:\xitami\cgi-bin and tried running it by using my IE browser to run it. I'm sure the program runs as it creates three directories like it's supposed to, but I can't get the HTML to display the web page that it produces. Am I doing something wrong or ??? Why not use Apache for your web server? It is widely used, supported, tested, ... and of course it is free. you will have your cgi running in no time.. http://httpd.apache.org/docs/2.0/platform/windows.html -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response Can you send us code? Ron Smith [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Forcing order
--- Chris Devers [EMAIL PROTECTED] wrote: On Thu, 9 Mar 2006, Ron Smith wrote: How can I assure printing the correct order? You can't guarantee the order of keys in a hash per se. For efficiency and optimization, hashes are stored in a random order, unlike arrays, which do have a straightforward order. The trick then is to sort the hash keys. Instead of this: foreach ( keys( %values ) ) { Try this, or a variant on this: foreach ( sort keys( %values ) ) { You can get more sophisticated than this, but doing at least this much sorting on the keys should start producing consistent results. Yes, I had though of doing this, but wasn't sure if the values were being saved or accumulated. So, this brings me to a key concept I'm unclear on. Am I correct in saying that the values appended to $data are accumulated each time values are entered; therefore the values in %values are too? -- Chris Devers DO NOT LEAVE IT IS NOT REAL Ron Smith [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Forcing order
Hi all, I need a little insight on the following code, as I learn the CGI module. What's happening is, as the output to web page increases, with the number of entries, the order in which values are entered rearranges itself, when printing to the page. How can I assure printing the correct order? #!E:/www/perl/bin/perl.exe use strict; use warnings; use CGI qw( :standard ); use CGI::Carp qw( fatalsToBrowser ); my $gallonsUsed = param( gallons ); my $milesDriven = param( miles ); my $data = param( hidden ); $data .= $gallonsUsed ; $data .= $milesDriven ; print( header() ); print( start_html( -title = 'Miles Per Gallon' ) ); print Form; form method=post action=pg92ex3.10MilesPerGallon.pl strong Enter the gallons used: /strong input type=text name=gallonsbr strong Enter the miles driven: /strong input type=text name=milesbr input type=hidden name=hidden value=$data input type=submit value=Enter /form Form my %values = split( ' ', $data ); my $i = 0; my $totGals = 0; my $totMilesDriven = 0; my $average = 0; my $totAverage = 0; foreach ( keys( %values ) ) { $i++; $totGals += $_; $totMilesDriven += $values{ $_ }; $average = ( $values{ $_ } / $_ ); $totAverage = $totMilesDriven / $totGals; print( p( Trip: $ibr Gallons used: $_br Miles driven: $values{ $_ }br The miles per gallon for this trip were: $averagebr ) ); } print( p( strongTotal trips so far: $ibr Total gallons so far: $totGalsbr Total miles so far: $totMilesDrivenbr Total average so far: $totAverage/strong ) ); print( end_html() ); Thanks, Ron Smith [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Error in the if block
Sorry, my mistake, that should really be: my ( $smallestNum, $largestNum ) = ( sort { $a = $b } @numbers )[ 0, -1 ]; Although as I said, the for loop is more efficient. I just amazes me as to how *flexable* Perl is. Ron Smith [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Error in the if block
Sorry, my mistake, that should really be: my ( $smallestNum, $largestNum ) = ( sort { $a = $b } @numbers )[ 0, -1 ]; Although as I said, the for loop is more efficient. It just amazes me as to how *flexable* Perl is. Ron Smith [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Error in the if block
Hi all, This page accepts a series of numbers, separated by spaces, and gives the values listed bellow. I'm getting the following error, but don't see why. Can anyone spot my error? Please, enter numbers separated by spaces only!: Bad file descriptor at E:/www/cgi-bin/pg93ex3.11SeriesOfNumbers.pl line 14. I've narrowed the problem down to the if block (the regex), I'd like to accept numbers and spaces only. Here's the code: #!E:/www/perl/bin/perl.exe use strict; use warnings; use CGI qw( :standard ); use CGI::Carp qw( fatalsToBrowser ); print header(); my $userIn = param( textfield ); if ( $userIn =~ /^(\d+|\s*)$/ ) { $userIn = $1; } else { die Please, enter numbers separated by spaces only!: $!; } my @numbers = split( / /, $userIn ); my $total = scalar( @numbers ); my @sorted = sort( @numbers ); my $smallestNum = @sorted[0]; my $largestNum = @sorted[-1]; my $sum = 0; foreach ( @numbers ) { $sum += $_; } my $average = ( $sum / $total ); printHTML; html head titleSeries of Numbers/title style type=text/css !-- .style1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; } body,td,th { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; } -- /style /head This page accepts a series of numbers, separated by spaces, and gives the values listed bellow. form action= method=post name=form1 class=style1 id=form1 table width=448 border=0 tr td width=270div align=rightEnter your numbers here: /div/td td width=165input type=text name=textfield //td /tr tr td colspan=2 div align=center a href=http://mail.yahoo.com/config/login?/pg93ex3.11SeriesOfNumbers.html; Click here to go back! /a /div/td /tr tr tddiv align=rightThe total number of numbers entered is: /div/td td $total /td /tr tr tddiv align=rightThe smallest number is: /div/td td @sorted[0] /td /tr tr tddiv align=rightThe largest number is: /div/td td @sorted[-1] /td /tr tr tddiv align=rightThe sum of all the numbers is: /div/td td $sum /td /tr tr tddiv align=rightThe average of all the numbers is:/div/td td $average /td /tr /table /form /html HTML Ron Smith [EMAIL PROTECTED]
Re: Error in the if block
No information about the input that causes the error; are there also inputs not causing an error? Yes, the input expected would be: 32 11 25 or 32 11 25 or 32 11 25 ...etc. What you want is something like /^\s*((?:\d+\s*?)+)\s*$/ The inner (?:) does not capture output (see perldoc perlre), and the regex trims the input (which is allowed to contain leading and trailing space) This worked superbly for what I'm doing. :-) I found reference to ?: on page 204 of the Camel Book, but it isn't enough info to tell how to use it. I'm looking into 'perldoc perlre' righ now. Thanks, for giving me another resource. :-) The if-else could be shortened to (untested, so please check): die Bla unless ($userIn)=$userIn=~/^\s*((?:\d+\s*?)+)\s*$/; Right; a lot shorter. Why, the parentheses around $userIn? my @numbers = split( / /, $userIn ); This only splits on a single space character. my @numbers = split /\s+/, $userIn; splits (explicitly) on the same whitespace allowed in the regex above. I changed this too. Thanks, Hans! [irrelevant parts snipped away] Ron Smith [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Error in the if block
--- John W. Krahn [EMAIL PROTECTED] wrote: Your problem is that you are using the $! variable: But you are using it for a pattern match failure which is neither a system nor a library call. my @numbers = split( / /, $userIn ); I would write that as: my @numbers = $userIn =~ /\d+/g; @numbers or die Please, enter numbers separated by spaces only!; Yep. Actually, I had already followed your suggestion, with the addition of \n. But, it was to get rid of the fact that $! was spitting out the file name. Thanks, for an explaination behind the *real* reason I should make the change. my $total = scalar( @numbers ); my $total = forces scalar context so using the scalar() function is redundant. Thanks, I shortened this up too; scalar function gone. [pg. 73 Camel Book] But since you are sorting numbers, you probably want to do a numeric sort to get the correct numbers: my ( $smallestNum, $largestNum ) = sort { $a = $b } @numbers; I'm using: my @sorted = sort { $a = $b } @numbers; Thanks, again. [pg. 790 Camel Book] This was overlooked in my haste. my $sum = 0; foreach ( @numbers ) { $sum += $_; } my $average = ( $sum / $total ); You could just use the array there as a mathematical expression forces scalar context: my $average = ( $sum / @numbers ); This is bookmarked for future reference. Thanks, a lot John. :-) Ron Smith [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Error in the if block
--- John W. Krahn [EMAIL PROTECTED] wrote: Ron Smith wrote: Hans Meier (John Doe) wrote: The if-else could be shortened to (untested, so please check): die Bla unless ($userIn)=$userIn=~/^\s*((?:\d+\s*?)+)\s*$/; Right; a lot shorter. Why, the parentheses around $userIn? Context. Without the parentheses you have scalar context but with the parentheses you have list context. In scalar context the match operator returns 'true' or 'false' but in list context it returns the contents of all capturing parentheses in the pattern. Thanks. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response Ron Smith [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
How do I redirect STDIN
Hi all, How would I redirect the output of the print line to an array instaed of STDOUT? my $firstBar = 5; print * while $firstBar, $firstBar--; I've looked in several places, including the Camel Book and the Cookbook. Everything seems to be refering to a filehandle instead. ...any suggestions?? Ron Smith [EMAIL PROTECTED]
Redirecting STDOUT to an array
Hi all, How would I redirect the output of the print line to an array instaed of STDOUT? my $firstBar = 5; print * while $firstBar, $firstBar--; I've looked in several places, including the Camel Book and the Cookbook. Everything seems to be refering to a filehandle instead. ...any suggestions?? Ron Smith [EMAIL PROTECTED]
Re: How do I redirect STDIN [Please, ignore this thread]
Please, ignore this thread!! I've posted the correct thread under the subject: Redirecting STDOUT to an array. Ron Smith [EMAIL PROTECTED] wrote: Hi all, How would I redirect the output of the print line to an array instaed of STDOUT? my $firstBar = 5; print * while $firstBar, $firstBar--; I've looked in several places, including the Camel Book and the Cookbook. Everything seems to be refering to a filehandle instead. ...any suggestions?? Ron Smith [EMAIL PROTECTED] Ron Smith [EMAIL PROTECTED]
Re: Redirecting STDOUT to an array
Sky Blueshoes [EMAIL PROTECTED] wrote: Ron Smith wrote: Hi all, How would I redirect the output of the print line to an array instaed of STDOUT? my $firstBar = 5; print * while $firstBar, $firstBar--; I've looked in several places, including the Camel Book and the Cookbook. Everything seems to be refering to a filehandle instead. ...any suggestions?? Ron Smith [EMAIL PROTECTED] No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.375 / Virus Database: 267.15.6/257 - Release Date: 2/10/2006 If you want to assign something to an array, you do just that. @array = $firstBar; if you want to print to a file, you need to open a filehandle open (FILE, firstbar.txt); and then print to it: print FILE * while $firstBar, $firstBar--; -- SkyBlueshoes http://skyblue.fulllifeministries.org [EMAIL PROTECTED] Intel Pentium D 920 2.8Ghz w/ 1GB PC4200 DDR2 SDRAM Maxtor 114GB Maxtor 150GB HP dvd635 DVD combo recorder XFX GeForce 7800GT overclocked w/ 256 DDR3 Intel 945p chipset w/ 8ch Audio Microsoft Windows XP Professional (Service Pack 2) Yes, you are right. I probably should post the rest of the story at this point: I'm taking numerical values from a web page: my $firstBar = param( textfield ); and I'd like to generate a row of asterisks, based on the number stored in $firstBar. I thought of printing to a file then splitting the contents to an array, but I was wondering if there was a more direct way. Ron Smith [EMAIL PROTECTED]
Re: Redirecting STDOUT to an array
Tom Phoenix [EMAIL PROTECTED] wrote: On 2/12/06, Ron Smith wrote: How would I redirect the output of the print line to an array instaed of STDOUT? my $firstBar = 5; print * while $firstBar, $firstBar--; You would write some Perl code that puts something into an array, and you would use that in place of the print statement. (And what's with that conditional? Did you mean to use the scalar comma operator?) I'm not sure, but you may want something like this: push @data, * while $firstBar--; But it occurs to me that you may be saying that you've already got a program with print statements scattered throughout, and you want those print statements to magically chuck the output data into an array (of lines? of characters?). This could be done with a tied filehandle. Have you looked for a module on CPAN? http://search.cpan.org/ Hope this helps! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The push worked fine. Thanks. Ron Smith [EMAIL PROTECTED]
Re: Redirecting STDOUT to an array
Tom Phoenix [EMAIL PROTECTED] wrote: Inexplicably, Ron Smith seems to have written: Yes, you are right. I probably should post the rest of the story at this point: and I'd like to generate a row of asterisks, based on the number stored in $firstBar. I thought of printing to a file then splitting the contents to an array, but I was wondering if there was a more direct way. Then why the goto didn't you say that in the first place? my $starbar = '*' x $firstBar; Row of asterisks, as requested. And just in time, because it allows me to call you a *** without using any additional vulgarity. (No insult intended, I'm just venting.) --Tom Phoenix Stonehenge Perl Training Yeah, I deserve it. Giving the whole story in the beginning would have been better. But, hey I'm JAPH and laziness is a virtue in that case. :-) Anyway the push does just fine. Thanks, Tom. Ron Smith [EMAIL PROTECTED]
Stuck on last step
Hi all, I've got a CGI script that takes two strings and sorts them in order, then prints them. The problem is I don't want nulls or numbers entered. I think I've got the null end of it right, but I'd also like to error-out any numbers entered. Take a look at the unless line. ...any suggestions?? #!E:/www/perl/bin/perl.exe use strict; use warnings; use CGI qw( :standard ); use CGI::Carp qw( fatalsToBrowser ); print header(); my $firstString = param( textfield ); my $secondString = param( textfield2 ); my @list = sort ( $firstString, $secondString ); unless ( $firstString $secondString /\w+/ ) { printHTML; html body p This page takes two strings from the user and prints them in alphabetical order. If they are equal, they will print on separate lines. /p form name=form1 id=form1 method=post action=../webroot/cgi-bin/pg59ex2.11SortStrings.pl table width=341 border=0 tr td width=181div align=rightEnter your first string: /div/td td width=144input type=text name=textfield //td /tr tr tddiv align=rightEnter your second string: /div/td tdinput type=text name=textfield2 //td /tr tr td colspan=2div align=centerfont color=red Please, enter two words! /font/div/td/td /tr tr td colspan=2div align=centera href=/pg59ex2.11SortStrings.html Click here to go back /a/div/td /tr /table /form pnbsp;/p /body /html HTML } elsif ( $firstString eq $secondString ) { printHTML; html body pThis page takes two strings from the user and prints them in alphabetical order. If they are equal, they will print on separate lines./p form name=form1 id=form1 method=post action=../webroot/cgi-bin/pg59ex2.11SortStrings.pl table width=341 border=0 tr td width=181div align=rightEnter your first string: /div/td td width=144input type=text name=textfield //td /tr tr tddiv align=rightEnter your second string: /div/td tdinput type=text name=textfield2 //td /tr tr td colspan=2div align=center $firstStringbr$secondString /div/td/td /tr tr td colspan=2div align=centera href=/pg59ex2.11SortStrings.html Click here to go back /a/div/td /tr /table /form pnbsp;/p /body /html HTML } else { printHTML; html body pThis page takes two strings from the user and prints them in alphabetical order. If they are equal, they will print on separate lines./p form name=form1 id=form1 method=post action= table width=341 border=0 tr td width=181div align=rightEnter your first string: /div/td td width=144input type=text name=textfield //td /tr tr tddiv align=rightEnter your second string: /div/td tdinput type=text name=textfield2 //td /tr tr td colspan=2div align=center @list /div/td /tr tr td colspan=2div align=centera href=/pg59ex2.11SortStrings.html Click here to go back /a/div/td /tr /table /form pnbsp;/p /body /html HTML } Ron Smith [EMAIL PROTECTED]
Re: On Focus
John, Thanks for the explanation. It's clarified things for me. I'll be searching CPAN for a solution, as you suggested. Thanks, again Ron John Doe [EMAIL PROTECTED] wrote: On 2/5/06, Ron Smith wrote: Hi all, I've been looking for this all over, but can't seem to find a link. Is there a Perl or PerlScript equivalent to the JavaScript or vbscript on-focus function? If there is, could someone please, point me in the right direction. Omega -1911 [EMAIL PROTECTED] wrote: Can you tell us what exactly it is that you are trying to do? Ron Smith am Montag, 6. Februar 2006 01.35: Yes, I'm trying to have the blinking cursor start in a specific text field, on a web page, when the page loads in the browser. Hi Ron There is no such thing as a perl equivalent for the javascript onfocus attribute. Javascript handlers are interpreted by the javascript engine of a browser, based on the definition of this attribute and its associated javascript handler code, both defined in the (x)html code. Perl on the other side is a script language that can be interpreted by the server (via cgi, modperl etc.) to produce html page source code - but can not be given to the browser to be interpreted by it. What you want probably is something that produces the onfocus attribute on the server side, along with producing the html code. There are lots of modules on search.cpan.org that help to produce html source and even javascript code. Check out the CGI module, http://search.cpan.org/~lds/CGI.pm-3.15/CGI.pm, and search for the word javascript. hth, joe -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Ron Smith [EMAIL PROTECTED]
On Focus
Hi all, I've been looking for this all over, but can't seem to find a link. Is there a Perl or PerlScript equivalent to the JavaScript or vbscript on-focus function? If there is, could someone please, point me in the right direction. Thanks, Ron Ron Smith [EMAIL PROTECTED]
Re: On Focus
Yes, I'm trying to have the blinking cursor start in a specific text field, on a web page, when the page loads in the browser. Thanks, Ron Omega -1911 [EMAIL PROTECTED] wrote: On 2/5/06, Ron Smith wrote: Hi all, I've been looking for this all over, but can't seem to find a link. Is there a Perl or PerlScript equivalent to the JavaScript or vbscript on-focus function? If there is, could someone please, point me in the right direction. Thanks, Ron Ron Smith [EMAIL PROTECTED] Can you tell us what exactly it is that you are trying to do? Ron Smith [EMAIL PROTECTED]
Error on: my $sth-execute;
Hi all, I'm getting an error when trying to do an INSERT statement to a MySQL database. There's something I'm not understanding here. Can anyone point me in the right direction? I also tried a do method, but got the same error. I know the param function is loading the values from the form, because I've used a print statement to check the variables. TIA Ron -snip--- Software error: Can't call method execute on an undefined value at C:/www/cgi-bin/load_company_products.cgi line 21. For help, please send mail to the webmaster ([EMAIL PROTECTED]), giving this error message and the time and date of the error. -snip--- #!/www/perl/bin/perl -wT use strict; use DBI; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); my $sku = param('sku'); my $partNum = param('partNum'); my $name = param('name'); my $descr = param('descr'); my $stockNum = param('stockNum'); my $qty = param('qty'); my $img = param('img'); my $vendNum = param('vendNum'); my $price = param('price'); my $dbh = DBI-connect(DBI:mysql:company, username, password) or die Error: $DBI::errstr\n; my $sql = INSERT INTO products VALUES ('$sku', '$partNum', '$name', '$descr', '$stockNum', '$qty', '$img', 'vendNum', '$price'); my $sth = $dbh-prepare($sql); my $sth-execute; =line 21 $dbh-disconnect; #my $sth-do(INSERT INTO products VALUES ('$sku', '$partNum', '$name', '$descr', '$stockNum', '$qty', '$img', 'vendNum', '$price')); snip---
Re: Error on: my $sth-execute;
--- Lawrence Statton [EMAIL PROTECTED] wrote: --0-551411304-1121705388=:507 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi all, I'm getting an error when trying to do an INSERT statement to a MySQL databas e. There's something I'm not understanding here. Can anyone point me in the r ight direction? I also tried a do method, but got the same error. I know th e param function is loading the values from the form, because I've used a print statement to check the variables. TIA Ron -snip--- Software error: Can't call method execute on an undefined value at C:/www/cgi-bin/load_comp any_products.cgi line 21. For help, please send mail to the webmaster ([EMAIL PROTECTED]), giving this er ror message and the time and date of the error. -snip--- 1) Your first mistake is never checking for any errors; my $dbh = DBI-conect(...) or die ...helpful error message...; I was using: my $dbh = DBI-connect(DBI:mysql:company, geeksatlarge) or die Error: $DBI::errstr\n; but will try: die no database: , DBI-errstr unless $DBH; Thanks! Perhaps ESPECIALLY interesting would be around line 20 adding something of the form my $sth = $dbh-prepare($sql) or die There is no statement handle because: , $dbh-errstr; Yep! I saw a lot of mail on this one. I'm removing the extra my. It was an oversight. :-) 2) Use placeholders. REALLY -- where the [EMAIL PROTECTED] are people learning to write SQL? 3) I have a personal bias against the format of insert you have used, and it makes it utterly impossible to help debug your code because now a critical piece of data ( the output of a DESCRIBE products) is invisible to us. I always prefer the INSERT INTO table ( col, col, col ) VALUES ( ?, ? , ? ) ; form as it handles much more gracefully the addition of columns in a table. Yes, the though had crossed my mind to use this format, so I'm switching over; also, using placeholders. I won't be able to test any corrections until tonight or tomorrow though. Thanks, to everyone on the list for help while I'm in Perl/CGI infancy. ;-) Ron Smith #!/www/perl/bin/perl -wT use strict; use DBI; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); my $sku = param('sku'); my $partNum = param('partNum'); my $name = param('name'); my $descr = param('descr'); my $stockNum = param('stockNum'); my $qty = param('qty'); my $img = param('img'); my $vendNum = param('vendNum'); my $price = param('price'); my $dbh = DBI-connect(DBI:mysql:company, username, password) or die Error: $DBI::errstr\n; my $sql = INSERT INTO products VALUES ('$sku', '$partNum', '$name', '$descr', '$stockNum', '$qty', '$img', 'vendNum', '$price'); my $sth = $dbh-prepare($sql); my $sth-execute; =line 21 $dbh-disconnect; So, let's build a test script that includes all of the things I mentioned. -- cut here #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use DBI; our $DBH = DBI-connect( 'dbi:mysql:dbname=test', undef , undef ); die no database: , DBI-errstr unless $DBH; # version for running in CGI #my ($sku, $partNum, $name, $descr, $stockNum, #$qty, $img, $vendNum, $price) = map { param($_) } qw / sku partNum name descr stockNum qty img vendNum price /; # # brute force for testing # my $sku = '123456'; my $partNum = '501-1627'; my $name = 'TGX Frame Buffer'; my $descr = 'Sun TGX frame buffer; CG6'; my $stockNum = 'A-102-55'; my $qty = 10; my $img = undef; my $vendNum = '5011627'; my $price = '12.75'; my $sql = qq { INSERT INTO product ( sku, partNum, name, descr, stockNum, qty, img, vendNum, price ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ? ) }; my $sth = $DBH-prepare($sql); die No statement handle: , $DBH-errstr unless $sth; my $rv = $sth-execute( $sku, $partNum, $name, $descr, $stockNum, $qty, $img, $vendNum, $price ); doe Something was wrong: , $sth-errstr unless defined $rv; print JOY; $DBH-disconnect; -- cut here This works. By the way, in copying your program I found your bug. Look lin line 20 and it should stand out. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: error with -T taint checking
--- Chris Devers [EMAIL PROTECTED] wrote: On Mon, 11 Jul 2005, Ron Smith wrote: Insecure dependency in open while running with -T switch at C:/www/cgi-bin/upload_save.cgi line 42. What do you see on line 42? It seems to be in Store_Results(): sub Store_Results{ my $data; my $mime = uploadInfo($file_name)-{'Content-Type'}; open (STORAGE, $directory/$file) or die Error: $directory/$file: $!\n; # line 42== if ($mime !~ /text/) { binmode ($file_name); binmode (STORAGE); } while (read($file_name, $data, 1024)) { print STORAGE $data; } close STORAGE; } In other words, it chokes when you try to write to the dynamically selected file, $directory/$file. Unfortunately, this is exactly the sort of thing that taint mode is supposed to be catching. Read the perldoc on it for details: From the command line, if available: $ perldoc perlsec Or read it from perldoc.perl.org: http://perldoc.perl.org/perlsec.html Hope this helps clarify things. * ** *** * *** *** * * On an entirely unrelated note, if you get in the habit of consistently indenting your code now, you'll be *much* happier a year or five from now when you're trying to maintain code you wrote when you started out. I agree and have taken your advice. I've also turned off color and graphics in my messages, so I can post replies where needed, instead of top posting. :-) Here's how I might have written the subroutine in question: sub Store_Results{ my ( $file_name, $directory, $file ) = @_; my $data; my $mime = uploadInfo($file_name)-{'Content-Type'}; open (STORAGE, $directory/$file) or die Error: $directory/$file: $!\n; line 42== if ($mime !~ /text/) { binmode ($file_name); binmode (STORAGE); } while (read($file_name, $data, 1024)) { print STORAGE $data; } close STORAGE; } Note also that I explicitly pulled in arguments, rather than using globals. This will mean changing the sub call to Store_Results( $file_name, $directory, $file ); but writing it that way will also just serve to clarify things and make it easier to maintain the program when you look at it again years later. I also took you suggestion here too. I does make things more clear and understandable. I still get the error with the -T switch though, so I'll check out the suggested reading. Thanks Chris Ron * ** *** * *** *** * * You don't have to follow the details of how I'm doing this if you don't want to, but at least choose some conventions and stick to them. Doing so will, I promise, save you headaches in the long run :-) -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Files uploading with 0kb size
Hi all, I'm back on the list with another upload problem that's a little baffling to me. I'm using the following script to do multiple uploads. But, after the files are uploaded, they have a file size of 0 KB. And, in the case of text files, the contents of the files are missing. ...anyone familiar with this problem? The script appears to work fine; no errors. But the files are zero size with no contents. It looks to me that the script is not uploading the actual file, but merely writing the file name to disk in the form of an empty file. ...not sure where to start looking on this one. Does anyone have any pointers? TIA Ron ---snip- #!/www/perl/bin/perl -w use strict; use DBI; use File::Basename; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); my $directory = C:/www/webroot/storage; my $url_path = /storage; my @file_names = param('filename'); my @descriptions = param('description'); my @file_array = (); $CGI::POST_MAX = 1024 * 1500; # limit uploads to 1500kb of all files combined Get_Names(); Store_Descriptions(); Print_Results(); sub Get_Names{ my $counter = 0; my $full_name; my $file_name; foreach $full_name (@file_names) { my $rec = {}; if ($full_name ne ) { $file_name = Get_File_Name($full_name); $rec-{file_name} = $file_name; $rec-{full_name} = $full_name; $rec-{description} = $descriptions[$counter]; push @file_array, $rec; Store_File($full_name, $file_name); } $counter++; } } sub Store_Descriptions{ my $temp; my $DBH = DBI-connect(DBI:mysql:book, geeksatlarge); my $sth_insert = $DBH-prepare(qq{INSERT INTO files (Description, FileName) VALUES (?,?)}) or die $DBH-errstr; foreach $temp (@file_array) { $sth_insert-execute($temp-{description}, $temp-{file_name}); } $DBH-disconnect; } sub Get_File_Name{ if ($ENV{HTTP_USER_AGENT} =~ /win/i) { fileparse_set_fstype(MSDOS); } elsif ($ENV{HTTP_USER_AGENT} =~ /mac/i) { fileparse_set_fstype(MacOS); } my $full_name = shift; $full_name = basename($full_name); $full_name =~ s!\s!\_!g; return($full_name); } sub Store_File{ my $file_handle = shift; my $file_name = shift; my $data; my $mime = uploadInfo($file_handle)-{'Content-Type'}; open (STORAGE, $directory/$file_name) or die Error: $!\n; if ($mime !~ /text/) { binmode ($file_name); binmode (STORAGE); } while (read($file_name, $data, 1024)) { print STORAGE $data; } close STORAGE; } sub Print_Results{ my $temp; print header; print start_html(File Upload Example 4); print h2(The following files were uploaded:); foreach $temp (@file_array) { my $link = $url_path/$temp-{file_name}; print HTML; pre bFile Name:/b $temp-{file_name} bDescription:/b $temp-{description} pbLink to File:/b a href=$link$link/a/p /pre HTML } print qq(\na href=/cgi-bin/upload_multi_save_view.cgiView Files/a); print end_html; }
error with -T taint checking
Hi all, I'm back again with another question. And, thanks for your previous help. This time I'm working my wat through the book Writing CGI applications with Perl. There's a tutorial that I've done that involves uploading a file and inserting the file name and description in MySQL. Some of you may be familiar with this one. Anyway, I get an error on the upload part when -T is used: #!/www/perl/bin/perl -wT. When it's removed, guess what? No error. I would like to know if anyone on the list can take a look at the following script, and maybe explain why this happens. The error points to line 42. There's no explaination in the book of course. TIA Ron Software error: Insecure dependency in open while running with -T switch at C:/www/cgi-bin/upload_save.cgi line 42. For help, please send mail to the webmaster ([EMAIL PROTECTED]), giving this error message and the time and date of the error. snip--- #!/www/perl/bin/perl -wT use strict; use DBI; use File::Basename; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); my $directory = C:/www/webroot/storage; my $url_path = /storage; my $file_name = param('filename'); my $description = param('description'); my $file = Get_File_Name($file_name); $CGI::POST_MAX = 1024 * 250; # limit uploads to 250kb Store_Results(); Store_Description(); Print_Results(); sub Store_Description{ my $dbh = DBI-connect(DBI:mysql:book,geeksatlarge); my $sth_insert = $dbh-prepare(qq{insert into files (Description,FileName) values (?,?)}) or die $dbh-errstr; $sth_insert-execute($description,$file); $dbh-disconnect; } sub Get_File_Name{ if ($ENV{HTTP_USER_AGENT} =~ /win/i) { fileparse_set_fstype(MSDOS); } elsif ($ENV{HTTP_USER_AGENT} =~ /MAC/i) { fileparse_set_fstype(MacOS); } my $full_name = shift; $full_name = basename($full_name); $full_name =~ s!\s!\_!g; return($full_name); } sub Store_Results{ my $data; my $mime = uploadInfo($file_name)-{'Content-Type'}; open (STORAGE, $directory/$file) or die Error: $directory/$file: $!\n; # line 42== if ($mime !~ /text/) { binmode ($file_name); binmode (STORAGE); } while (read($file_name, $data, 1024)) { print STORAGE $data; } close STORAGE; } sub Print_Results{ my $link = $url_path/$file; print header; print start_html('File Upload And Save'); print HEREDOC; pre bFile Sent: /b$file_name bFile Name: /b$file bLink to File: /ba href=$link$link/a a href=/cgi-bin/viewfiles.cgiView Files/a /pre HEREDOC print end_html; } snip---
Re: Form / CGI error
--- Chris Devers [EMAIL PROTECTED] wrote: On Wed, 6 Jul 2005, Ron Smith wrote: I'm getting an error when I submit the following html form to a CGI script. Let's focus on the script, not the HTML. Once you've verified that the script works, at least on a basic level -- i.e. you can go to http://your-site/cgi-bin/your-script.cgi and get back a non-error response -- *then* you can start thinking about the HTML. #!/www/perl/bin/perl -wT use strict; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); print header; print CORE::dump(); # = This line was originaly: print dump(); Okay, hold that thought... -snip-3-From the browser--- Internal Server Error This continues to be useless. It's a generic error response from the web server; it indicates nothing about what the actual problem was. That said, with CGI::Carp's fatalsToBrowser, you should be getting useful diagnostics in the web server response. Maybe it's hidden in a comment or something, I don't know. In any case, the response you pasted doesn't have any useful information in it, just as it didn't when you pasted it to the list a few days ago :-) --snip-4-From the error log-- [Wed Jul 06 18:23:56 2005] [error] [client 127.0.0.1] Premature end of script headers: form4-21.cgi, referer: http://localhost/form4-21.html Okay, now we're getting somewhere. Premature end of script headers is generally a tell-tale sign that the CGI script never sent back the mandatory content-type declaration. I'm not clear why this isn't working, as the `print header;` line you have should do this, but in any case you can ignore CGI.pm for a moment and just put the needed line in directly, like so: #!/www/perl/bin/perl -wT use strict; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); print Content-type: text/plain\n\n; print Okay, at least this worked.\n; If the code above works, then you can amend it to use your CORE line: #!/www/perl/bin/perl -wT use strict; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); print Content-type: text/plain\n\n; print CORE::dump(); Now then, why on earth are you trying to dump core? This was just an exercise out of a book. I gave your suggestion a try and worked through the lines and got it to work. I still get the error with 'dump()' though. I finally moved on to the following, whiched worked fine: #!/www/perl/bin/perl -wT # use strict; use CGI qw(:standard); # use CGI::Carp qw(fatalsToBrowser); print header; my $first_name = param('fname'); my $last_name = param('lname'); my $fav_color = param('color'); print qq(Hello, $first_name $last_name.br /); print qq(Your favorite color is: $fav_colorbr /); Thanks for the suggestion. :-) Ron If you just want to output the environment, this is a clumsy way to do it. Something like this would work just fine: #!/www/perl/bin/perl -wT use strict; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); print Content-type: text/plain\n\n; print Environment variable dump:\n; foreach $key ( sort keys %ENV ) { print $key: $ENV{$key}\n; } That should work, and as it isn't dumping core, it might even behave :-) -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re-starting Apache
Hi everyone, My OS stats are: Apache/2.0.52 (Win32) PHP/4.3.10 mod_perl/1.99_18 Perl/v5.8.6 Server at localhost Port 80 This is running on Win XP Pro. When I try to create a user-defined ENV variable in 'httpd.conf', I'm unable to do a re-start of Apache. The server just won't come back up untill I've removed the offending lines. Does anyone know of a workaround? TIA Ron
Internal Server Error
Hi all, I'm running: 'http://localhost/html/inputForm.html' which takes a first name and last name, and submits them to 'http://localhost/cgi-bin/query_string.cgi I get a the following error: -snip-1--- Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, [EMAIL PROTECTED] and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Apache/2.0.52 (Win32) PHP/4.3.10 mod_perl/1.99_18 Perl/v5.8.6 Server at localhost Port 80 -snip-1--- The form settings are the following: form name=form1 id=form1 method=get action=query_string.cgi The values of the URL are: http://localhost/html/query_string.cgi?fname=Ronlname=Smithsubmit=Submit I did some moving of the files to get this to work but the '.cgi' file prints the underlying code from the above location. And, if I put both pages in the 'cgi-bin' directory, the .html page throws the following browser error; -snip-2--- Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, [EMAIL PROTECTED] and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Apache/2.0.52 (Win32) PHP/4.3.10 mod_perl/1.99_18 Perl/v5.8.6 Server at localhost Port 80 -snip-2--- Following is the code to the CGI script: #!//perl/bin/perl.exe -wT # input will be coming from inputForm.html use strict; use CGI qw(cgi); use CGI::Carp qw(fatalsToBrowser); print content-type: text/html\n\n; my %form; my @pairs = split(//, $ENV{'QUERY_STRING'}); foreach (@pairs) { my ($name, $value) = split(/=/, $_); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg; $form{$name} = $value; } print HTML; html headtitle Output Form /title/head body centerh3 Form Output /h3/centerp/p HTML foreach (keys %form) { print $_ = %form{$_}br; } print HTML; /body /html HTML Does anyone have any advice as to how to get this script to accept values from a .html page. It's probably something I'm unaware of. I'm just starting to get into CGI scripts. I've since found a script that delivers what I want: -snip-3--- #!/www/perl/bin/perl.exe -wT use strict; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); my $first_name = param('fname'); my $last_name = param('lname'); print header, start_html('Form Output'), h3({-align='center'}, 'Form Output'), p; print $_ . - . param($_) . br foreach param; print end_html; -snip-3--- TIA Ron
Re: error in building perl module--hopefully not OT
Jim Garvin [EMAIL PROTECTED] wrote: Ron Smith wrote: Hmmm..., I'm attempting to build and install a perl module on a Win XP box using the free version of Borland C++ Builder 6. I seem to have run into a snag. Here are the particulars: ... make install --returned the following error in the DOS shell: MAKE Version 5.2 Copyright (c) 1987, 2000 Borland Can't find string terminator @ anywhere before EOF at -e line 1. Does anyone out there have any experience with this error message? TIA Ron Smith I'm pretty sure it has to do w/ command line quoting in windows versus command line quoting in *nix. Anytime I'm forced to do anything on windows, I cringe at the common practices I'm going to have to suspend in order to get the job done. Well, what module is it? If it's not a public module, what's the makefile look like? This part sucks, because we are looking at things that we are supposed to not have to think about. Hopefully someone pops in with a magical answer before we dive in. We are probably going to have to use single-quotes instead of double-quotes, or change a quote operators (q// qq//) funny character, or something like that. Just guessing. --jim
error in building perl module--hopefully not OT
Hmmm..., I'm attempting to build and install a perl module on a Win XP box using the free version of Borland C++ Builder 6. I seem to have run into a snag. Here are the particulars: perl Makefile.PL --executed OK make--seems to have executed OK, it gave the following in the DOS shell: MAKE Version 5.2 Copyright (c) 1987, 2000 Borland make test --returned the following in the DOS shell: MAKE Version 5.2 Copyright (c) 1987, 2000 Borland C:\Perl\bin\perl.exe -MExtUtils::Command::MM -e test_harness(0, 'blib\lib', 'blib\arch' t\given.t t\nested.t t\switch.t t\given.ok t\nestedok t\switchok All tests successful. Files=3, Tests=590, 2 wallclock secs ( 0.00 cusr + 0.00 csys = 0.00 CPU) make install --returned the following error in the DOS shell: MAKE Version 5.2 Copyright (c) 1987, 2000 Borland Can't find string terminator @ anywhere before EOF at -e line 1. Does anyone out there have any experience with this error message? TIA Ron Smith
select case or switch statement
Does Perl have the equivalent of a case statement or a switch statement. I'm trying to avoid a bunch of if-then statements. I'm seeing posts regarding use switch, but I want to make sure it's not a deprecated practice. I'm using Perl -v 5.8.0. my $day; if ($day = mon) { $num = 0; } if ($day = tue) { $num=1; } ...etc. I'll be using $num, as an index, to extract a value from an array later on. TIA, Ron
Re: select case or switch statement
I used 'perldoc -f switch' and nothing came up. I've done what you suggested and I'm on my way. Thank you very much. R Ing. Branislav Gerzo [EMAIL PROTECTED] wrote: Ron Smith [RS], on Saturday, June 11, 2005 at 14:11 (-0700 (PDT)) has on mind: RS Does Perl have the equivalent of a case statement or a switch RS statement. I'm trying to avoid a bunch of if-then statements. RS I'm seeing posts regarding use switch, but I want to make sure RS it's not a deprecated practice. I'm using Perl -v 5.8.0. How you would definde your question ? it is about switch So, give this question (-q) to perl documentation (perldoc) with keyword switch. I did, and found an answer, how about you ? perldoc -q switch -- ...m8s, cu l8r, Brano. [Brilliant... Genius... Best message of 1993! -- N.Y. Times] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Can I safely ignore this error?
Using the following input on a Window$ OS: filename.0001.ext filename.0002.ext filename.0003.ext filename.0004.ext filename.0005.ext And, the following script: #!/usr/bin/perl -w use strict; print \nThis program will change the file name(s) for you.\n\n; print What's the current base name?: ; chomp ( my $name = STDIN ); print What's the current extention?: ; chomp ( my $ext = STDIN ); my @old_names = ( glob $name.*.$ext ); print \nThe following is your selection: . $old_names[0] - (, ++$#old_names, frames).\n\n; print Type in the new basename and hit \Enter\: ; chomp ( my $new = STDIN ); if ( $new eq ) { print \nYou must enter a name!\n\n; die rename did not occur: $!; } else { for ( @old_names ) { next unless /^$name\.(\d+)\.$ext$/; my $pad = $1; rename $_, sprintf $new.%04d.$ext, $pad; } } I get the following error: Use of uninitialized value in pattern match (m//) at line 26, STDIN line 3. The script gives no errors with 'warnings' turned off. Can I safely ignore this error? __ Do you Yahoo!? All your favorites on one personal page Try My Yahoo! http://my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Using 'rename' on the command line
I'm trying to rename some files from the command line but nothing gets changed. I think I'm leaving out something; maybe '$_'. Or, I have incorrect syntax. I don't get any error message either. I took a look at 'man rename', but it doesn't show an example of a loop. I'm using the following on the command-line: perl -e 'for (`ls -1`) { rename filename, newfilename if /\w+$/}' Can anyone show me the error of my ways? - Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com
Re: Extracting Directories and Sub Directories and Counting
--- Gunnar Hjalmarsson [EMAIL PROTECTED] wrote: Ron Smith wrote: If I wanted to add more fields to my output, which construct would I use to create more fields; something like the following? basenamecountextensionsize ...maybe 'HoH', or just expand on the 'HoA? I suppose that you are not really talking about the output now, but rather about adding more info to the data structure. Anyway, it depends on what you would like to use it for. I imagine that you might want a HoAoH with each file being represented by a hash reference. Something like: my %HoAoH = ( dir1 = [ { basename = 'name1', extension = 'html', size = 1000, }, ], dir2 = [ { basename = 'name2', extension = 'html', size = 2000, }, { basename = 'name3', extension = 'gif', size = 1500, }, ], ); -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl This looks closer to what I was refering to. But I didn't even know you could do this. I've been away from this thread a couple of days mulling over 'perlref' and 'perlreftut'. I've also picked up a copy of Learning Perl Objects, References Modules. Hey, I just recently discovered this book was out there. I think I'd better go through this material and what you've given me above, before I proceed any futher with this thread. Thanks, everybody, for your help; and especially Gunnar. I'll be back with other questions regarding references after I've done further homework. :) Ron __ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Extracting Directories and Sub Directories and Counting
Pardon me Gunnar, etal, I'm new and thought that the 'comp.lang.perl.misc' post was entirely separate from '[EMAIL PROTECTED]', reaching an entirely different audience. I eanestly appologize to everyone on both lists. My bad!! I have spanked my own hand with a digital ruler. I'll do my best not to let that occur again. I'm new, and some of the things I learn come the hard way. Again, my sincere appologies folks. I'll be reading the 'crospost' page to get the rules. Is there anything other than that, that I can do to straighten things out? Pardon the confusion. Ron Gunnar Hjalmarsson [EMAIL PROTECTED] wrote: Ron Smith wrote: If I wanted to add more fields to my output, which construct would I use to create more fields; something like the following? basename count extension size ...maybe 'HoH', or just expand on the 'HoA? You multi-posted basically the same question to comp.lang.perl.misc (see below). Any comments on that, Ron? Original Message Subject: Re: Extracting Directories and Sub Directories and Counting Date: Tue, 02 Nov 2004 13:40:21 +0100 From: Gunnar Hjalmarsson Newsgroups: comp.lang.perl.misc References: Ron Smith wrote: gives me: file_base_name file_count in two columns. How would I add additional columns like: file_base_name file_count File_extension file_size Which construct would I use? Would it be a 'HoH', or simply expand on a 'HoA', or is it another construct like 'AoA' or AoH? I was very disappointed to see this post here, Ron. First of all, since you posted basically the same question to [EMAIL PROTECTED] (where I have answered it, btw), what you did is called multi-posting and is considered rude. See why here: http://www.uwasa.fi/~ts/http/crospost.html Furthermore, your question was preceded by a long thread at [EMAIL PROTECTED]: http://www.mail-archive.com/beginners%40perl.org/msg63290.html Do you really believe that you explained your problem properly to those who have not read the previous posts? -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com/a
Re: Extracting Directories and Sub Directories and Counting
Hey Gunnar, and list, ---snip print \n; my %HoA; for ( `dir /b/s` ) { push @{ $HoA{$1} }, $2 if /(.+)\\(\w+)\.\d+\.\w+$/; } for my $dir ( sort keys %HoA ) { print join ( \n, $dir ), \n\n; my @basenames = @{ $HoA{$dir} }; my %count; for my $frames ( @basenames ) { $count{$frames} += 1; } for ( sort keys %count ) { printf %30s\t%04d\n, $_, $count{$_}; } print \n; } ---snip gives me: C:\scripts\dir\dir\dir basename 0010 basename 0006 basename 0005 C:\scripts\dir\dir\dir\sub_directory basename 0010 C:\scripts\dir\dir\dir\sub_directory\deeper_sub basename0004 C:\scripts\dir\dir\dir\sub_directory\deeper_sub even_deeper_sub basename0011 This is what I was shooting for, file basenames and counts. Thanks! I've been reading 'perlreftut', 'perlrefdsc' and the rest over the weekend and today. I've been playing around with everything there. It's a lot, but I'm plowing through. If I wanted to add more fields to my output, which construct would I use to create more fields; something like the following? basenamecountextensionsize ...maybe 'HoH', or just expand on the 'HoA? --- Gunnar Hjalmarsson [EMAIL PROTECTED] wrote: Gunnar Hjalmarsson wrote: for my $dir ( sort keys %HoA ) { print $dir\n; my @basenames = @{ $HoA{$dir} }; my %count; for my $frames ( @basenames ) { $count{$frames} += 1; } for ( sort keys %count ) { printf %30s\t%04d\n, $_, $count{$_}; } } Or with less typing: for ( sort keys %HoA ) { print $_\n; my %bn; %bn = map { $_, ++$bn{$_} } @{ $HoA{$_} }; printf %30s\t%04d\n, $_, $bn{$_} for sort keys %bn; } ;-) -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response __ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Extracting Directories and Sub Directories and Counting
Well I've moved this along a little further, but it looks like I'm stuck on one last thing. I'm getting; C:\Perl\scripts\dir\dir\dir basename 0001 basename 0002 basename 0003 basename 0004 basename 0005 basename 0006 basename 0007 basename 0008 basename 0009 basename 0010 another_basename 0001 another_basename 0002 another_basename 0003 another_basename 0004 another_basename 0005 another_basename 0006 yet_another_name 0001 yet_another_name 0002 yet_another_name 0003 yet_another_name 0004 yet_another_name 0005 C:\Perl\scripts\dir\dir\dir\sub_directory basename 0001 basename 0002 basename 0003 basename 0004 basename 0005 basename 0006 basename 0007 basename 0008 basename 0009 basename 0010 C:\Perl\scripts\dir\dir\dir\sub_directory\deeper_sub basename 0001 basename 0002 basename 0003 basename 0004 The following is the re-worked script: snip- #!/usr/bin/perl -w use strict; my %HoA; for ( `dir /b/s` ) { push @{ $HoA{$1} }, $2 if /(.+)\\(\w+)\.(\d+)\.(\w+)$/; } my %count; for my $dir ( sort keys %HoA ) { print $dir\n; my @basenames = @{ $HoA{$dir} }; for my $frames ( @basenames ) { $count{$frames} += 1; printf %30s\t%04d\n, $frames, $count{$frames}; } } snip- I'm trying to get the following output: C:\Perl\scripts\dir\dir\dir basename 0010 another_basename 0006 yet_another_basename 0005 C:\Perl\scripts\dir\dir\dir\sub_directory basename 0010 C:\Perl\scripts\dir\dir\dir\sub_directory\deeper_sub basename 0004 I've gone through 'perldoc perlreftut', but can't see the last step. --- Gunnar Hjalmarsson [EMAIL PROTECTED] wrote: [ replying to the list since that's where the discussion belongs ] Ron Smith wrote (to me privately): Thank you *very* much for furthering my 'Perl' knowlege. I've never see a variable like '@{ $HoA{$dir} }' before. Well, it's not a special variable type. $HoA{$dir} is a reference to an anonymous array, which you dereference with the @{ $HoA{$dir} } construct. I'm just at the 'Llama' level. I think I understand what's going on though. Your solution:... my %HoA; for ( `dir /b/s` ) { push @{ $HoA{$1} }, $2 if /(.+)\\(\w+)\.\d+\.\w+$/; } for my $dir (sort keys %HoA ) { print $dir\n, join( \n, @{ $HoA{$dir} } ), \n\n; } ...worked out fine. This one took some thought for me to wrap my head around. Thank you so *very* much for showing me something new and very useful. I now realize that the small piece of code above combines three components of Perl that make it a really powerful programming language: Hashes, references and regular expressions. I'm attempting to play around with this new tool to get it to do different things, but I'm running into another problem. I can't seem to pull the elements back out from the arrays properly. I'm tring to count the basenames now. I get what looks like memory addresses instead. I think these are the references to the actual arrays that you were eluding to. Sounds plausible. :) I was using parts of the script you helped me out on before to do the counting of the basenames: #!/usr/bin/perl -w use strict; my @paths = `dir /b`; my @basenames = extract_names(@paths); sub extract_names { my ($name, @names); for (@_) { if (/(\w+)\.\d+\.\w+$/) { $name = $1; $name =~ s/$/\n/; Hmm.. It's usually practical to not add \n like that, but take care of linebreaks in connection with printing the variable. Without adding \n, instead of saying print @basenames; you can say e.g. print join(\n, @basenames), \n; push @names, $name; } } @names; } my (%count, $frames); for $frames (@basenames) { chomp ($frames); $count{$frames} += 1; } for $frames (sort keys %count) { # print $frames\t1-$count{$frames}\n; printf %20s\t%04d\n, $frames, $count{$frames}; } One of the things I attempted was the following: #!/usr/bin/perl -w use strict; my %HoA; for ( `dir /b/s
Extracting Directories and Sub Directories
The following is the script: ---snip #!/usr/bin/perl -w use strict; use File::Basename; my @lines = dirname `dir /b/s`; print @lines\n; ---snip The following is the input: C:\Perl\scripts\shots\sp2\shot_1\dir.txt C:\Perl\scripts\shots\sp2\shot_1\filename.0001.cin C:\Perl\scripts\shots\sp2\shot_1\filename.0002.cin C:\Perl\scripts\shots\sp2\shot_1\filename.0003.cin C:\Perl\scripts\shots\sp2\shot_1\filename.0004.cin C:\Perl\scripts\shots\sp2\shot_1\filename.0005.cin C:\Perl\scripts\shots\sp2\shot_1\file_name.0001.cin C:\Perl\scripts\shots\sp2\shot_1\file_name.0002.cin C:\Perl\scripts\shots\sp2\shot_1\file_name.0003.cin C:\Perl\scripts\shots\sp2\shot_1\file_name.0004.cin C:\Perl\scripts\shots\sp2\shot_1\file_name.0005.cin C:\Perl\scripts\shots\sp2\shot_1\sub_directory C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0001.rgb C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0002.rgb C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0003.rgb C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0004.rgb C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0005.rgb I would like the output to be the following: C:\Perl\scripts\shots\sp2\shot_1--current directory C:\Perl\scripts\shots\sp2\shot_1\sub_directory --sub directory 'dirname' seems to only pick up the following: C:\Perl\scripts\shots\sp2\shot_1 I also tried the following code: ---snip #!/usr/bin/perl -w use strict; use File::Basename; my @dir_contents = `dir /b/s`; for (@dir_contents) { my @paths = dirname $_; print @paths\n; ---snip But, I get the following (truncated for our purposes): C:\Perl\scripts\shots\sp2\shot_1 C:\Perl\scripts\shots\sp2\shot_1 C:\Perl\scripts\shots\sp2\shot_1 C:\Perl\scripts\shots\sp2\shot_1 C:\Perl\scripts\shots\sp2\shot_1 C:\Perl\scripts\shots\sp2\shot_1 C:\Perl\scripts\shots\sp2\shot_1 C:\Perl\scripts\shots\sp2\shot_1 C:\Perl\scripts\shots\sp2\shot_1 C:\Perl\scripts\shots\sp2\shot_1 C:\Perl\scripts\shots\sp2\shot_1 C:\Perl\scripts\shots\sp2\shot_1 C:\Perl\scripts\shots\sp2\shot_1\sub_directory C:\Perl\scripts\shots\sp2\shot_1\sub_directory C:\Perl\scripts\shots\sp2\shot_1\sub_directory C:\Perl\scripts\shots\sp2\shot_1\sub_directory C:\Perl\scripts\shots\sp2\shot_1\sub_directory C:\Perl\scripts\shots\sp2\shot_1\sub_directory C:\Perl\scripts\shots\sp2\shot_1\sub_directory C:\Perl\scripts\shots\sp2\shot_1\sub_directory C:\Perl\scripts\shots\sp2\shot_1\sub_directory C:\Perl\scripts\shots\sp2\shot_1\sub_directory C:\Perl\scripts\shots\sp2\shot_1\sub_directory I've also tried a number of other things to no avail. Does anyone have a solution to my delima? I've also tried the following code, but, it too fills the buffer. #!/usr/bin/perl -w use strict; my (@lines, $line, @paths); @lines = `dir /b/s`; print @lines; for (@lines) { if (/\w+\.\d+(\.\w+)$/) { $line = $`; $line =~ s/$/\n/; push @paths, $line; print @paths; } } __ Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. http://promotions.yahoo.com/new_mail -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Extracting Directories and Sub Directories
The sulution that you and others gave to the previous problem worked out fine. I thought I sent mail regarding that. I didn't think that this was related to that problem; but, it is very similar. My appologies if I'm mistaken. TIA -- for any input you can give me. Ron --- Gunnar Hjalmarsson [EMAIL PROTECTED] wrote: Ron Smith wrote: snip I would like the output to be the following: C:\Perl\scripts\shots\sp2\shot_1 --current directory C:\Perl\scripts\shots\sp2\shot_1\sub_directory --sub directory Ron, Recently you posted a related problem, but didn't even acknowledge that you got several responses. http://www.mail-archive.com/beginners%40perl.org/msg63070.html Why are you now presenting this in a new thread as a separate problem? Aren't they instead as integrated as they possibly could be? -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response __ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Broken Subroutine
Here's the problem: My input looks like the following: C:\Perl\scripts\shots\sp2\shot_1\dir.txt C:\Perl\scripts\shots\sp2\shot_1\drames.txt C:\Perl\scripts\shots\sp2\shot_1\filename.0001.cin C:\Perl\scripts\shots\sp2\shot_1\filename.0002.cin C:\Perl\scripts\shots\sp2\shot_1\filename.0003.cin C:\Perl\scripts\shots\sp2\shot_1\filename.0004.cin C:\Perl\scripts\shots\sp2\shot_1\filename.0005.cin C:\Perl\scripts\shots\sp2\shot_1\filename.0006.cin C:\Perl\scripts\shots\sp2\shot_1\filename.0007.cin C:\Perl\scripts\shots\sp2\shot_1\filename.0008.cin C:\Perl\scripts\shots\sp2\shot_1\filename.0009.cin C:\Perl\scripts\shots\sp2\shot_1\filename.0010.cin C:\Perl\scripts\shots\sp2\shot_1\framename.0001.cin C:\Perl\scripts\shots\sp2\shot_1\framename.0002.cin C:\Perl\scripts\shots\sp2\shot_1\framename.0003.cin C:\Perl\scripts\shots\sp2\shot_1\framename.0004.cin C:\Perl\scripts\shots\sp2\shot_1\framename.0005.cin C:\Perl\scripts\shots\sp2\shot_1\framename.0006.cin C:\Perl\scripts\shots\sp2\shot_1\lss C:\Perl\scripts\shots\sp2\shot_1\lss_orig C:\Perl\scripts\shots\sp2\shot_1\shotname.0001.cin C:\Perl\scripts\shots\sp2\shot_1\shotname.0002.cin C:\Perl\scripts\shots\sp2\shot_1\shotname.0003.cin C:\Perl\scripts\shots\sp2\shot_1\shotname.0004.cin C:\Perl\scripts\shots\sp2\shot_1\shotname.0005.cin C:\Perl\scripts\shots\sp2\shot_1\sub_directory C:\Perl\scripts\shots\sp2\shot_1\test C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0001.rgb C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0002.rgb C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0003.rgb C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0004.rgb C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0005.rgb C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0006.rgb C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0007.rgb C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0008.rgb C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0009.rgb C:\Perl\scripts\shots\sp2\shot_1\sub_directory\basename.0010.rgb I want my output from the subroutine to look like the following: filename filename filename filename filename filename filename filename filename filename framename framename framename framename framename framename shotname shotname shotname shotname shotname basename basename basename basename basename basename basename basename basename basename The following is the code: #!/usr/bin/perl -w use strict; my @paths = `dir /b/s`; # print @paths; my @basenames = basenames(@paths); sub basenames { foreach (@_) { if ($_ =~ /(\w+)\.\d+\.\w+$/) { @basenames = $1; # print @basenames\n; } } } Everything looks OK when I do the test prints. But, I'm not getting output from the subroutine. What's the correct way to get this return? The OS is Window$. ___ Do you Yahoo!? Declare Yourself - Register online to vote today! http://vote.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Extra newline characters.
I'm working the exercises out of the Learning Perl book, but I'm doing so through a shell account from a Window$ box into a UNIX environment. I'm experiencing an oddity wherein I'm getting, what I think are, extra newlines or carriage returns in my code as I type it in the shell through a telnet session. This phenomenon, of course, throws off the results of the code. Has anyone experienced this? Is there a solution? I've tried several adjustments in the code I'm writing by using an extra 'chomp' or' chop', but this method is hit-and-miss. There may be some ENV variable or something else I can use to get some consistency going. TIA Ron - Do you Yahoo!? vote.yahoo.com - Register online to vote today!
Re: Extra newline characters.
I'm not sure what you mean. I'm new at logging into shell accounts through a 'telnet' session. I'm on a Window$ 2000 box, using 'telnet' to log into 'sdf.lonestar.org'. The first thing that appears at login is the following: NetBSD/alpha (sdf) (ttypu) Does that help? Ron Errin Larsen [EMAIL PROTECTED] wrote: On Fri, 8 Oct 2004 11:11:26 -0700 (PDT), Ron Smith wrote: I'm working the exercises out of the Learning Perl book, but I'm doing so through a shell account from a Window$ box into a UNIX environment. I'm experiencing an oddity wherein I'm getting, what I think are, extra newlines or carriage returns in my code as I type it in the shell through a telnet session. This phenomenon, of course, throws off the results of the code. Has anyone experienced this? Is there a solution? I've tried several adjustments in the code I'm writing by using an extra 'chomp' or' chop', but this method is hit-and-miss. There may be some ENV variable or something else I can use to get some consistency going. TIA Ron What UNIX environment? What terminal emulator? I know that Solaris includes a handy utility called dos2unix that will help pull out annoying extra characters from DOS created text files. Perhaps this utility is found in other UNIXy OSs as well. --Errin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish.
Extra newline characters.
Thanks all. The problem was at the begining of the 'TELNET' session, I have to type in: UNSET CRLF. - Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish.
A possibly stupid 'Perl' question?
I'm in a situation wherein I want to brush up on my 'Perl', but have no personal computer. I'm currently reading my way through Learning Pearl, but can't do the exercises because I only have access to 'Windows' machines that do not have Perl installed at all. Is there a way to use Perl on-line from such a machine? Is Perl small enough to be installed on a floppy disk that can be moved from machine to machine? Is it possible to use 'Perl' without having to install it on a particular machine? TIA Ron Smith - Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers!
Re: Installing the Tk module
You can find a compatible and free C compiler at 'http://www.borland.com/'. As far as Perl itself is concerned, you can download ActivePerl from 'http://www.activestate.com'. This Windows version of perl includes the 'Tk' module. If you use the MSI version, you will also need the Windows 2.0 installer already installed on your system. R. From: Octavian Rasnita [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Installing the Tk module Date: Thu, 15 Aug 2002 10:36:43 +0300 Can somebody tell me how to install the Tk module in Windows 2000? I've installed it with ppm, I've downloaded it from CPAN, but I can't make it work. It keeps giving me errors about a module that is not found (Event.pm) and an object in a module... Do I need a C compiler to install Tk in Windows? I have a C compiler but it is not the recommended Visual C++ and I don't know C at all. Help! Teddy's Center: http://teddy.fcc.ro/ Mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Chat with friends online, try MSN Messenger: http://messenger.msn.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Multiple directory handles?
5 if (@ARGV) { 6 foreach $ARGV (@ARGV) { 7 opendir (DIR, $ARGV) or die $!; 8 } 9 } So far, it looks like the last command-line argument is stepping on any other arguments that come before it. Is there a way to assign multiple command-line args to multiple directory handles? TIA Ron _ Join the worlds largest e-mail service with MSN Hotmail. http://www.hotmail.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Multiple directory handles...?
5 if (@ARGV) { 6 foreach $ARGV (@ARGV) { 7 opendir (DIR, $ARGV) or die $!; 8 } 9 } So far, it looks like the last command-line argument is stepping on any other arguments that come before it. Is there a way to assign multiple command-line args to multiple directory handles? TIA Ron -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ultimate stupidity
Just think of the semicolons as periods to a sentence. Think of your thoughts in totality. After all it is a language :-). Ron From: Gary L. Armstrong [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: RE: ultimate stupidity Date: Fri, 5 Oct 2001 23:29:15 -0400 I forget the semicolons just about every coding session. My program never works right the first test run because of this. I can't even blame it on the cursor. I'll fix it and move on, but the next day I forget them again. Sometimes I forget the # before my comment marking the end of an if or other conditional block. Usually, though, it's the semicolon. -=GLA=-; -Original Message- From: Brett W. McCoy [mailto:[EMAIL PROTECTED]] Sent: Friday, October 05, 2001 11:43 AM To: Francesco Scaglioni Cc: [EMAIL PROTECTED] Subject: Re: ultimate stupidity On Fri, 5 Oct 2001, Francesco Scaglioni wrote: Answer: I had inadvertently put a space in front of the # at the beginning of the #!. The space is, of course covered by the cursor when I visit the beginning of the file an I had failed to notice the implied space ( implied because I could still see the # ). Is this a record for the most stupid mistake ever made? Boy have I got much to learn. Don't feel bad -- we've all done similar things. You know why programmers have flat foreheads. Beacuse they are constantly slapping their forehead and going 'Doh!' Being able to admit an error (even one you think is stupid) is a good quality to have. -- Brett http://www.chapelperilous.net/ Sir, it's very possible this asteroid is not stable. -- C3P0 -- 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] _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DELETE BLANK LINE
How about: next unless /\S/; Ron From: Eric Wang [EMAIL PROTECTED] To: Pedro A Reche Gallardo [EMAIL PROTECTED] CC: [EMAIL PROTECTED] [EMAIL PROTECTED] Subject: Re: DELETE BLANK LINE Date: Thu, 4 Oct 2001 11:05:59 -0700 (PDT) Yeah, I think you can use chomp(); so use foreach $i (@foo){ chomp($i); do you things here } I am not sure if you can delete the line if it's all blank. But, worth a try. ;) Eric * *Eric T. Wang * *Bioinformatic Support and SRA * *University of California, Irvine College of Medicine * *Department of Biological Chemistry* *RK Moyzis Lab * *[EMAIL PROTECTED] * *949-824-1870 * * On Wed, 3 Oct 2001, Pedro A Reche Gallardo wrote: Hi all, I am sure someone has already asked this but I do not remeber the answer. How can I delete or go to the next line if a blank line is found. By a blank line I mean any line containing only white spaces, return, tab characters etc. Regards, Pedro -- *** PEDRO a. RECHE gallardo, pHDTL: 617 632 3824 Scientist, Mol.Immnunol.Foundation, FX: 617 632 3351 Dana-Farber Cancer Institute, EM: [EMAIL PROTECTED] Harvard Medical School, EM: [EMAIL PROTECTED] 44 Binney Street, D610C,URL: http://www.reche.org Boston, MA 02115 *** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Subroutine example
Is it just me, or does anyone out there notice that the example subroutine on pg. 57 of Learning Perl (Third Edition) doesn't work, as presented? When written like: snip-- #!/usr/bin/perl -w use strict; sub marine { my $n += 1; # Global variable $n print Hello, sailor number $n!\n; } marine; marine; marine; marine; snip-- STDOUT gets: Hello, sailor number 1! Hello, sailor number 1! Hello, sailor number 1! Hello, sailor number 1! But, when written like: snip-- #!/usr/bin/perl -w use strict; my $n = 1; sub marine { print Hello, sailor number $n!\n; $n += 1; # Global variable $n } marine; marine; marine; marine; snip-- STDOUT gets: Hello, sailor number 1! Hello, sailor number 2! Hello, sailor number 3! Hello, sailor number 4! ...like it's supposed to. Am I missing some key information here?? Or, is the book just a bit unclear?? Ron _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filehandle error using Strict
What is it that you're trying to do with the file? If you just want to read the contents, using 'filehandles' and 'strict', here's one way to do it: ---snip--- #!/usr/bin/perl -w use strict; open (FILE, some_file); while (FILE) { print; } close FILE; ---snip--- Ron From: Deborah Strickland [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Filehandle error using Strict Date: Tue, 04 Sep 2001 10:17:04 -0700 Hi all, I've had this question for quite a while and can't find any reference to it in any of my many Perl books. I want to use the 'strict' command but whenever I do it always causes an error on any file handles I have used. I always declare everything but have never seen a filehandle declared before using it. I then tried to declare the file handle with 'my $FH' but that causes an error for some reason. What's the correct way? This works: open(FN, $someFIle); This fails: use strict; open(FN, $someFile); What's the correct way to get 'strict' to work when using file handles? Thnx, Deb -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Capture an email address from a text file
I don't know how detailed you wanna get with this, but the following will return the line in the text file with the address. -snip-- #!/usr/bin/perl -w use strict; while () { open (FILE, some_file_name); print if /@/; } close FILE; -snip-- You can run the above code like a UNIX command-line program like: ./my_program some_file_name This is just a general suggestion. You should embellish to suit your needs. Ron From: Arthur Perley [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Capture an email address from a text file Date: Tue, 4 Sep 2001 12:15:01 -0400 Hello, I need some suggestions regarding stripping email addresses from returned email messages. The addresses are embedded in text files (the email message) without any consistent delimiters (e.g. or :). These aren't the From: addresses, since that is usually something like [EMAIL PROTECTED] but more like user [EMAIL PROTECTED] not found or some such embedded in the message. Thanks in advance -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: split a file
Yet another way...: -snip--- #!/usr/bin/perl -w use strict; open (FILE, file_with_headings.txt) || die Couldn't open \file_with_headings.txt\ $!\n; open (DIALIGN, dialign.txt) || die Couldn't create \dialign.txt\ $!\n; open (FASTA, fasta.txt) || die Couldn't create \fasta.txt\ $!\n; open (TREE, sequence_tree.txt) || die Couldn't create \sequence_tree.txt\ $!\n; while (FILE) { print DIALIGN if (/DIALIGN/ .. /FASTA/); print FASTA if (/FASTA/ .. /Sequence tree/); print TREE if (/Sequence tree/ .. eof); } close (DIALIGN); close (FASTA); close (TREE); -snip--- Ron Smith From: Pedro A Reche Gallardo [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED], [EMAIL PROTECTED] [EMAIL PROTECTED] Subject: split a file Date: Tue, 21 Aug 2001 18:24:44 -0400 Hi All, I have a file (see below) that I would like to split in three files: One file for the information under Alignment (DIALIGN format), another for the information under the line Alignment (FASTA format) and a third one for the information under sequence tree. Any help to do this will be appreciated. Cheers Alignment (DIALIGN format): === gi|38145|e1 MALPVTALLL PLALLLHAAR ---PSQFRVS PLDRTWNLGE TVELKCQVLL gi|74386931 MALPVTALLL PLALLLHAAR ---PSQFRVS PLDRTWNLGE TVELKCQVLL ** ***** ** ** ** * *** ** ** Alignment (FASTA format): = gi|38145|emb|CAA4278 MALPVTALLLPLALLLHAAR---PSQFRVSPLDRTWNLGETVELKCQVLL SNPTSGCSWLFQPRGAAASPTFLLYLSQNKPKAAEGLDTQRFSGKRLGDT gi|7438693|pir||S256 MALPVTALLLPLALLLHAAR---PSQFRVSPLDRTWNLGETVELKCQVLL Sequence tree: == ((gi|38145|emb|CAA4278:0.003018, gi|7438693|pir||S256:0.003018):0.002338, gi|1168854|sp|P41688:0.005357); *** PEDRO a. RECHE gallardo, pHDTL: 617 632 3824 Scientist, Mol.Immnunol.Foundation, FX: 617 632 3351 Dana-Farber Cancer Institute, EM: [EMAIL PROTECTED] Harvard Medical School, EM: [EMAIL PROTECTED] 44 Binney Street, D610C,URL: http://www.reche.org Boston, MA 02115 *** _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how do I know what modules are installed
use: 'perl -MMODULE_NAME -e 1' for an individual module, like: perl -MFile::Copy -e 1, or perl -MCGI -e 1. For all the modules installed, you might want to check out the following URL: http:[EMAIL PROTECTED]/msg04057.html Ron From: Joe Bellifont [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: how do I know what modules are installed Date: Wed, 15 Aug 2001 12:29:35 + I have to install the xml parser module. I have root access. How do I know if it is already installed and how can I get a list of all installed modules thanks. -J _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to retrieve filesystem size ?
Is this for PC or UNIX?? The following basic works for UNIX: print (`df -k`); # use backquotes Chapter 14 (Process Management) in Learning Perl. Ron From: Vincent Bouttier-Deslandes [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Subject: How to retrieve filesystem size ? Date: Fri, 03 Aug 2001 16:02:31 +0200 Hi, Does anybody know how I can get a filesystem (or drive) size and free space ? I haven't see any module with a function to do that. Thanks. -- Vincent Bouttier-Deslandes ([EMAIL PROTECTED]) Responsable du pôle Outils/Sécurité Tel: +33.3.28.37.78.47 - Fax : +33.3.20.67.58.43 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
A Munging Project
Hi all, I've been handed a project where I have to read the contents of several files, which looks like the following: file.0001.rgb file.0002.rgb file.0003.rgb file.0004.rgb file.0005.rgb file_2.0001.rgb file_2.0002.rgb file_2.0003.rgb then replace the contents of those files with the same info in the following format: 1 file.%04d.rgb1-5 2 file_2.%04d.rgb 1-3 Are there any modules I should be looking at that could make this job easier? Ron _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
array contents to a file
Could someone provide a snippet of code that reads the contents of an array to a text file. Thanks, Ron _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Request for code review...Please
I seem to be stuck on a relatively simple problem, but being a newbie I can't seem to see the STDERR of my ways. To make a short story shorter, the attached bit of code is meant to allow multple users on a networked UNIX enviroment to select which machine they want to create a directory on, but restrict the choices of directory names they can use. However, they are allowed to *add* new names on their own, as the need arises. Everything works fine *except* the 'if' statement block from lines 46-51 (in vi), or the first 'if' statement if you don't have access to numbering. I get some odd behavior here (no doubt due to something I'm doing wrong). As soon as you enter add at line 44, the script jumps to line 70, and finishes the script instead of pushing the *new* user-added directory name to @show_list. What am I overlooking??? TIA Ron _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp director_post.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tkperl
you may want to look into: [EMAIL PROTECTED] Ron From: raf [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Tkperl Date: Mon, 23 Jul 2001 13:20:26 +0200 Hi, is there a mailing-list concerning Tkperl? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Highlihting a string
If it's not CGI.pm you're looking for, try Term::ANSIColor module. Ron From: viswanathan sundararajan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Highlihting a string Date: Thu, 19 Jul 2001 23:14:03 -0700 (PDT) Hi, I want to highlight a string in my output.For example consider the output welcome to perl.I want to highlight the string perl in this output.Could Anyone help me in this regard? visu __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]