Re: Can't get Socket module
In article [EMAIL PROTECTED], Jeremiah Foster wrote: Hello there! I am having difficulty downloading the Socket module to make a script work. Below is the result of my attempt installing from the command line via Perl; Any suggestions? Perhaps looking at one of the HOWTO's on the web for installing Perl modules without root access will be useful for you: http://people.nl.linux.org/~joor/noroot.shtml Mark Thanks Mark, that link was helpful and I read it, though I usually do download and install from tarred, gunzipped archives. Also, I do have root permission on this machine. I saw that the file that the interactive module script couldn't fetch was simply a text file that I could cut and paste with a browser. The weird thing was that it kept saying; Warning: expected file [yes/sources/modules/03modlist.data.gz] doesn't exist but I could go to that link and view it. Isn't it something other than not just being root? Is there a flaw in the script? Jeremiah -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: data structures one more try
Rob, Good call! You can print out the data in @bags and @bag_quantity using Data::Dumper.. print Dumper [EMAIL PROTECTED]; http://www.coraconnection.com/paul_s/pages/catalog.html Check this out, 'order' second and third bag in the first row. and hit the CGI and see the results, bizarre! Thanks for your help, Regards Dave ( kora musician / audiophile / web master @ cora connection / DFW, TX, USA) and web designer for Afropop Worldwide http://www.afropop.org/community/contributors.php?ID=8 == Cora Connection: Your West African Music Source Resources, Recordings, Instruments More! http://www.coraconnection.com/ == == Cora Connection: Your West African Music Source Resources, Recordings, Instruments More! http://www.coraconnection.com/ == -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: data structures one more try
Rob and all the rest reading this, Here's what fixed the problem. The check boxes are only sent to CGI.pm if checked, while all the input fields are sent regardless. So @bag_quantity was filled with '0's ... get rid of 'o's @bag_quantity = grep(/[^0]/, @bag_quantity); ...this now seems to work Thanks, Dave ( kora musician / audiophile / web master @ cora connection / DFW, TX, USA) and web designer for Afropop Worldwide http://www.afropop.org/community/contributors.php?ID=8 == Cora Connection: Your West African Music Source Resources, Recordings, Instruments More! http://www.coraconnection.com/ == -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
what wrong with this code
I am writing a usr login program, my perl are list as following. in Line 123 what i am trying to do is if a user missing some informatin say username, use will be prompted to input username but all other information will be sent back to the registration form, so user do not need to re input all the information again. (you can see my website from http://apidb.org/regstr.html) but this code does not work, if a user left all filed blank before he submit, some very strang information will be sent back to the registraiton form with waring messge. like in the firsname field will have size=15, which is not provided by user. How can i fix this problem? Thanks #Get user's input my $username = $query-param(username); my $email = $query-param(email); my $password1 = $query-param(password1); my $password2 = $query-param(password2); my $fname = $query-param(fname); my $lname = $query-param(lname); if(!$username||!$email|| !$password1||!$password2) { print h4(Field with * can not be empty); regstrForm($username, $password1, $password2, $email, $fname,$lname);# Line 123 #to sent usr-provided info back to the registration form # return; } sub regstrForm { print FORM ACTION=/cgi-bin/regstr.pl METHOD=POST TABLE width='640' align='center' cellpadding=2 cellspacing=10 TR TDfont color='#003399' size=3bPlease register: /b/font/TD /TR TR TD*User Name:/TD TDINPUT NAME='username' ALIGN='left' SIZE='20' VALUE=$_[0]/TD /TR TR TD*Password:/TD TDINPUT NAME='password1' Type=password ALIGN='left' VALUE=$_[1] SIZE='20'/TD /TR TR TD*Retype Password:/TD TDINPUT NAME='password2' Type=password VALUE=$_[2] ALIGN='left' SIZE='20'/TD /TR TR TD*Email:/TD TDINPUT NAME='email' Type=text VALUE=$_[3] ALIGN='left' SIZE='40'/TD /TR TR TDFirst Name:/TD TDINPUT ALIGN=left NAME='fname' VALUE=$_[4] SIZE=15/TD /TR TR TDLast Name:/TD TDINPUT ALIGN=left NAME=lname VALUE=$_[5] SIZE=15/TD /TR TR TDINPUT ALIGN = RIGHT TYPE='submit' NAME='Submit' VALUE='Register'/TD TDINPUT ALIGN = LEFT TYPE='reset' VALUE=Reset/TD /TR /TABLE /FORM h4*Required field/h4 ** *** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: what wrong with this code
Hi Xiongfei, By looking at the source of the html, i wold suggest you wrap with quotes the default values of the form fields (i.e attribute VALUE=) Example: TR TD*Password:/TD TDINPUT NAME='password1' Type=password ALIGN='left' VALUE='$_[1]' SIZE='20'/TD /TR That way, if $_[1] is blank, the browser won't mistake SIZE='20' to be the default value of password1. Hope that helps, Etienne Rivard Xiongfei Wang[EMAIL PROTECTED] 03/05/03 01:40pm I am writing a usr login program, my perl are list as following. in Line 123 what i am trying to do is if a user missing some informatin say username, use will be prompted to input username but all other information will be sent back to the registration form, so user do not need to re input all the information again. (you can see my website from http://apidb.org/regstr.html) but this code does not work, if a user left all filed blank before he submit, some very strang information will be sent back to the registraiton form with waring messge. like in the firsname field will have size=15, which is not provided by user. How can i fix this problem? Thanks #Get user's input my $username = $query-param(username); my $email = $query-param(email); my $password1 = $query-param(password1); my $password2 = $query-param(password2); my $fname = $query-param(fname); my $lname = $query-param(lname); if(!$username||!$email|| !$password1||!$password2) { print h4(Field with * can not be empty); regstrForm($username, $password1, $password2, $email, $fname,$lname);# Line 123 #to sent usr-provided info back to the registration form # return; } sub regstrForm { print FORM ACTION=/cgi-bin/regstr.pl METHOD=POST TABLE width='640' align='center' cellpadding=2 cellspacing=10 TR TDfont color='#003399' size=3bPlease register: /b/font/TD /TR TR TD*User Name:/TD TDINPUT NAME='username' ALIGN='left' SIZE='20' VALUE=$_[0]/TD /TR TR TD*Password:/TD TDINPUT NAME='password1' Type=password ALIGN='left' VALUE=$_[1] SIZE='20'/TD /TR TR TD*Retype Password:/TD TDINPUT NAME='password2' Type=password VALUE=$_[2] ALIGN='left' SIZE='20'/TD /TR TR TD*Email:/TD TDINPUT NAME='email' Type=text VALUE=$_[3] ALIGN='left' SIZE='40'/TD /TR TR TDFirst Name:/TD TDINPUT ALIGN=left NAME='fname' VALUE=$_[4] SIZE=15/TD /TR TR TDLast Name:/TD TDINPUT ALIGN=left NAME=lname VALUE=$_[5] SIZE=15/TD /TR TR TDINPUT ALIGN = RIGHT TYPE='submit' NAME='Submit' VALUE='Register'/TD TDINPUT ALIGN = LEFT TYPE='reset' VALUE=Reset/TD /TR /TABLE /FORM h4*Required field/h4 ** *** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Script does not want to run, error
Mel, Renamer does not have execute permissions. Do a chmod 755 renamer.pl. Also the script is owned by root, so you will not be able to run it as me. Eric -Original Message- From: mel awaisi [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 05, 2003 2:34 PM To: [EMAIL PROTECTED] Subject: Script does not want to run, error Hi, I am having problems opening this script on my machine. i have been getting help from a very helpful person on this list. I have checked the shebang line, that perl exists, and perl -v gives proper output. i try to run the script below as follow: [EMAIL PROTECTED] httpd]# cd cgi-bin [EMAIL PROTECTED] cgi-bin]# ls -la total 28 drwxr-xr-x2 me root 4096 Mar 5 21:49 . drwxr-xr-x5 me root 4096 Mar 3 01:50 .. -rwxr-xr-x1 me root 268 Mar 4 13:50 printenv -rwxr-xr-x1 me me 1792 Mar 5 15:20 renamer -rwxr-xr-x1 me me 1788 Mar 4 16:40 renamer.cgi -rw---1 root root 1731 Mar 5 21:49 renamer.pl -rwxr-xr-x1 me root 757 Mar 3 01:50 test-cgi [EMAIL PROTECTED] cgi-bin]# renamer.pl [1] 10254 [EMAIL PROTECTED] cgi-bin]# bash: renamer.pl: command not found [1]+ Exit 127renamer.pl [EMAIL PROTECTED] cgi-bin]# [EMAIL PROTECTED] cgi-bin]# ./renamer.pl [1] 10297 [EMAIL PROTECTED] cgi-bin]# bash: ./renamer.pl: Permission denied [1]+ Exit 126./renamer.pl [EMAIL PROTECTED] cgi-bin]# Regards, Mel _ Chat online in real time with MSN Messenger http://messenger.msn.co.uk -- 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]
[OT] YAPC::NA 2003 Registration
Hello folks, I just wanted to alert people to the fact that registration has begun for YAPC::NA::2003. The Yet Another Perl Conferences (YAPCs) are grassroots symposia on the Perl programming language under the auspices of the Yet Another Society (YAS), a non-profit corporation for the advancement of collaborative efforts in computer and information sciences. The cost is $85 for 3 days of talks, tutorials and discussions. I have some fabulous talk proposals, so this stands to be a great place to learn some new things. It will be June 16-18, 2003 in Boca Raton, FL. Please visit the website to learn more, and _to register_. If anyone has any questions, feel free to email me off-list. Cheers, Kevin -- [Writing CGI Applications with Perl - http://perlcgi-book.com] BASIC is the Computer Science equivalent of `Scientific Creationism'. -- BSD fortune file -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem with script:usage
hi Could someone please look at my script and tell me why i am getting this!!! please [EMAIL PROTECTED] cgi-bin]# ./renamer.pl [2] 11033 [1] Exit 127renamer.pl [EMAIL PROTECTED] cgi-bin]# usage: ./renamer.pl initial_name original_dir new_dir suffi x example: ./renamer.pl image /home/httpd/htdocs/ /home/me/images/ jpg [2]+ Exit 255./renamer.pl [EMAIL PROTECTED] cgi-bin]# Regards, Mel _ Express yourself with cool emoticons http://messenger.msn.co.uk -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help really needed in this script: error: Prematue end of script header
Mel, I agree with the follow up posting on beginners that says this script should not be run as a CGI. However, just as an FYI, that particular error was being generated by Apache because you weren't outputting an HTTP content type. On another issue I see that you cross posted this message across many unrelated lists. Including at least the datetime list. Please don't spam the Perl lists with irrelevant questions. beginners and beginners-cgi is the appropriate place to ask these kinds of question. The Perl community is very supportive and people in that community want to help you. Don't alienate those that you are asking for help. Cheers, -J -- On Wed, 5 Mar 2003, mel awaisi wrote: Hi, I have with the help of one of the guys of this list got this script to take an image from one directory and then rename it with the time and date of the image and then store it onto a new directory. I sotred the image in the cgi-bin, and then tried to run the file, i got errors, when i went to the errorlog i got an error saying: Prematue end of script header: /home/httpd/cgi-bin.renamer.cgi Regards, Mel #!/usr/bin/perl use strict; use warnings; =head1 NAME # renamer - renames files received by ftp, moving them to a new directory =head1 SYNOPSIS nohup ./renamer image /home/httpd/htdocs /home/me/images jpg =head1 DESCRIPTION #The above instructs renamer to look for files called image.jpg in /home/httpd/htdocs. #It checks once per minute for such a file to appear. If it sees a #readable file called /home/httpd/htdocs.jpg it moves it to #/home/httpd/htdocs/image.200302251530.jpg where the number is a #time stamp with year (four digits), month, day of the month, hour (in #24 mode), and minute. #Read the bugs section closely. =head1 BUGS #The original and new directories must be on the same file system. #The program probably does not work on windows systems. #The daemon behavior is weak. #Not much testing has been done, so the script may have other problems. =cut my $usage = EOUSAGE; usage: $0 initial_name original_dir new_dir suffix example: $0 pic /home/httpd/htdocs /home/me/images jpg EOUSAGE my $check_file = shift or die $usage; my $original_dir = shift or die $usage; my $new_dir = shift or die $usage; my $suffix = shift or die $usage; exit if (fork()); while (1) { process($check_file) if (-r $original_dir/$check_file.$suffix); sleep 60; } sub process { my $file = shift; my ($hour, $min, $mon, $day, $year) = (localtime)[1..5]; $year += 1900; $mon++; my $stamp = $year$mon$day$hour$min; print renaming $original_dir/$file.$suffix to $new_dir/$file.$stamp.$suffix\n; rename $original_dir/$file.$suffix, $new_dir/$file.$stamp.$suffix or warn couldn't rename file $file to $new_dir/$file.$stamp.$suffix\n; } _ It's fast, it's easy and it's free. Get MSN Messenger today! http://messenger.msn.co.uk -- 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]
PowerBuilder and Perl
Hello, I have following architecture: Client:PowerBuilder8 client on Windows2000 (Perl not installed) : almost 200 users. Business:Perl script on Sun Solaris (no Web Server, no Application Server, just a perl script :) ). RDBMS: Oracle Requirements: - Asynchronous communication between pb client/windows and perl script/unix: That means the client don't have to wait the reply from the perl script. - No need to install perl on client machines. - Client should be warned when its request is treated (to be defined, any idea is welcome). - The reply's data are not send back directly to the client. - The reply's data have to be stored in Oracle table(s) - The client will access reply's data at the end of request's treatment. How can i allow my pb client execute my perl script ? Any other ideas are welcome. Thanks in advance for your input. José. DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent.
not able to set repository
Hi All I am having a problem in setting the repository - can somebody tell me the reason . ppm set repository Unknown or ambiguous setting 'repository'. See 'help settings'. ppm set repository RothConsulting http://www.roth.net/perl/packages Unknown or ambiguous setting 'repository'. See 'help settings'. ppm set case-sensitivity: 0 download-chunksize: 16384 fields: name version abstract follow-install: 1 force-install: 0 install-verbose: 1 pager: profile-track: 0 prompt-context: 0 prompt-slotsize: 11 prompt-verbose: 0 rebuild-html: remove-verbose: 1 sort-field: name tempdir: C:\TEMP trace-file: ppm3.log trace-level: 0 upgrade-verbose: 1 verbose-startup: 1 /// My HTTP_proxy is set to http://proxyname:portno like say http://jen:8210 Thanks Regards Pradeep HP, bangalore ,India Ph :91-80- 2052262
Re: Simple Regex Problem.
Rob Hanson wrote: Try this... my $data = BlahBlahBlahBlah From: BlahsvilleDude [EMAIL PROTECTED]BlahBBlahBBlah $data =~ s/^.*([^]*).*$/$1/; Hi Rob. Anchoring the search at the start of the string and then allowing 'any number of anything' is the same as not anchoring it! Likewise with your dollar anchor at the end. $data =~ m/ ([^]*) /x; my $newdata = $1; Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Simple Regex Problem.
David --- Senior Programmer Analyst --- Wgo Wagner wrote: I had to change as follows: my $data = 'BlahBlahBlahBlah From: BlahsvilleDude [EMAIL PROTECTED]BlahBBlahBBlah'; printf bf:%-s\n, $data; $data =~ s/^.*([^]*).*$/$1/gs; printf af:%-s\n, $data; but it does work though you need to use single quotes around the data as it is coming in. If you can have the line feed in there, then you will need the s to handle the possible line feed. Hi Wags. This stuff is presumably coming from a file or something like that? It's highly unlikely that it's going to be hard-coded in the program, so there's no issue about interpolating strings. Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: perl program control -- wvdial
Jdavis wrote: Hello, Hello! if( $choice == 1){ `wvdial`; print connected; } I also have tried.. if( $choice == 1){ `wvdial`; } but nothing after `wvdial` gets ran. could someone offer me some advice...please :) ? try: if( $choice == 1) { $ret = `wvdial`; print $ret; } Thanks, -- jd [EMAIL PROTECTED] Bad spellers of the world untie! I can't tell if I have worked all my life or if I have never worked a single day of my life Miguel de Icaza -- LaVei -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
regular exp problem
I have a str that contains the base64 encoded string of a mail. Now this string should not contain any characters with ascii values above 128. Can i write a regex to check this thanks ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: perl program control -- wvdial
Jdavis wrote: Hello, I am writing a script to help a user turn a modem on and off and adjust the routing tables on a Linux box. I am trying to call wvdial to do the dialing, but it does not give control back to my script. I call it like so if( $choice == 1){ `wvdial`; print connected; } Hi. I don't know wvdial, but it sounds to me very much like an application that will prompt for input. If so, then just running it from Perl will make it start and wait - it will only fall back to Perl when it exits. If this is the case then you have (at least) two options: put all of the required parameters on the command line that you issue, or open a pipe to it and send commands that way. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Delivering Graphics over HTTP
I've done as suggested and it works fine in Mozilla but IE won't display the image: http://cgi.www.miswebdesign.com/cgi-bin/www.miswebdesign.com/logo.pl?image=l ogo Any ideas? Cheers, Nigel Script: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-= #!/bin/perl5.6.0 use CGI; use File::Slurp; my $q = new CGI; my $url = '/docs/www.miswebdesign.com'; my $logo = '/images/logo.jpg'; my $location = $url . $logo; print Cache-Control: no-cache\n; print Expires: Thu, 01 Dec 1994 16:00:00 GMT\n; print Last-Modified: Thu, 27 Feb 2003 15:12:07 GMT\n; print Content-type: image/jpg\n; print ETag: \518394-1a79-3e5e2ac7\\n; print Accept-Ranges: bytes\n; print Content-Length: 6777\n\n; print read_file($location); -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-= -Original Message- From: Dan Muey [mailto:[EMAIL PROTECTED] Sent: 28 February 2003 14:43 To: Nigel Peck - MIS Web Design; [EMAIL PROTECTED] Subject: RE: Delivering Graphics over HTTP I assume what you're trying to do is have in your html img src=image.cgi And maybe except paramkaters and display accordingly? If so all you need to remember is to print the proper headers and don't try to print and text. #!/usr/bin/perl use File::Slurp; use CGI qw/:standard/; print header(image/gif); print read_file(/path/to/img.gif); Of course you can do all kinds of things like check for errors modify the images using various image modules display different images based on inout, etc, etc DMuey I need to deliver graphic files (jpg and gif) over http in the same manner that a web server would. Can anyone point me in the right direction? Setting the mime type is no problem but it's the rest that I have no experience of. In the past I've always simply done a location: /path/to/graphic but the graphics are getting cached somewhere along the line so I need to set Cache-control: no-cache and the only way I can think of to do this is if my script does the delivery itself. I don't have access to the configuration of the web server. Unless it possible to do it in .htaccess? I tried the following in .htaccess but no joy, is there a better way of doing this with .htaccess? Possibly at HTTP 1.0 server somewhere in the chain is preventing it from working? Files ~ logo\.jpg$ Header add Cache-Control no-cache /Files Files ~ logo2\.jpg$ Header add Cache-Control no-cache /Files TIA Nigel -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: not able to set repository
Pradeep Goel wrote: Hi All I am having a problem in setting the repository - can somebody tell me the reason . ppm set repository Unknown or ambiguous setting 'repository'. See 'help settings'. ppm set repository RothConsulting http://www.roth.net/perl/packages Unknown or ambiguous setting 'repository'. See 'help settings'. Hi Pradeep. Check what version of ppm you're running with ppm version I have V2.1.5, which came with ActivePerl v5.6.1. It may be time to upgrade your copy of Perl! HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Simple Regex Problem.
Rob Dixon said: $data =~ m/ ([^]*) /x; my $newdata = $1; And if the match fails? -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: not able to set repository
its 3.0.1 perl is 5.8 my time is quite bad these days :) Thanks regards Pradeep - Original Message - From: Rob Dixon [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, March 05, 2003 6:10 PM Subject: Re: not able to set repository ppm set repository RothConsulting http://www.roth.net/perl/packages Unknown or ambiguous setting 'repository'. See 'help settings'. Hi Pradeep. Check what version of ppm you're running with ppm version I have V2.1.5, which came with ActivePerl v5.6.1. It may be time to upgrade your copy of Perl! HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Simple Regex Problem.
Paul Johnson wrote: Rob Dixon said: $data =~ m/ ([^]*) /x; my $newdata = $1; And if the match fails? Well I think it's likely that you'd want to do: $data =~ m/ ([^]*) /x or die Malformed data; or at least: $data =~ m/ ([^]*) /x or next; as a mismatch inmplies that something's happening that you don't expect. But you're quite right, I should have pointed out that $1 etc. are 'sticky' and will keep their values from the last successful match. I'll go for: { my $newdata; $newdata = $1 if $data =~ m/ ([^]*) /x; : } Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: regular exp problem
Ramprasad wrote: I have a str that contains the base64 encoded string of a mail. Now this string should not contain any characters with ascii values above 128. Can i write a regex to check this Assuming you mean 'above 127' you can use the POSIX ASCII character class: die Invalid character in data if $string =~ /[^[:ascii:]]/; HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Delivering Graphics over HTTP
On Wed, 5 Mar 2003 12:39:18 -, Nigel Peck - MIS Web Design [EMAIL PROTECTED] wrote: I've done as suggested and it works fine in Mozilla but IE won't display the image: http://cgi.www.miswebdesign.com/cgi-bin/www.miswebdesign.com/logo.pl?image=l ogo Any ideas? My guess, and this is just a guess, is that IE doesn't like your header, and probably doesn't interpret the 'jpg' correctly. Try using 'jpeg' instead. My suspicion is Mozilla is correcting this, which is good and bad I suppose, depending on what the standard really is. print Content-type: image/jpg\n; http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DBI and getting values from the DB
Hello everyone, Please forgive in advance if this has already been posted...fairly new to the list as have only been on it a week. At this point I only get the digest, but just sent an email to subscribe to the full list. I'm running apache 2.0x with mod_perl on a windows 2000 server. I have a form page on the website where folks can enter a name and then search a DB looking for that name and then give back the results on another htm page. I'm hoping this is a common thing to do. Ok...the upshot is that using DBI:ODBC to access the access db works. Also, I can use CGI.pm and know that the value from the form is getting to the script. The problem lies in comparing the values from the form and the values from the DB. I keep getting no results. Here's a snippet of the code: #The CGI.pm module will take input from the form. use CGI qw(:standard ); my $name=param(name); #Connecting to DB my $dbh = DBI-connect('DBI:ODBC:opal') or die Oops! Couldn't Connect. DBI-errstr; my $sth = $dbh-prepare ('SELECT ContactName FROM Contacts WHERE ContactName=?') or die Couldn't prepare the statement: . $dbh-errstr; my @row; #DB now connected. Run statements to find information. $sth-execute(my $name); while (@row = $sth-fetchrow_array){ print @row\n; } if ($sth-rows == 0) { print No names matched `$wholename'.\n\n; } $sth-finish; print \n; --Would anybody have any ideas? I've got the Programming the DBI book as well as some others, but since I'm new to this, I may be leaving something totally out. Thanks in advance for your help and if this is a wrong post or offtopic, please let me know. thanks! -- Tony Bandy, MLS [EMAIL PROTECTED] Sys. Admin. OPAL OHIONET 1500 West Lane Ave. Columbus, OH 43221-3975 1-800-686-8975 (614) 486-2966 X19 (Emergency--614-352-9409) http://www.ohionet.org http://cat.opal-libraries.org IMPORTANT NOTICE: This electronic message, including all attachments, is intended only for the individual/company/representative addressed above, and may contain CONFIDENTIAL, PRIVILEGED, and/or TRADE SECRET INFORMATION. If you are not the intended recipient, this notification is to let you know that any use, distribution, or copying of this electronic message, including any attachments, is strictly prohibited. If you feel you have received this email in error, please contact [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: perl program control -- wvdial
On 04 Mar 2003 22:58:20 -0700, [EMAIL PROTECTED] (Jdavis) wrote: Hello, I am writing a script to help a user turn a modem on and off and adjust the routing tables on a Linux box. I am trying to call wvdial to do the dialing, but it does not give control back to my script. I call it like so if( $choice == 1){ `wvdial`; print connected; } I also have tried.. if( $choice == 1){ `wvdial`; } but nothing after `wvdial` gets ran. could someone offer me some advice...please :) ? Backticks and system will run the program until it finishes, then return control to the calling program. Exec will run the program, but never return control. What you want to do is fork and exec if($pid = fork() == 0) { exec(wvdial); } # this is all executed in the parent #... kill $pid; #to terminate wvdial You can check whether the connection is good by checking the file /var/run/ppp0.ip -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: DBI and getting values from the DB
Not a OT but there is a good maillist specially for dbi users at http://lists.perl.org/showlist.cgi?name=dbi-users Anyway try this: [snippet of your code with some modif] #The CGI.pm module will take input from the form. use CGI qw(:standard ); my $name=param(name); #Connecting to DB my $dbh = DBI-connect('DBI:ODBC:opal') or die Oops! Couldn't Connect.DBI-errstr; #qq while building sql, will avoid you lot of head aches my $sql=qq[ SELECT ContactName FROM Contacts WHERE ContactName='?' ]; my $sth = $dbh-prepare($sql) or die Couldn't prepare the statement:.$dbh-errstr; my @row; #DB now connected. Run statements to find information. #you don't need a my $name here. $sth-execute($name); while (@row = $sth-fetchrow_array){ print @row\n; } if ($sth-rows == 0){ print No names matched `$wholename'.\n\n; } $sth-finish; print \n; HTH, José. -Original Message- From: Tony Bandy [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 05, 2003 2:53 PM To: [EMAIL PROTECTED] Subject: DBI and getting values from the DB Hello everyone, Please forgive in advance if this has already been posted...fairly new to the list as have only been on it a week. At this point I only get the digest, but just sent an email to subscribe to the full list. I'm running apache 2.0x with mod_perl on a windows 2000 server. I have a form page on the website where folks can enter a name and then search a DB looking for that name and then give back the results on another htm page. I'm hoping this is a common thing to do. Ok...the upshot is that using DBI:ODBC to access the access db works. Also, I can use CGI.pm and know that the value from the form is getting to the script. The problem lies in comparing the values from the form and the values from the DB. I keep getting no results. Here's a snippet of the code: #The CGI.pm module will take input from the form. use CGI qw(:standard ); my $name=param(name); #Connecting to DB my $dbh = DBI-connect('DBI:ODBC:opal') or die Oops! Couldn't Connect. DBI-errstr; my $sth = $dbh-prepare ('SELECT ContactName FROM Contacts WHERE ContactName=?') or die Couldn't prepare the statement: . $dbh-errstr; my @row; #DB now connected. Run statements to find information. $sth-execute(my $name); while (@row = $sth-fetchrow_array){ print @row\n; } if ($sth-rows == 0) { print No names matched `$wholename'.\n\n; } $sth-finish; print \n; --Would anybody have any ideas? I've got the Programming the DBI book as well as some others, but since I'm new to this, I may be leaving something totally out. Thanks in advance for your help and if this is a wrong post or offtopic, please let me know. thanks! -- Tony Bandy, MLS [EMAIL PROTECTED] Sys. Admin. OPAL OHIONET 1500 West Lane Ave. Columbus, OH 43221-3975 1-800-686-8975 (614) 486-2966 X19 (Emergency--614-352-9409) http://www.ohionet.org http://cat.opal-libraries.org IMPORTANT NOTICE: This electronic message, including all attachments, is intended only for the individual/company/representative addressed above, and may contain CONFIDENTIAL, PRIVILEGED, and/or TRADE SECRET INFORMATION. If you are not the intended recipient, this notification is to let you know that any use, distribution, or copying of this electronic message, including any attachments, is strictly prohibited. If you feel you have received this email in error, please contact [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Delivering Graphics over HTTP
I get it in IE 5.0 ok also Netscape 7.01 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 05, 2003 7:33 AM To: Nigel Peck - MIS Web Design; Dan Muey; [EMAIL PROTECTED] Subject: RE: Delivering Graphics over HTTP On Wed, 5 Mar 2003 12:39:18 -, Nigel Peck - MIS Web Design [EMAIL PROTECTED] wrote: I've done as suggested and it works fine in Mozilla but IE won't display the image: http://cgi.www.miswebdesign.com/cgi- bin/www.miswebdesign.com/logo.pl?i mage=l ogo Any ideas? My guess, and this is just a guess, is that IE doesn't like your header, and probably doesn't interpret the 'jpg' correctly. Try using 'jpeg' instead. My suspicion is Mozilla is correcting this, which is good and bad I suppose, depending on what the standard really is. print Content-type: image/jpg\n; http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Module listing
Is there a perl command to list installed modules? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Backslash in a string
The problem still remains. Look at the small program below. The result is this: DirectionsNitprogrsourcsql DirectionsNitprogrsourcsql And I would like it to be this:\Directions\unit\progr\sourcsql .Directions.unit.progr.sourcsql Notice that it doesn't print the backslashes and it when the backslash is followed by a u, it transform in uppercase the next letter as it would do a break page if it was followed by a n. The value given to the $reprt in the program below is fetched from a database query and appears to be stored exactly like this in the table ## #!/usr/bin/perl my ($reprt); $reprt= \Directions\unit\progr\sourcsql; print $reprt.\n; # $reprt =~ s/\\//g; $reprt =~ s/[\\]/\./g; print $reprt.\n; ## Todd Wade [EMAIL PROTECTED] a écrit dans le message de news: [EMAIL PROTECTED] Beau E. Cox [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi - -Original Message- From: Guy P [mailto:[EMAIL PROTECTED] Sent: Monday, March 03, 2003 9:10 AM To: [EMAIL PROTECTED] Subject: Backslash in a string Hello, My Perl program execute a query that bring back into a variable a Windows paths initially stored in a database. I have got problems to manage the backslash. Example: Here's what is stored in the database -- \Directions\unit\progr\sourcsql I would like to get it in a variable thus I could use the Perl print function and have the same printed on the screen. Thank you! Escape the esacpe character; if $var holds your path, do: $var =~ s/\\//g; This replaces \ with \\ which will then print as \. Pretty messy, yeah? You can use a forward slash for directory seperators inside perl and it will know which file you are talking about: open( FH, 'c:/path/to/file.ext' ) or die( open failed: $! ); Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Managing the backslash in a string
Look at the small program below. The result is this: DirectionsNitprogrsourcsql DirectionsNitprogrsourcsql And I would like it to be this:\Directions\unit\progr\sourcsql .Directions.unit.progr.sourcsql Notice that it doesn't print the backslashes and it when the backslash is followed by a u, it transform in uppercase the next letter as it would do a break page if it was followed by a n. The value given to the $reprt in the program below is fetched from a database query and appears to be stored exactly like this in the table ## #!/usr/bin/perl my ($reprt); $reprt= \Directions\unit\progr\sourcsql; print $reprt.\n; # $reprt =~ s/\\//g; $reprt =~ s/[\\]/\./g; print $reprt.\n; ## Dan Muey [EMAIL PROTECTED] a écrit dans le message de news: [EMAIL PROTECTED] . Uh.. What's the problem? Are you getting an error of some kind? Are you having problems querying a database? A little context/code you're using might help. There is no conflict with having slashes in a string that is stored in a variable so You may want to expound a little more. DMuey Hello, My Perl program execute a query that bring back into a variable a Windows paths initially stored in a database. I have got problems to manage the backslash. Example: Here's what is stored in the database -- \Directions\unit\progr\sourcsql I would like to get it in a variable thus I could use the Perl print function and have the same printed on the screen. Thank you! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Module listing
On Wed, 5 Mar 2003 09:36:01 -0500, Rob [EMAIL PROTECTED] wrote: Is there a perl command to list installed modules? on Unix: find `perl -e 'print @INC;'` -name *.pm -print Gleaned from a doc, perldoc perlmodlib. I alias this like so (bash): alias listperlmods=find \`perl -e 'print \@INC\'\` -name '*.pm' -print http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Module listing
You can use the find command to find all of the .pm files in the INC dirs listed with perl -V. Do you need to check somehow if a module is installed before running a script? This should work to check in your script: eval { require foo.pm; import foo.pm; } if ($@) { die foo.pm not installed? } Luke -Original Message- From: Rob [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 05, 2003 6:36 AM To: [EMAIL PROTECTED] Subject: Module listing Is there a perl command to list installed modules? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Backslash in a string
On Wed, 5 Mar 2003 10:02:17 -0500, Guy P [EMAIL PROTECTED] wrote: The problem still remains. Look at the small program below. The result is this: DirectionsNitprogrsourcsql DirectionsNitprogrsourcsql And I would like it to be this:\Directions\unit\progr\sourcsql .Directions.unit.progr.sourcsql In your sample script, it is when you set reprt that the \'s are being interpolated. Add use strict, use warnings and you will see this, identified by the warnings. Are you sure when you have retrieved the variable it still contains the backslashes? You can test for this: if ($reprt =~ /\\/) { # has backslashes } else { # doesn't } My suspicion is that it is getting interpolated somewhere between the database and when you retrieve it, is it possible to check this path? http://danconia.org ## #!/usr/bin/perl my ($reprt); $reprt= \Directions\unit\progr\sourcsql; print $reprt.\n; # $reprt =~ s/\\//g; $reprt =~ s/[\\]/\./g; print $reprt.\n; ## -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Can't fork using open
=Beginning of the citation== '-' is not recognized as an internal or external command, operable program or batch file. =The end of the citation I use windows xp, activestate perl build 804. Can anyone explain why I'm getting this error? I know that windows version of perl supports forking, but does that error mean it does not support forking with open? How can I alternatively intersept STDOUT? Not sure if you got an answer to this, but you can not fork opens in Win32 does not work like unix. There are ways to do it by hand, but i have found better results using the below modules. Take a look at the followng docs( you can google for them): Win32::Process Win32::IPC Win32::Daemon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Managing the backslash in a string
## #!/usr/bin/perl my ($reprt); $reprt= \Directions\unit\progr\sourcsql; print $reprt.\n; # $reprt =~ s/\\//g; $reprt =~ s/[\\]/\./g; print $reprt.\n; my $reprt= '\Directions\unit\progr\sourcsql'; print $reprt.\n; $reprt =~ s/[\\]/./g; print $reprt.\n; That should work. Note the use of ''. Luke -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cpan problems
Sometimes I really hate using cpan. It's 'help' isn't much. It's been since last october that I touched my cpan stuff, and now it's out of date. It's currently at v1.60. I wanted to upgrade, so I did a make Bundle::CPAN, which is supposed to do a get first. BUT, my cpan thinks that it needs to get v1.63, Can't open CPAN-1.63.tar.gz: No such file or directory Bad luck... Still failed! Can't access URL ftp://ftp.perl.org/pub/CPAN/authors/id/A/AN/ANDK/CPAN-1.63.tar.gz. Please check, if the URLs I found in your configuration file () are valid. The urllist can be edited. E.g. with 'o conf urllist push ftp://myurl/' Could not fetch authors/id/A/AN/ANDK/CPAN-1.63.tar.gz Giving up on '/home/deb/.cpan/sources/authors/id/A/AN/ANDK/CPAN-1.63.tar.gz' Note: Current database in memory was generated on Sun, 20 Oct 2002 21:52:34 GMT cpan Well, Duh. v1.63 has been superceded by v1.70 - so how do I tell cpan to grab v1.70?? One more question - if I finally get Bundle::CPAN upgraded to the latest and greatest, will that also update my static lists on what is available on CPAN? I tried to get File::Slurp, and it wants to get an older version that no longer exists - same as the cpan bundle. I guess all I really want to do is update the file lists, but I don't know how to do that. Thanks, deb -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- There are 010 types of people in the world: those who understand binary, and those who don't. ô¿ô 111,111,111 x 111,111,111 = 12,345,678,987,654,321 (decimal) ~ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
single line condition statement with semicolon
Hello What I want to do is assign the value of $_[1] to $m unless it's empty then assign it 'text/plain' This currently works but I want to do a one liner I think you can do that with a colon but I can't seem to find the syntax $m = 'text/plain'; $m = $_[1] unless(!$_[1]); Somehting like $m = $_[1] unless(!$_[1]) :$m = 'text/plain'; But I can get it right, any assistance would be much appreciated. Thanks Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: cpan problems
On Wed, 5 Mar 2003 08:25:30 -0800, Deb [EMAIL PROTECTED] wrote: Sometimes I really hate using cpan. It's 'help' isn't much. It's been since last october that I touched my cpan stuff, and now it's out of date. It's currently at v1.60. I wanted to upgrade, so I did a make Bundle::CPAN, which is supposed to do a get first. I wonder if the fact that you are using 'make' instead of 'install' is causing this problem. It might only try and make the last version it knew about, rather than looking to see what the newest version is. Try doing install Bundle::CPAN instead. BUT, my cpan thinks that it needs to get v1.63, Can't open CPAN-1.63.tar.gz: No such file or directory Bad luck... Still failed! Can't access URL ftp://ftp.perl.org/pub/CPAN/authors/id/A/AN/ANDK/CPAN-1.63.tar.gz. Please check, if the URLs I found in your configuration file () are valid. The urllist can be edited. E.g. with 'o conf urllist push ftp://myurl/' You should enter more than one url when configuring CPAN, the mirror you have listed above is a very busy one and I can not access it currently because there are to many users. Try adding 6-7 if you run into this problem consistently, try one that is close to your geographical location as well. You might try blowing away your .cpan and reconfiguring, who knows. Just a couple of thoughts, HTH, http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cpan problems
[EMAIL PROTECTED] [EMAIL PROTECTED] had this to say, I wonder if the fact that you are using 'make' instead of 'install' is causing this problem. It might only try and make the last version it knew about, rather than looking to see what the newest version is. Try doing install Bundle::CPAN instead. Tried. no luck. You should enter more than one url when configuring CPAN, the mirror you have listed above is a very busy one and I can not access it currently because there are to many users. Try adding 6-7 if you run into this problem consistently, try one that is close to your geographical location as well. Yeah, you're right, but I can get there no problem. You might try blowing away your .cpan and reconfiguring, who knows. Thought about that, but I'd rather solve the problem of updating the filelist information, and work through this. Just a couple of thoughts, HTH, Thanks, deb -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- There are 010 types of people in the world: those who understand binary, and those who don't. ô¿ô 111,111,111 x 111,111,111 = 12,345,678,987,654,321 (decimal) ~ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cpan problems
It was Wednesday, March 05, 2003 when Deb took the soap box, saying: : Sometimes I really hate using cpan. It's 'help' isn't much. It's been since : last october that I touched my cpan stuff, and now it's out of date. It's : currently at v1.60. I wanted to upgrade, so I did a make Bundle::CPAN, : which is supposed to do a get first. : : BUT, my cpan thinks that it needs to get v1.63, Sounds like you need to update your CPAN index. Should solve all your problems. Use the 'reload index' command first. Also, you should consider using CPANPLUS (with the cpanp shell utility), it's the next generation CPAN interface. Casey West -- Shooting yourself in the foot with Assembly Language You crash the OS and overwrite the root disk. The system administrator arrives and shoots you in the foot. After a moment of contemplation, the administrator shoots himself in the foot and then hops around the room rabidly shooting at everyone in sight. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: single line condition statement with semicolon
$m = $_[1] unless(!$_[1]); This is scary itself, a double negative unless is a bit confusing. if would have been better I think. I want to do a one liner my $m = $_[1] || 'text/plain'; You can have as many conditions as you want, the first that is true (not blank, zero or undef) will be used. Rob -Original Message- From: Dan Muey [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 05, 2003 11:33 AM To: [EMAIL PROTECTED] Subject: single line condition statement with semicolon Hello What I want to do is assign the value of $_[1] to $m unless it's empty then assign it 'text/plain' This currently works but I want to do a one liner I think you can do that with a colon but I can't seem to find the syntax $m = 'text/plain'; $m = $_[1] unless(!$_[1]); Somehting like $m = $_[1] unless(!$_[1]) :$m = 'text/plain'; But I can get it right, any assistance would be much appreciated. Thanks Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cpan problems
Casey West [EMAIL PROTECTED] had this to say, Sounds like you need to update your CPAN index. Should solve all your problems. Use the 'reload index' command first. Also, you should consider using CPANPLUS (with the cpanp shell utility), it's the next generation CPAN interface. Ah! That did the trick. I didn't know about cpanplus. Will have to look into that when my current project is complete. Thanks for the tip! deb -- Contrary to popular opinion, Unix is user friendly, It just happens to be very selective about who it makes friends with. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: single line condition statement with semicolon
I think something like: if( $_[1] ) ? $m = $_[1] : $m ='text/plain'; might work. Try looking up the perl 'trinary' operator. Dan Muey [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] com... Hello What I want to do is assign the value of $_[1] to $m unless it's empty then assign it 'text/plain' This currently works but I want to do a one liner I think you can do that with a colon but I can't seem to find the syntax $m = 'text/plain'; $m = $_[1] unless(!$_[1]); Somehting like $m = $_[1] unless(!$_[1]) :$m = 'text/plain'; But I can get it right, any assistance would be much appreciated. Thanks Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cpan problems
Deb said: You might try blowing away your .cpan and reconfiguring, who knows. Thought about that, but I'd rather solve the problem of updating the filelist information, and work through this. Even more radical, you might want to make the jump to CPANPLUS. CPANPLUS will eventually replace CPAN. I never had too much luck with CPAN (although I didn't put in too much effort), but CPANPLUS has just worked for me. -- There are 010 types of people in the world: those who understand binary, and those who don't. And the other 6? -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: single line condition statement with semicolon
Hi - -Original Message- From: Dan Muey [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 05, 2003 6:33 AM To: [EMAIL PROTECTED] Subject: single line condition statement with semicolon Hello What I want to do is assign the value of $_[1] to $m unless it's empty then assign it 'text/plain' This currently works but I want to do a one liner I think you can do that with a colon but I can't seem to find the syntax $m = 'text/plain'; $m = $_[1] unless(!$_[1]); Somehting like $m = $_[1] unless(!$_[1]) :$m = 'text/plain'; But I can get it right, any assistance would be much appreciated. Thanks Dan $m = $_[1] ? $_[1] : 'text/plain'; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: single line condition statement with semicolon
$m = 'text/plain'; $m = $_[1] unless(!$_[1]); Somehting like $m = $_[1] unless(!$_[1]) :$m = 'text/plain'; But I can get it right, any assistance would be much appreciated. Thanks Dan $m = $_[1] ? $_[1] : 'text/plain'; Excellent!! I also received the suggestion my $m = $_[1] || 'text/plain'; Any body have any pros/cons about which would be more efficient/better ?? If not thanks for the help!! DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: single line condition statement with semicolon
$m = $_[1] unless(!$_[1]); This is scary itself, a double negative unless is a bit confusing. if would have been better I think. Good point I want to do a one liner my $m = $_[1] || 'text/plain'; Oh!! I never thought of using || for an assignment. Sweet idea. Thanks Dan You can have as many conditions as you want, the first that is true (not blank, zero or undef) will be used. Rob -Original Message- From: Dan Muey [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 05, 2003 11:33 AM To: [EMAIL PROTECTED] Subject: single line condition statement with semicolon Hello What I want to do is assign the value of $_[1] to $m unless it's empty then assign it 'text/plain' This currently works but I want to do a one liner I think you can do that with a colon but I can't seem to find the syntax $m = 'text/plain'; $m = $_[1] unless(!$_[1]); Somehting like $m = $_[1] unless(!$_[1]) :$m = 'text/plain'; But I can get it right, any assistance would be much appreciated. Thanks Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: cpan problems
I've also had trouble using CPAN and so I did the reload index mentioned in this thread and that seemed to go thought but I s til can't get it to go. It's the same error everytime ( diff module names of course ) :: could not open y... There is a direct perl -MCAPN =e shell; CPAN install Bundel::CPAN ... cannot open y/sources/authors/id/A/AN/ANDK/CPAN-1.70.tar.gz: no such file Could not open y/build/ANDK000/Makefile.PL at /usr/libdata/perl/5.00503/CPAN.pm line 3642 I'm root when I do this. Do I need to be in a special directory when I do it? ( I also tried it in root's home directory, same thing ) Permissions :: ([EMAIL PROTECTED](~/perl_cpan_mod ):120)# ls -al y/ total 8 drwxr-xr-x 4 root wheel 512 Mar 5 11:11 . drwxr-xr-x 3 root wheel 512 Mar 5 11:10 .. drwxr-xr-x 2 root wheel 512 Mar 5 11:11 build drwxr-xr-x 4 root wheel 512 Mar 5 11:10 sources ([EMAIL PROTECTED](~/perl_cpan_mod ):121)# Or whatelse could I be fumbling up ?? Thanks Dan -- DETAILS -- ([EMAIL PROTECTED](/home/dmuey):101)# perl -MCPAN -e shell; cpan shell -- CPAN exploration and modules installation (v1.48) ReadLine support available (try ``install Bundle::CPAN'') cpan relaod index Unknown command 'relaod'. Type ? for help. cpan reload index CPAN: LWP::UserAgent loaded ok Fetching with LWP: ftp://mirrors.phenominet.com/pub/CPAN/authors/01mailrc.txt.gz Going to read y/sources/authors/01mailrc.txt.gz CPAN: Compress::Zlib loaded ok Fetching with LWP: ftp://mirrors.phenominet.com/pub/CPAN/modules/02packages.details.txt.gz Going to read y/sources/modules/02packages.details.txt.gz Scanning cache y/build for sizes There's a new CPAN.pm version (v1.70) available! You might want to try install Bundle::CPAN reload cpan without quitting the current session. It should be a seamless upgrade while we are running... Fetching with LWP: ftp://mirrors.phenominet.com/pub/CPAN/modules/03modlist.data.gz Going to read y/sources/modules/03modlist.data.gz cpan install Bundle::CPAN Fetching with LWP: ftp://mirrors.phenominet.com/pub/CPAN/authors/id/A/AN/ANDK/CPAN-1.70.tar.gz CPAN: MD5 security checks disabled because MD5 not installed. Please consider installing the MD5 module. cannot open y/sources/authors/id/A/AN/ANDK/CPAN-1.70.tar.gz: no such file Could not open y/build/ANDK000/Makefile.PL at /usr/libdata/perl/5.00503/CPAN.pm line 3642 cpan exit Lockfile removed. ([EMAIL PROTECTED](/home/dmuey):102)# --- end details --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
removing elements from an array
Hi, I would like to remove elements from an array that are eq to string '0' The following does not work, can someone shed some light on the proper way to do this. Thanks! Dave G. #!/usr/bin/perl -w @bag_quantity = ( '0', 1, '0', '0', '0', '0', '0', '0', '0' ); for (@bag_quantity){ shift if $_ eq '0'; } print @bag_quantity\n; == Cora Connection: Your West African Music Source Resources, Recordings, Instruments More! http://www.coraconnection.com/ == -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: removing elements from an array
Hi, I would like to remove elements from an array that are eq to string '0' The following does not work, can someone shed some light on the proper way to do this. Thanks! Dave G. look at the grep function: perldoc -f grep -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: removing elements from an array
You don't want to use shift in the middle of a for or foreach. shift removes the first element of the array, and you're just asking for trouble mucking with the structure of an array as you're cycling through it. delete() won't work either, as it pretty much just marks the element as undef and doesn't really remove it. I think you want something closer to this: @bag_quantity = grep( whatever... ); check out perldoc -f grep -Original Message- From: David Gilden [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 05, 2003 9:39 AM To: [EMAIL PROTECTED] Subject: removing elements from an array Hi, I would like to remove elements from an array that are eq to string '0' The following does not work, can someone shed some light on the proper way to do this. Thanks! Dave G. #!/usr/bin/perl -w @bag_quantity = ( '0', 1, '0', '0', '0', '0', '0', '0', '0' ); for (@bag_quantity){ shift if $_ eq '0'; } print @bag_quantity\n; == Cora Connection: Your West African Music Source Resources, Recordings, Instruments More! http://www.coraconnection.com/ == -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: removing elements from an array
I would like to remove elements from an array that are eq to string '0' The following does not work, can someone shed some light on the proper way to do this. Thanks! Dave G. #!/usr/bin/perl -w @bag_quantity = ( '0', 1, '0', '0', '0', '0', '0', '0', '0' ); for (@bag_quantity){ shift if $_ eq '0'; } print @bag_quantity\n; I'm sure there are several ways to do this, and off the top of my head I don't know which is fastest. 1: @bag_quantity = grep { $_ ne '0' } @bag_quantity; 2: my @new_bq; for (@bq) { push @new_bq, $_ if $_ ne '0'; } Luke -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Can't fork using open
James Kipp wrote: =Beginning of the citation== '-' is not recognized as an internal or external command, operable program or batch file. =The end of the citation I use windows xp, activestate perl build 804. Can anyone explain why I'm getting this error? I know that windows version of perl supports forking, but does that error mean it does not support forking with open? How can I alternatively intersept STDOUT? Not sure if you got an answer to this, but you can not fork opens in Win32 does not work like unix. No, but given that a lot of work has been put into ithreads in V5.8 to make threading platform-independent (or at least functional on Windows) I'm surprised that a language feature like this hasn't been implemented. As well as that I can see nowhere in the docs where it mentions the lack of Windows support for this feature. I suppose it could be dependent on the options enabled in the Perl build, which are fixed for ActivePerl because it is a binary distribution. I'd be interested to hear if anybody has any knowledge in this area. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Backslash in a string
Guy P wrote: The problem still remains. Look at the small program below. The result is this: DirectionsNitprogrsourcsql DirectionsNitprogrsourcsql And I would like it to be this:\Directions\unit\progr\sourcsql .Directions.unit.progr.sourcsql Notice that it doesn't print the backslashes and it when the backslash is followed by a u, it transform in uppercase the next letter as it would do a break page if it was followed by a n. The value given to the $reprt in the program below is fetched from a database query and appears to be stored exactly like this in the table ## #!/usr/bin/perl my ($reprt); $reprt= \Directions\unit\progr\sourcsql; print $reprt.\n; # $reprt =~ s/\\//g; $reprt =~ s/[\\]/\./g; print $reprt.\n; ## your reg. exp is fine except that you put $reprt in double quote. try: #!/usr/bin/perl -w use strict; my $s = '\Directions\unit\progr\sourcsql\new'; print $s\n; $s =~ s#\\#\.#g; print $s\n; __END__ prints: \Directions\unit\progr\sourcsql\n .Directions.unit.progr.sourcsql.n when you get your string back from db, do not quote it like you did. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: removing elements from an array
Why not use a foreach, test the element, then undef it when found? Or, use foreach, test the element, if != '0', then push it onto another array? David Gilden [EMAIL PROTECTED] had this to say, Hi, I would like to remove elements from an array that are eq to string '0' The following does not work, can someone shed some light on the proper way to do this. Thanks! Dave G. #!/usr/bin/perl -w @bag_quantity = ( '0', 1, '0', '0', '0', '0', '0', '0', '0' ); for (@bag_quantity){ shift if $_ eq '0'; } print @bag_quantity\n; == Cora Connection: Your West African Music Source Resources, Recordings, Instruments More! http://www.coraconnection.com/ == -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- There are 010 types of people in the world: those who understand binary, and those who don't. ô¿ô 111,111,111 x 111,111,111 = 12,345,678,987,654,321 (decimal) ~ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: removing elements from an array
I would like to remove elements from an array that are eq to string '0' The following does not work, can someone shed some light on the proper way to do this. Thanks! Dave G. #!/usr/bin/perl -w @bag_quantity = ( '0', 1, '0', '0', '0', '0', '0', '0', '0' ); for (@bag_quantity){ shift if $_ eq '0'; } print @bag_quantity\n; In the spirit of TMTOWTDI (found this on usenet): for my $i (0 .. $#bq) { if ($bq[$i] eq '0') { splice @bq, $i, 1; redo; } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Module listing
use ExtUtils::Installed; my $instmod = ExtUtils::Installed-new(); foreach my $module ($instmod-modules()) { my $version = $instmod-version($module) || ???; print $module -- $version\n; } Rob [EMAIL PROTECTED] 3/5/2003 9:36:01 AM Is there a perl command to list installed modules? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Module listing
Rob wrote: Is there a perl command to list installed modules? This is a FAQ. As far as I'm concerned, by far the best way is to use ExtUtils::Installed like this: use ExtUtils::Installed; print $_\n foreach ExtUtils::Installed-new-modules; which does a lot more than just list the *.pm files in @INC. Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Module listing
Or for a really quick and dirty list :: perl -e 'use ExtUtils::Installed;for (ExtUtils::Installed-new()-modules()){print $_ \n;}' DMuey -Original Message- From: John Mooney [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 05, 2003 11:55 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: Module listing use ExtUtils::Installed; my $instmod = ExtUtils::Installed-new(); foreach my $module ($instmod-modules()) { my $version = $instmod-version($module) || ???; print $module -- $version\n; } Rob [EMAIL PROTECTED] 3/5/2003 9:36:01 AM Is there a perl command to list installed modules? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Module listing
Rob Dixon wrote: Rob wrote: Is there a perl command to list installed modules? This is a FAQ. As far as I'm concerned, by far the best way is to use ExtUtils::Installed like this: use ExtUtils::Installed; print $_\n foreach ExtUtils::Installed-new-modules; which does a lot more than just list the *.pm files in @INC. Cheers, Rob I attemp it but get the following error: Can't find unicode character property definition via main-e or e.pl at unicode/Is/e.pl line 0 But can find no e.pl and unsure where to even attempt to see where the error is coming from. Running as 5.6.0 build 623 (I know it is old, but it is what we a running here). Wags ;) ** This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: single line condition statement with semicolon
Dan Muey wrote: $m = $_[1] ? $_[1] : 'text/plain'; Excellent!! I also received the suggestion my $m = $_[1] || 'text/plain'; Any body have any pros/cons about which would be more efficient/better ?? I second Rob H's version - the second one - as being more Perlish. It also avoids repeating $_[1] and is likely, if anything, to be faster. :) Rob D -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: script to mimic the cusor movement on a terminer or shell
Automating interactive programs take some extra work. Does the program accept input immediately after it starts, or do you need to wait until the screen is drawn? I cut my teeth on this sort of thing using expect/tcl, and it looks like there are Perl modules that can also let you do sent/expect sequences so that everything is properly synchronized. -- Danny Faught Tejas Software Consulting http://tejasconsulting.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Can't fork using open
Not sure if you got an answer to this, but you can not fork opens in Win32 does not work like unix. No, but given that a lot of work has been put into ithreads in V5.8 to make threading platform-independent (or at least functional on Windows) I'm surprised that a language feature like this hasn't been implemented. As well as that I can see nowhere in the docs where it mentions the lack of Windows support for this feature. I suppose it could be dependent on the options enabled in the Perl build, which are fixed for ActivePerl because it is a binary distribution. I'd be interested to hear if anybody has any knowledge in this area. I do believe you can fork a child with an open in Win, but i am not sure if it was just a matter of syntax or something else. I am going to research this a bit. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
using ParseExcel::Simple to get worksheet name
im trying to use Spreadsheet::ParseExcel::Simple to return the name of the worksheet. but all i get is something such as: Spreadsheet::ParseExcel::Simple::_Sheet=HASH(0x39b8918) what am i doing wrong? code: use strict; use Spreadsheet::ParseExcel::Simple; my $wkbook = x:/traffic/temp_assay/site.xls; my (@sheets,$dest,$sheet,$year,$date,@wktemp,$ath,$bth,$cth); my $xls = Spreadsheet::ParseExcel::Simple-read($wkbook); foreach my $sheet ($xls-sheets) { @sheets = $xls-sheets; while ($sheet-has_data) { my @data = $sheet-next_row; my $sheet = $sheets[0]; print $sheet\n; } thanks Antonio Quinonez Traffic Analyst Accessline Communications -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using ParseExcel::Simple to get worksheet name
.--[ [EMAIL PROTECTED] wrote (2003/03/05 at 11:21:20) ]-- | | im trying to use Spreadsheet::ParseExcel::Simple to return the name of the | worksheet. | but all i get is something such as: | Spreadsheet::ParseExcel::Simple::_Sheet=HASH(0x39b8918) | | what am i doing wrong? | | code: | | use strict; | use Spreadsheet::ParseExcel::Simple; | my $wkbook = x:/traffic/temp_assay/site.xls; | | my (@sheets,$dest,$sheet,$year,$date,@wktemp,$ath,$bth,$cth); | my $xls = Spreadsheet::ParseExcel::Simple-read($wkbook); | foreach my $sheet ($xls-sheets) { | @sheets = $xls-sheets; | while ($sheet-has_data) { | my @data = $sheet-next_row; | my $sheet = $sheets[0]; | print $sheet\n; | } | `- I haven't looked at this much, but I'm betting it has to do with the fact you use several different my'ed versions of the scalar '$sheet' throughout. Try naming them something unique based upon what they hold and I bet you'll work your own problem out. - Frank Wiles [EMAIL PROTECTED] http://frank.wiles.org - -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: perl program control -- wvdial
On Wed, 2003-03-05 at 07:19, zentara wrote: On 04 Mar 2003 22:58:20 -0700, [EMAIL PROTECTED] (Jdavis) wrote: Hello, I am writing a script to help a user turn a modem on and off and adjust the routing tables on a Linux box. I am trying to call wvdial to do the dialing, but it does not give control back to my script. I call it like so if( $choice == 1){ `wvdial`; print connected; } I also have tried.. if( $choice == 1){ `wvdial`; } but nothing after `wvdial` gets ran. could someone offer me some advice...please :) ? Backticks and system will run the program until it finishes, then return control to the calling program. Exec will run the program, but never return control. What you want to do is fork and exec if($pid = fork() == 0) { exec(wvdial); } # this is all executed in the parent #... kill $pid; #to terminate wvdial You can check whether the connection is good by checking the file /var/run/ppp0.ip Thanks all who replied. I dont have a modem or wvdial so when i go to the cust house today i will try the new methods suggested. -- jd [EMAIL PROTECTED] Bad spellers of the world untie! I can't tell if I have worked all my life or if I have never worked a single day of my life Miguel de Icaza -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Can't fork using open
Vyacheslav Nadvorny wrote: I tried to run perlopentut example for STDOUT processing but got just this: =Beginning of the citation== '-' is not recognized as an internal or external command, operable program or batch file. =The end of the citation I use windows xp, activestate perl build 804. Can anyone explain why I'm getting this error? I know that windows version of perl supports forking, but does that error mean it does not support forking with open? How can I alternatively intersept STDOUT? =Beginning of the citation== #! c:/perl/bin/perl.exe -w head(100); while () { print; } sub head { my $lines = shift || 20; return unless $pid = open(STDOUT, |-); die cannot fork: $! unless defined $pid; while (STDIN) { print; last if --$lines 0; } exit; } =The end of the citation this's a known issue on the windos platform. solution is at: http://www.perldoc.com/perl5.8.0/pod/perlfork.html and then goes down to the section: Forking pipe open() not yet implemented david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Can't fork using open
No, but given that a lot of work has been put into ithreads in V5.8 to make threading platform-independent (or at least functional on Windows) I'm surprised that a language feature like this hasn't been implemented. As well as that I can see nowhere in the docs where it mentions the lack of Windows support for this feature. I suppose it could be dependent on the options enabled in the Perl build, which are fixed for ActivePerl because it is a binary distribution. I'd be interested to hear if anybody has any knowledge in this area. I do believe you can fork a child with an open in Win, but i am not sure if it was just a matter of syntax or something else. I am going to research this a bit. I just test ran the below and it worked fine. I am running Win2k Pro, AS Perl 5.6.1 build 630: code adapted from the perlipd doc -- $parent = $$; print parent: $parent\n; $pid = open(STATUS, netstat -an 21 |) || die can't fork: $!; while (STATUS) { #next if /^(tcp|udp)/i; } print child: $pid\n; close STATUS || die bad netstat: $! $?; --- prints: C:\testperl test1.pl parent: 1792 child: 1648 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to look into every subdirectory
I need to make an HTML page that lists all files and directories and then links to them. The following script, with a subroutine, looks like what I need. I should just need to add some html tags to the Print statements. Does that sound right to you all? Or do you have better suggestions? (I'm a real beginner at Perl, but my job has suddenly starting requiring lots of perl scripts!) --Deborah (I asked this question a while back, but my email messages got messed up and I can't find the answer that I got.) -Original Message- From: Beau E. Cox [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:29 PM To: Prasad Karpur; [EMAIL PROTECTED] Subject: RE: How to look into every subdirectory Hi - -Original Message- From: Prasad Karpur [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:18 AM To: [EMAIL PROTECTED] Subject: How to look into every subdirectory I am new to Perl and would like to know how to look into every subdirectory. Any help would be greatly appreciated. #!/usr/bin/perl #use strict; use Cwd; my $curr = cwd(); opendir(CURRDIR, $curr) or die can't open directory ($!), exiting.\n; my @files = readdir(CURRDIR); #closedir(CURRDIR); foreach my $file (sort @files) { next if $file eq '.' || $file eq '..'; next if !-d $file; if (-d $file) { print $file/\n; #Puts a slash in front of every directory it encounters } else { print $file\n; } } closedir(CURDIR); Just use a recursive subroutine to traverse your directory tree from any starting point: traverse (cwd()); sub traverse { my $dir = shift; $dir .= '/' unless $dir =~ m{/$}; opendir (DIR, $dir) || die unable to open directory $dir: $!\n; my @contents = readdir (DIR); closedir (DIR); for my $item (sort @contents) { my $di = $dir$item; next unless (-d $di); next if ($item eq '.' or $item eq '..'); print dir: $di\n; traverse ($di); } for my $item (sort @contents) { my $di = $dir$item; next if (-d $di); print file: $di\n; } } Try the above; WARNING: may contain typos! :) Also - check out File::Find on CPAN. Aloha = Beau; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help with File Handle --thanks
I thank those who have answered my request--let me see if I can summarize the recommendations: David Wagner recommended that I reform the call using cp: . use File::Copy cp; $n=FileHandle-new(/dev/null,r); cp($n,x);' which is not what you are trying. You are trying to use an already open file and that I don't believe is the context of what I see in the doc. The group can correct me ( and they will) if I am wrong. ... To which Rod Dixon replied that this suggestion would only read from a dev/null. Rod also added that I can't use the move command referencing a File Handle because (1) the File Handle's contents were still buffered and (2) this command can't succeed because I won't be able to delete a still open file handle using a move. (By the way, at this point in the program I hadn't written the file handle to a file with a close, else I wouldn't have tried this approach at all). Joseph Newton affirmed Dixon's point and essentially said that I was crazy to want to copy or move a file handle even if I could. What I thought I could do based on the documentation of File::Copy was copy OR move a file handle regardless of the mode used to open it originally or whether it'd been flushed---I had my reasons, including the intention to write the results of the program's standard error and some other history to a log file locally and to concatenate that local logfile into a separate consolidated log file. I thought using File::Copy would allow me to forego all the connection overhead associated with FTP --since all remote servers and the destination server are Win-based, plus allow me to send multiple files a la move without having to remove the files successfully copied. Whether this approach is good design or not, I'll reconsider based on the feedback, but there was a method to my madness. As I said originally, wheh I read this snippet from the File::Copy documentation, it appeared to me that it is possible to copy/move a FH--no one has told me exactly why file:copy with a FH isn't possible if it works as intended- : --File Copy doc snippet begins here copy(file1,file2); copy(Copy.pm,\*STDOUT);' move(/dev1/fileA,/dev2/fileB); use POSIX; use File::Copy cp; $n = FileHandle-new(/a/file,r); cp($n,x);' DESCRIPTION The File::Copy module provides two basic functions, copy and move, which are useful for getting the contents of a file from one place to another. * The copy function takes two parameters: a file to copy from and a file to copy to. Either argument may be a string, a FileHandle reference or a FileHandle glob. Obviously, if the first argument is a filehandle of some sort, it will be read from, and if it is a file *name* it will be opened for reading. Likewise, the second argument will be written to (and created if need be). Trying to copy a file on top of itself is a fatal error. end of quoted documentation So I thought that using a FileHandle was permissible as a move, copy or cp command. I wasn't trying to write to another File Handle so it looked acceptable. I will forego this approach and close my log file, and use Net::FTP or File::Copy against the files created. Thanks all. Jeff Smith -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Can't fork using open
I've used Win32::Process to do what you're trying to do-esp. when I wanted a process to go off and do it's thing independently, then return immediately to the calling Perl module for other functions and housekeeping. Backticking and system calls didn't do what I wanted to do, esp. when the forked process was not guaranteed to return in any set time. Win32:Process does that plus a host of other process controls. -Original Message- From: Kipp, James [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 05, 2003 2:14 PM To: 'Rob Dixon'; [EMAIL PROTECTED] Subject: RE: Can't fork using open Not sure if you got an answer to this, but you can not fork opens in Win32 does not work like unix. No, but given that a lot of work has been put into ithreads in V5.8 to make threading platform-independent (or at least functional on Windows) I'm surprised that a language feature like this hasn't been implemented. As well as that I can see nowhere in the docs where it mentions the lack of Windows support for this feature. I suppose it could be dependent on the options enabled in the Perl build, which are fixed for ActivePerl because it is a binary distribution. I'd be interested to hear if anybody has any knowledge in this area. I do believe you can fork a child with an open in Win, but i am not sure if it was just a matter of syntax or something else. I am going to research this a bit. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: using ParseExcel::Simple to get worksheet name
[EMAIL PROTECTED] wrote: im trying to use Spreadsheet::ParseExcel::Simple to return the name of the worksheet. but all i get is something such as: Spreadsheet::ParseExcel::Simple::_Sheet=HASH(0x39b8918) what am i doing wrong? code: use strict; use Spreadsheet::ParseExcel::Simple; my $wkbook = x:/traffic/temp_assay/site.xls; my (@sheets,$dest,$sheet,$year,$date,@wktemp,$ath,$bth,$cth); my $xls = Spreadsheet::ParseExcel::Simple-read($wkbook); foreach my $sheet ($xls-sheets) { @sheets = $xls-sheets; while ($sheet-has_data) { my @data = $sheet-next_row; my $sheet = $sheets[0]; print $sheet\n; } thanks Antonio Quinonez I pulled this from the doc as a sample script. I ran it on my machine and it gave me the right name. my $oExcel = new Spreadsheet::ParseExcel;#1.1 Normal Excel97 my $oBook = $oExcel-Parse('myspread.xls'); my($iR, $iC, $oWkS, $oWkC); print FILE :, $oBook-{File} , \n; print COUNT :, $oBook-{SheetCount} , \n; print AUTHOR:, $oBook-{Author} , \n; for(my $iSheet=0; $iSheet $oBook-{SheetCount} ; $iSheet++) { $oWkS = $oBook-{Worksheet}[$iSheet]; print - SHEET:, $oWkS-{Name}, \n; for(my $iR = $oWkS-{MinRow} ; defined $oWkS-{MaxRow} $iR = $oWkS-{MaxRow} ; $iR++) { for(my $iC = $oWkS-{MinCol} ; defined $oWkS-{MaxCol} $iC = $oWkS-{MaxCol} ; $iC++) { $oWkC = $oWkS-{Cells}[$iR][$iC]; print ( $iR , $iC ) =, $oWkC-Value, \n if($oWkC); } } } Wags ;) ** This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Can't fork using open
I just test ran the below and it worked fine. I am running Win2k Pro, AS Perl 5.6.1 build 630: code adapted from the perlipd doc -- $parent = $$; print parent: $parent\n; $pid = open(STATUS, netstat -an 21 |) || die can't fork: $!; while (STATUS) { #next if /^(tcp|udp)/i; } print child: $pid\n; close STATUS || die bad netstat: $! $?; --- hmm.. The results weren't so good from the write side. It seems the fork and spawn of the child works fine, however (as Jeff Smith mentioned in his post) the forked process doesn't seem to return or at least in any set time. The code below spawns the child but never returns: open(TEST, | notepad.exe) || die can't fork: $!; print TEST stuff\n; close TEST || die bad cmd: $! $?; notepad opens but it never returns to do the write. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to look into every subdirectory
I need to make an HTML page that lists all files and directories and then links to them. The following script, with a subroutine, looks like what I need. I should just need to add some html tags to the Print statements. Does that sound right to you all? Or do you have better suggestions? (I'm a real beginner at Perl, but my job has suddenly starting requiring lots of perl scripts!) Sounds like a cool job! Here's what I'd do to get a list of links to all the files and directories and make an html page out of it :: #!/usr/bin/perl use strict; use warnings; use CGI qw/:standard/; use File::Slurp; my $dir = '.'; # hardcoded, from input, from function like cwd(), etc... print header(); my @files = read_dir($dir); foreach my $f(@files) { print \\#149\; a href=\$f\ $f /a br \n; } Then from there you can get fancy like checking for the file type and displaying different icons for each one, Having alist of files/types to not display links to, taking directories and making a list of files with links in each of them also, and on and on. You could also add a header and footer tyo make it look ike the rest of your site Perl is awesome!! Learn how to use modules, it's tricky at first but you'll save yourself lots of time. DMuey --Deborah (I asked this question a while back, but my email messages got messed up and I can't find the answer that I got.) -Original Message- From: Beau E. Cox [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:29 PM To: Prasad Karpur; [EMAIL PROTECTED] Subject: RE: How to look into every subdirectory Hi - -Original Message- From: Prasad Karpur [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:18 AM To: [EMAIL PROTECTED] Subject: How to look into every subdirectory I am new to Perl and would like to know how to look into every subdirectory. Any help would be greatly appreciated. #!/usr/bin/perl #use strict; use Cwd; my $curr = cwd(); opendir(CURRDIR, $curr) or die can't open directory ($!), exiting.\n; my @files = readdir(CURRDIR); #closedir(CURRDIR); foreach my $file (sort @files) { next if $file eq '.' || $file eq '..'; next if !-d $file; if (-d $file) { print $file/\n; #Puts a slash in front of every directory it encounters } else { print $file\n; } } closedir(CURDIR); Just use a recursive subroutine to traverse your directory tree from any starting point: traverse (cwd()); sub traverse { my $dir = shift; $dir .= '/' unless $dir =~ m{/$}; opendir (DIR, $dir) || die unable to open directory $dir: $!\n; my @contents = readdir (DIR); closedir (DIR); for my $item (sort @contents) { my $di = $dir$item; next unless (-d $di); next if ($item eq '.' or $item eq '..'); print dir: $di\n; traverse ($di); } for my $item (sort @contents) { my $di = $dir$item; next if (-d $di); print file: $di\n; } } Try the above; WARNING: may contain typos! :) Also - check out File::Find on CPAN. Aloha = Beau; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: using ParseExcel::Simple to get worksheet name
im trying to use Spreadsheet::ParseExcel::Simple to return the name of the worksheet. but all i get is something such as: Spreadsheet::ParseExcel::Simple::_Sheet=HASH(0x39b8918) what am i doing wrong? It's returning a reference to a hash it looks like. I've never used that module so I couldn't tell you for sure but try somehting like I have below :: code: use strict; use Spreadsheet::ParseExcel::Simple; my $wkbook = x:/traffic/temp_assay/site.xls; my (@sheets,$dest,$sheet,$year,$date,@wktemp,$ath,$bth,$cth); my $xls = Spreadsheet::ParseExcel::Simple-read($wkbook); foreach my $sheet ($xls-sheets) { @sheets = $xls-sheets; Why do you set the list of sheets when you're inside a loop working on one sheet ? I see why you were trying it but then you just use the first element in it every time. I'd move it before the foreach statemen so it only has to run sheets() once instead of once for every sheet while ($sheet-has_data) { my @data = $sheet-next_row; my $sheet = $sheets[0]; print $sheet\n; print ${$sheet}{$sheets[0]}; this may or may not do it since I'm not familiar w/ the module but it's the right idea. You need to see the module's docs about how it sets up references and perhaps brush up on understanding perl refernces. They will help you out very much. DMuey } thanks Antonio Quinonez Traffic Analyst Accessline Communications -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Can't fork using open
That was what I found out and why I chose to use Win32::Process so that interactive sessions/commands could be spawned without leaving the Perl module in the lurch. Try it, you'll like it. yes i have used that module in the past as well. I was just trying to see if it could be done effectivley by hand, but as we saw it is not reliable. Has anyone had luck with 5.8? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
net-whois
Can some on tell me where I can find doc on net-whois mod or example script that I can look at. Thomas
Script does not want to run, error
Hi, I am having problems opening this script on my machine. i have been getting help from a very helpful person on this list. I have checked the shebang line, that perl exists, and perl -v gives proper output. i try to run the script below as follow: [EMAIL PROTECTED] httpd]# cd cgi-bin [EMAIL PROTECTED] cgi-bin]# ls -la total 28 drwxr-xr-x2 me root 4096 Mar 5 21:49 . drwxr-xr-x5 me root 4096 Mar 3 01:50 .. -rwxr-xr-x1 me root 268 Mar 4 13:50 printenv -rwxr-xr-x1 me me 1792 Mar 5 15:20 renamer -rwxr-xr-x1 me me 1788 Mar 4 16:40 renamer.cgi -rw---1 root root 1731 Mar 5 21:49 renamer.pl -rwxr-xr-x1 me root 757 Mar 3 01:50 test-cgi [EMAIL PROTECTED] cgi-bin]# renamer.pl [1] 10254 [EMAIL PROTECTED] cgi-bin]# bash: renamer.pl: command not found [1]+ Exit 127renamer.pl [EMAIL PROTECTED] cgi-bin]# [EMAIL PROTECTED] cgi-bin]# ./renamer.pl [1] 10297 [EMAIL PROTECTED] cgi-bin]# bash: ./renamer.pl: Permission denied [1]+ Exit 126./renamer.pl [EMAIL PROTECTED] cgi-bin]# Regards, Mel _ Worried what your kids see online? Protect them better with MSN 8 http://join.msn.com/?page=features/parentalpgmarket=en-gbXAPID=186DI=1059 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
rename() doesn't work
Why doesn't my rename() work? It is returning a '1', meaning success (I get the has been modified message below. Yet when I list the files (ls), it shows the original file name and my tmp file name. The rename doesn't seem to work. Any ideas?! close(IN) or warn cannot close file $inFile: $!\n; close(TMP) or warn cannot close file $tmpFile: $!\n; $rc = rename($tmpFile, $inFile) or die Could not rename files: $!\n; print RC = $rc\n; if (! $rc) { warn Rename failed: $!\n; } else { print File $inFile has been modfied\n; } -Jeff __ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Managing the backslash in a string
Guy P wrote: Look at the small program below. The result is this: DirectionsNitprogrsourcsql DirectionsNitprogrsourcsql And I would like it to be this:\Directions\unit\progr\sourcsql ... $reprt= \Directions\unit\progr\sourcsql; ...Hi Guy, You are comparing apples and oranges here. The string in $reprt above is not equivalent to what the variable would hold if you got it from the database. My Perl program execute a query that bring back into a variable a Windows paths initially stored in a database. I have got problems to manage the backslash. To express what the variable would hold if read from the database, you would have to escape each backslash with another backslash. All control characters within interpolated strings require backslashes to escape them. This makes the packslash itself a control character. Each backslash must then be escaped. Solutions: Escape each backslash: $reprt = Directions\\unit\\progr\\sourcsql; OR use a non-interpolated [single-quoted] string: $reprt = 'Directions\unit\progr\sourcsql'; OR skip trying to hard-code the string in a variable, and instead test by reading the string from the command line. If you do this, there will be no need to escape control characters, as that will already be done under the surface. Joseph OT: You might note that I also removed the initial backslashes. If you are working in Windows, there is no context in which they will be needed. If you have a tree structure: C:\ biology\ botany\ zoology\ protozoan.txt echinoderm.txt Your current directory is biology. to access echinoderm.txt in the zoology folder you would address it as zoology\echinoderm.txt, with no initial control characters of any kind. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tk grab flaws (Is this normal)
I find it pretty strange that after I hit a button from the main window the grab is released and passed on to the next sub routine.. stepping a value to or rather changing a value.. after I em done with that sub .. I again call grab on the top level window and there it it goes with the grab .. It works fine... but when I try to call another routine through a button.. the sub routine comes up and I call external command in windows...which launches explorer.exe after which I again call grab to main window but this time it just does not grab... is this a flaw in Tk or em I not doing it right.. any bit of code will be appreciated.. thanks Sam _ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: rename() doesn't work
Why doesn't my rename() work? It is returning a '1', meaning success (I get the has been modified message below. Yet when I list the files (ls), it shows the original file name and my tmp file name. The rename doesn't seem to work. Any ideas?! Any of this apply?? perldoc -f rename =item rename OLDNAME,NEWNAME Changes the name of a file. Returns C1 for success, C0 otherwise. Behavior of this function varies wildly depending on your system implementation. For example, it will usually not work across file system boundaries, even though the system Imv command sometimes compensates for this. Other restrictions include whether it works on directories, open files, or pre-existing files. Check Lperlport and either the rename(2) manpage or equivalent system documentation for details. You may just try using backticks to execute mv DMuey close(IN) or warn cannot close file $inFile: $!\n; close(TMP) or warn cannot close file $tmpFile: $!\n; $rc = rename($tmpFile, $inFile) or die Could not rename files: $!\n; print RC = $rc\n; if (! $rc) { warn Rename failed: $!\n; } else { print File $inFile has been modfied\n; } -Jeff __ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: using ParseExcel::Simple to get worksheet name
thanks, dan. while sometimes you can get away with not understanding something, in my case,hashes--sometimes you just have to face them head-on. Amen to that thanks for your time in addressing my problem. No problem I hope it helped, I may need help with that module someday Too so , we're all in this together! Isn't perl and this list great!! DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: cpan problems
I've also had trouble using CPAN and so I did the reload index mentioned in this thread and that seemed to go thought but I s til can't get it to go. It's the same error everytime ( diff module names of course ) :: could not open y... There is a direct perl -MCAPN =e shell; CPAN install Bundel::CPAN ... cannot open y/sources/authors/id/A/AN/ANDK/CPAN-1.70.tar.gz: no such file Could not open y/build/ANDK000/Makefile.PL at Since it says no such file would that mean that it's not able to download the files and creat those files Or that it got them but permissions wouldn't allow them to be created and thus they do not exist now? OR ??? And how would I be able to check that? /usr/libdata/perl/5.00503/CPAN.pm line 3642 I'm root when I do this. Do I need to be in a special directory when I do it? ( I also tried it in root's home directory, same thing ) Permissions :: ([EMAIL PROTECTED](~/perl_cpan_mod ):120)# ls -al y/ total 8 drwxr-xr-x 4 root wheel 512 Mar 5 11:11 . drwxr-xr-x 3 root wheel 512 Mar 5 11:10 .. drwxr-xr-x 2 root wheel 512 Mar 5 11:11 build drwxr-xr-x 4 root wheel 512 Mar 5 11:10 sources ([EMAIL PROTECTED](~/perl_cpan_mod ):121)# Or whatelse could I be fumbling up ?? Thanks Dan -- DETAILS -- ([EMAIL PROTECTED](/home/dmuey):101)# perl -MCPAN -e shell; cpan shell -- CPAN exploration and modules installation (v1.48) ReadLine support available (try ``install Bundle::CPAN'') cpan relaod index Unknown command 'relaod'. Type ? for help. cpan reload index CPAN: LWP::UserAgent loaded ok Fetching with LWP: ftp://mirrors.phenominet.com/pub/CPAN/authors/01mailrc.txt.gz Going to read y/sources/authors/01mailrc.txt.gz CPAN: Compress::Zlib loaded ok Fetching with LWP: ftp://mirrors.phenominet.com/pub/CPAN/modules/02packages.detai ls.txt.gz Going to read y/sources/modules/02packages.details.txt.gz Scanning cache y/build for sizes There's a new CPAN.pm version (v1.70) available! You might want to try install Bundle::CPAN reload cpan without quitting the current session. It should be a seamless upgrade while we are running... Fetching with LWP: ftp://mirrors.phenominet.com/pub/CPAN/modules/03modlist.data.gz Going to read y/sources/modules/03modlist.data.gz cpan install Bundle::CPAN Fetching with LWP: ftp://mirrors.phenominet.com/pub/CPAN/authors/id/A/AN/ANDK/CPAN-1.70.tar.gz CPAN: MD5 security checks disabled because MD5 not installed. Please consider installing the MD5 module. cannot open y/sources/authors/id/A/AN/ANDK/CPAN-1.70.tar.gz: no such file Could not open y/build/ANDK000/Makefile.PL at /usr/libdata/perl/5.00503/CPAN.pm line 3642 cpan exit Lockfile removed. ([EMAIL PROTECTED](/home/dmuey):102)# --- end details --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to look into every subdirectory
I had so much fun doing that that I did one that did a little more : Try this it's a little creamier since it uses UL tags instead of #149; And it lists files in the directories that are in the directory in $dir :: I better stop now or I'll be messing with this all night! !#/usr/bin/perl use warnings; use strict; use CGI qw/:standard/; use File::Slurp; my $dir = '.'; # hardcoded, from input $dir = param('dir'), from function like cwd(), etc... print header(); my @files = read_dir($dir); print P UL \n; foreach my $f(@files) { if(-d $dir/$f) { print LI a href=\$f\ $f /a \n; print UL\n; my @tmp = read_dir($dir/$f); foreach my $s(@tmp) { print LI a href=\$f/$s\ $f/$s /a\n; } print /UL\n; } else { print LI a href=\$f\ $f /a\n; } } print /UL P\n; Thanks for your help! You saved me a lot of mis-programming. Yea, I'm really interested in the new challenges -- I just wish I already knew perl. It can do so much. --Deb -Original Message- From: Dan Muey [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 05, 2003 3:02 PM To: Scott, Deborah; [EMAIL PROTECTED] Subject: RE: How to look into every subdirectory I need to make an HTML page that lists all files and directories and then links to them. The following script, with a subroutine, looks like what I need. I should just need to add some html tags to the Print statements. Does that sound right to you all? Or do you have better suggestions? (I'm a real beginner at Perl, but my job has suddenly starting requiring lots of perl scripts!) Sounds like a cool job! Here's what I'd do to get a list of links to all the files and directories and make an html page out of it :: #!/usr/bin/perl use strict; use warnings; use CGI qw/:standard/; use File::Slurp; my $dir = '.'; # hardcoded, from input, from function like cwd(), etc... print header(); my @files = read_dir($dir); foreach my $f(@files) { print \\#149\; a href=\$f\ $f /a br \n; } Then from there you can get fancy like checking for the file type and displaying different icons for each one, Having alist of files/types to not display links to, taking directories and making a list of files with links in each of them also, and on and on. You could also add a header and footer tyo make it look ike the rest of your site Perl is awesome!! Learn how to use modules, it's tricky at first but you'll save yourself lots of time. DMuey --Deborah (I asked this question a while back, but my email messages got messed up and I can't find the answer that I got.) -Original Message- From: Beau E. Cox [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 12:29 PM To: Prasad Karpur; [EMAIL PROTECTED] Subject: RE: How to look into every subdirectory Hi - -Original Message- From: Prasad Karpur [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 3:18 AM To: [EMAIL PROTECTED] Subject: How to look into every subdirectory I am new to Perl and would like to know how to look into every subdirectory. Any help would be greatly appreciated. #!/usr/bin/perl #use strict; use Cwd; my $curr = cwd(); opendir(CURRDIR, $curr) or die can't open directory ($!), exiting.\n; my @files = readdir(CURRDIR); #closedir(CURRDIR); foreach my $file (sort @files) { next if $file eq '.' || $file eq '..'; next if !-d $file; if (-d $file) { print $file/\n; #Puts a slash in front of every directory it encounters } else { print $file\n; } } closedir(CURDIR); Just use a recursive subroutine to traverse your directory tree from any starting point: traverse (cwd()); sub traverse { my $dir = shift; $dir .= '/' unless $dir =~ m{/$}; opendir (DIR, $dir) || die unable to open directory $dir: $!\n; my @contents = readdir (DIR); closedir (DIR); for my $item (sort @contents) { my $di = $dir$item; next unless (-d $di); next if ($item eq '.' or $item eq '..'); print dir: $di\n; traverse ($di); } for my $item (sort @contents) { my $di = $dir$item; next if (-d $di); print file: $di\n; } } Try the above; WARNING: may contain typos! :) Also - check out File::Find on CPAN. Aloha = Beau; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail:
RE: Can't fork using open
That was what I found out and why I chose to use Win32::Process so that interactive sessions/commands could be spawned without leaving the Perl module in the lurch. Try it, you'll like it. -Original Message- From: Kipp, James [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 05, 2003 4:09 PM To: '[EMAIL PROTECTED]' Subject: RE: Can't fork using open I just test ran the below and it worked fine. I am running Win2k Pro, AS Perl 5.6.1 build 630: code adapted from the perlipd doc -- $parent = $$; print parent: $parent\n; $pid = open(STATUS, netstat -an 21 |) || die can't fork: $!; while (STATUS) { #next if /^(tcp|udp)/i; } print child: $pid\n; close STATUS || die bad netstat: $! $?; --- hmm.. The results weren't so good from the write side. It seems the fork and spawn of the child works fine, however (as Jeff Smith mentioned in his post) the forked process doesn't seem to return or at least in any set time. The code below spawns the child but never returns: open(TEST, | notepad.exe) || die can't fork: $!; print TEST stuff\n; close TEST || die bad cmd: $! $?; notepad opens but it never returns to do the write. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Script does not want to run, error
Try # ./renamer.pl How do you know it's not running? It could be running but not printing anything to the screen? Is it supposed to have output? What is it supposed to do? Throw us bone here!! DMuey Hi, I am having problems opening this script on my machine. i have been getting help from a very helpful person on this list. I have checked the shebang line, that perl exists, and perl -v gives proper output. i try to run the script below as follow: [EMAIL PROTECTED] httpd]# cd cgi-bin [EMAIL PROTECTED] cgi-bin]# ls -la total 28 drwxr-xr-x2 me root 4096 Mar 5 21:49 . drwxr-xr-x5 me root 4096 Mar 3 01:50 .. -rwxr-xr-x1 me root 268 Mar 4 13:50 printenv -rwxr-xr-x1 me me 1792 Mar 5 15:20 renamer -rwxr-xr-x1 me me 1788 Mar 4 16:40 renamer.cgi -rw---1 root root 1731 Mar 5 21:49 renamer.pl -rwxr-xr-x1 me root 757 Mar 3 01:50 test-cgi [EMAIL PROTECTED] cgi-bin]# renamer.pl [1] 10254 [EMAIL PROTECTED] cgi-bin]# bash: renamer.pl: command not found [1]+ Exit 127renamer.pl [EMAIL PROTECTED] cgi-bin]# [EMAIL PROTECTED] cgi-bin]# ./renamer.pl [1] 10297 [EMAIL PROTECTED] cgi-bin]# bash: ./renamer.pl: Permission denied [1]+ Exit 126./renamer.pl [EMAIL PROTECTED] cgi-bin]# Regards, Mel _ Worried what your kids see online? Protect them better with MSN 8 http://join.msn.com/?page=features/parentalpgmarket=en-gbXAP ID=186DI=1059 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Script does not want to run, error
Make sure your script starts with #!/path/to/perl then change permission of the script, chmod 755 file_to_set try to run your script, if it doesnt work try #perl file_to_run Mark - Original Message - From: mel awaisi [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, March 05, 2003 5:11 PM Subject: Script does not want to run, error Hi, I am having problems opening this script on my machine. i have been getting help from a very helpful person on this list. I have checked the shebang line, that perl exists, and perl -v gives proper output. i try to run the script below as follow: [EMAIL PROTECTED] httpd]# cd cgi-bin [EMAIL PROTECTED] cgi-bin]# ls -la total 28 drwxr-xr-x2 me root 4096 Mar 5 21:49 . drwxr-xr-x5 me root 4096 Mar 3 01:50 .. -rwxr-xr-x1 me root 268 Mar 4 13:50 printenv -rwxr-xr-x1 me me 1792 Mar 5 15:20 renamer -rwxr-xr-x1 me me 1788 Mar 4 16:40 renamer.cgi -rw---1 root root 1731 Mar 5 21:49 renamer.pl -rwxr-xr-x1 me root 757 Mar 3 01:50 test-cgi [EMAIL PROTECTED] cgi-bin]# renamer.pl [1] 10254 [EMAIL PROTECTED] cgi-bin]# bash: renamer.pl: command not found [1]+ Exit 127renamer.pl [EMAIL PROTECTED] cgi-bin]# [EMAIL PROTECTED] cgi-bin]# ./renamer.pl [1] 10297 [EMAIL PROTECTED] cgi-bin]# bash: ./renamer.pl: Permission denied [1]+ Exit 126./renamer.pl [EMAIL PROTECTED] cgi-bin]# Regards, Mel _ Worried what your kids see online? Protect them better with MSN 8 http://join.msn.com/?page=features/parentalpgmarket=en-gbXAPID=186DI=1059 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: rename() doesn't work
Jeff Westman wrote: Why doesn't my rename() work? It is returning a '1', meaning success (I get the has been modified message below. Yet when I list the files (ls), it shows the original file name and my tmp file name. The rename doesn't seem to work. Any ideas?! close(IN) or warn cannot close file $inFile: $!\n; close(TMP) or warn cannot close file $tmpFile: $!\n; $rc = rename($tmpFile, $inFile) or die Could not rename files: $!\n; print RC = $rc\n; if (! $rc) { warn Rename failed: $!\n; } else { print File $inFile has been modfied\n; } -Jeff Hi Jeff, The code you have looks fine, presuming both fiiles are in the current directory. It might help to see more of the context. Have you tried pritning both filenames, as well as checking the tmp file before and after running the script to ensure that it has been modified? Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: rename() doesn't work
Yes, I tried all that. (thanks) This is very odd... turns out that when I tried to do a regular 'mv' command under Unix, it too said success ($?=0) I found that the mount I have my file system is non-standard Unix, so while the OS thought everything was okay, it really wasn't. I'm using some HP proprietary network mount. Go figure %-/ -Jeff --- R. Joseph Newton [EMAIL PROTECTED] wrote: Jeff Westman wrote: Why doesn't my rename() work? It is returning a '1', meaning success (I get the has been modified message below. Yet when I list the files (ls), it shows the original file name and my tmp file name. The rename doesn't seem to work. Any ideas?! close(IN) or warn cannot close file $inFile: $!\n; close(TMP) or warn cannot close file $tmpFile: $!\n; $rc = rename($tmpFile, $inFile) or die Could not rename files: $!\n; print RC = $rc\n; if (! $rc) { warn Rename failed: $!\n; } else { print File $inFile has been modfied\n; } -Jeff Hi Jeff, The code you have looks fine, presuming both fiiles are in the current directory. It might help to see more of the context. Have you tried pritning both filenames, as well as checking the tmp file before and after running the script to ensure that it has been modified? Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[OT] YAPC::NA 2003 Registration
Hello folks, I just wanted to alert people to the fact that registration has begun for YAPC::NA::2003. The Yet Another Perl Conferences (YAPCs) are grassroots symposia on the Perl programming language under the auspices of the Yet Another Society (YAS), a non-profit corporation for the advancement of collaborative efforts in computer and information sciences. The cost is $85 for 3 days of talks, tutorials and discussions. I have some fabulous talk proposals, so this stands to be a great place to learn some new things. It will be June 16-18, 2003 in Boca Raton, FL. Please visit the website to learn more, and _to register_. If anyone has any questions, feel free to email me off-list. Cheers, Kevin -- [Writing CGI Applications with Perl - http://perlcgi-book.com] The California crunch really is the result of not enough power-generating plants and then not enough power to power the power of generating plants. -- G.W. Bush, Interview with New York Times 01/14/2001 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: rename() doesn't work
Jeff Westman wrote: Yes, I tried all that. (thanks) This is very odd... turns out that when I tried to do a regular 'mv' command under Unix, it too said success ($?=0) I found that the mount I have my file system is non-standard Unix, so while the OS thought everything was okay, it really wasn't. I'm using some HP proprietary network mount. Go figure %-/ -Jeff I've noticed that when I have trouble using the rename command in Perl, I also tend to run into difficulties trying to rename from the shell [Explorer in my case] I guess the rename function works only as well as the standard interface of the file system. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] YAPC::NA 2003 Registration
Kevin Meltzer wrote: Hello folks, ... It will be June 16-18, 2003 in Boca Raton, FL. Please visit the website to learn more, and _to register_. If anyone has any questions, feel free to email me off-list. Cheers, Kevin Eh, which website? I didn't see a link. FWIW, yas.org [my best first guess] is available for sale or lease. Joseph [Writing CGI Applications with Perl - http://perlcgi-book.com] The California crunch really is the result of not enough power-generating plants and then not enough power to power the power of generating plants. -- G.W. Bush, Interview with New York Times 01/14/2001 Well. That certainly cleared things up ;- ) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] YAPC::NA 2003 Registration
On Wednesday, March 5, 2003, at 08:49 PM, R. Joseph Newton wrote: Kevin Meltzer wrote: It will be June 16-18, 2003 in Boca Raton, FL. Please visit the website to learn more, and _to register_. If anyone has any questions, feel free to email me off-list Eh, which website? I didn't see a link. FWIW, yas.org [my best first guess] is available for sale or lease. http://yapc.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
regex fun :)
hello, while trying to get a grasp on regex i found this nice little tutorial. http://www.steve.gb.com/perl/lesson06.html so i tried this.. $choice = 11 if($choice =~ /[1-6]{1}/) this returns true. I want it to only match a single digit ranging 1-6 , I thought the {1} would specifiy to match one time only?? could someone tell me what im doing wrong :) ? Thanks, -- jd [EMAIL PROTECTED] Bad spellers of the world untie! I can't tell if I have worked all my life or if I have never worked a single day of my life Miguel de Icaza -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: regex fun :)
jdavis wrote: hello, while trying to get a grasp on regex i found this nice little tutorial. http://www.steve.gb.com/perl/lesson06.html so i tried this.. $choice = 11 if($choice =~ /[1-6]{1}/) this returns true. I want it to only match a single digit ranging 1-6 , I thought the {1} would specifiy to match one time only?? could someone tell me what im doing wrong :) ? The {1} does tell it to match one time only, match any character 1-6 one time only, but not match only 1 character from 1-6 :-)..., so it matches the first '1' in the string and that is success. How about, if ($choice =~ /^[1-6]$/) { } http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: regex fun :)
jdavis wrote: hello, while trying to get a grasp on regex i found this nice little tutorial. http://www.steve.gb.com/perl/lesson06.html p.s. you may want to have a look at: perldoc perlretut perldoc perlre http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: regular exp problem
Rob Dixon wrote: Ramprasad wrote: I have a str that contains the base64 encoded string of a mail. Now this string should not contain any characters with ascii values above 128. Can i write a regex to check this Assuming you mean 'above 127' you can use the POSIX ASCII character class: die Invalid character in data if $string =~ /[^[:ascii:]]/; HTH, Rob thanks , I wanted above 127 alright. Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: regex fun :)
Jdavis wrote: hello, Hello, while trying to get a grasp on regex i found this nice little tutorial. http://www.steve.gb.com/perl/lesson06.html so i tried this.. $choice = 11 if($choice =~ /[1-6]{1}/) [1-6]{1} is a more verbose way of saying [1-6]. {1} is implied with every character literal or character class. You COULD write /string [1-6]/ as /s{1}t{1}r{1}i{1}n{1}g{1} {1}[1-6]{1}/ but why would you want to? this returns true. I want it to only match a single digit ranging 1-6, You need to learn about anchors. The beginning of line anchor - ^, the end of line anchor - $, the beginning of string anchor - \A, and the end of string anchors - \z and \Z I thought the {1} would specifiy to match one time only?? could someone tell me what im doing wrong :) ? It does match one time only but because the regex is not anchored it will match one character anywhere in the string. If you anchor the regex to the beginning of the line AND to the end of the line then there is no way that the string can contain more characters then your regex specifies. my $choice = 11 if ( $choice =~ /^[1-6]$/ ) John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: cpan problems
Dan Muey wrote at Wed, 05 Mar 2003 11:26:03 -0600: I've also had trouble using CPAN and so I did the reload index mentioned in this thread and that seemed to go thought but I s til can't get it to go. It's the same error everytime ( diff module names of course ) :: could not open y... There is a direct perl -MCAPN =e shell; CPAN install Bundel::CPAN ^^ Hmm, that should be Bundle, shouldn't it ?! Cheerio, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]