RE: How do I document my perl code?
POD - Plain Old Documentation You'll find this in the perl doc as perlpod basically you use the = in column one with a keyword. Perl parser ignores anything betweeen a beginning = and the final marker =cut. Typically its: =pod =head1 DESCRIPTION blah, blah, blah... =cut code.. Other notes: 1. the = =cut markers can also be used to comment out code rather than each line as in: =comment code.. =cut 2. Use PerlOasis (a free windows based gui) to preview your POD (its all perl code): http://www.bahnhof.se/~johanl/perl/Oasis/ -Original Message- From: Richard Heintze [mailto:[EMAIL PROTECTED] Sent: Monday, June 07, 2004 6:06 PM To: [EMAIL PROTECTED] Subject: RE: How do I document my perl code? Is there any standard for documenting functions? For example, in Javadoc, there is a specific format that uses the @ for identifying and formating the function argruments. It looks like POD much more freeform and is not nearly so detailed. Is that true? Siegfried P.S. Sorry Charles, I accidently replied to you personally. __ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Printing a multipart HTML output
Hi all, Please tell me how can I create a multipart html file that includes html text and images. I know that Mime::Lite can create such a thing for sending an email with attachments, but I don't know if it is possible to use it for creating common HTML pages with multipart content. Thank you. Teddy Teddy -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Printing a multipart HTML output
Hi all, Please tell me how can I create a multipart html file that includes html text and images. I know that Mime::Lite can create such a thing for sending an email with attachments, but I don't know if it is possible to use it for creating common HTML pages with multipart content. I was not aware that this was even possible. It does appear that some browsers, specifically in the Netscape class could handle this at least once upon a time. I found a link through google to chapter 13 of the definitive HTML book from ORA (illegal copyright violation so I will not provide it), that talks about how to do this, specifically in an HTTP push application (like streaming media, etc.) so apparently it can be done. This is going to be very, very browser implementation specific I imagine, because the browser has to know how to deal with multipart data transmissions, etc. but assuming your target app can handle it then it appears to work almost exactly as MIME does in e-mail. Aka you specify a content-type of multipart/*, with a boundary string, then just print your multiple parts separated by the boundary. Having said that you might be able to coerce MIME::Lite into doing this, though it might be overkill, since you may not have to deal with encoding, etc. since it isn't mail going through an intermediary. Either way you should look into some of the server-push applications available and see what they do. Of course, not sure why you would want to do this with text and images anyways, why not just serve up a normal img tag? HTH, http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Printing a multipart HTML output
Hi, Thanks for responding. I need to create that multipart page because I am trying to create a single html file with a financial analysis which includes pictures and I don't want to be necessary to send more files to the clients. But I was sure that if Outlook Express can read such a page, Internet Explorer and other browsers will be able to read it for sure. Thanks. Teddy - Original Message - From: Wiggins d Anconia [EMAIL PROTECTED] To: Octavian Rasnita [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, June 08, 2004 6:18 PM Subject: Re: Printing a multipart HTML output Hi all, Please tell me how can I create a multipart html file that includes html text and images. I know that Mime::Lite can create such a thing for sending an email with attachments, but I don't know if it is possible to use it for creating common HTML pages with multipart content. I was not aware that this was even possible. It does appear that some browsers, specifically in the Netscape class could handle this at least once upon a time. I found a link through google to chapter 13 of the definitive HTML book from ORA (illegal copyright violation so I will not provide it), that talks about how to do this, specifically in an HTTP push application (like streaming media, etc.) so apparently it can be done. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: POST and GET and CGI.pm
Greetings, While reading some of the Perl newsgroups, I've seen a few examples of people getting CGI parameters by either parsing the query-string (for GETs) or reading in some of the content (for POSTs). I've been working with CGI (using Perl) for a little while now and I've always used the param() method in CGI.pm and it is working for both GETs and POSTs. I'm wondering if I'm missing something and if there are times when using the CGI.pm param() method is not advised. Thanks. You're not the one missing out. 'param' specifically isn't always the best way, for instance sometimes I like to pull them all at once with the 'Vars' method. Or in the case of file uploads I generally use the newer upload interface methods. Point being, you should rarely if ever need to parse the query string/post yourself. To me, using the CGI module would never be the wrong way to do it, whereas the other would be. mod_perl not in consideration at this point, aka there is the Apache::Request (I think?) for that, etc. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
help with adjusting log file data?
Hi guys, Needing a little help with adjusting the data a log file reads to. It goes like this currently @env_vars = keys(%ENV); foreach $variable (@env_vars) { $log_entry .=$ENV{$variable}\|; } I am wanting to change this to include $http_referrer So,I am presuming that I should be doing this: foreach $variable (@env_vars) { $log_entry .=$ENV{'http_referrer}\|$ENV{$variable}\|; } Is this correct?? thanks in advance Cat
RE: help with adjusting log file data?
Catriona Pure Scents [EMAIL PROTECTED] wrote: : Hi guys, : : Needing a little help with adjusting the data a log file reads to. : : It goes like this currently : @env_vars = keys(%ENV); : : foreach $variable (@env_vars) : { : $log_entry .=$ENV{$variable}\|; : } There is no need to escape '|' in a double quoted string. This is equivalent to the loop, though I don't know why the extra '|' at the end would be wanted. my $log_entry = ( join '|', values %ENV ) . '|'; : I am wanting to change this to include $http_referrer If http_referer has anything in it it will be included already. : So,I am presuming that I should be doing this: : : foreach $variable (@env_vars) : { : $log_entry .=$ENV{'http_referrer}\|$ENV{$variable}\|; } There is a typo in there. $log_entry .=$ENV{http_referrer}|$ENV{$variable}|; } : Is this correct?? My first thought was: What happened when you tried it? Then I wondered what you meant by correct. In my mind, even after fixing the typo this is incorrect. You are defining every other pipe separated field with the referrer. At some point, assuming the referrer is defined, there may be three such fields in a row. I don't think that is really what you want. This looks more like it: my $log_entry = join '|', values %ENV ); The next thing I wondered was whether you were aware that newlines are embedded in at least one Apache field ('SERVER_SIGNATURE'), thus $log_entry won't be one line in the log and won't be able to be retrieved as one line. Here's a script that generates $log_entry with newlines (\n) instead of pipes ('|'). #!/usr/bin/perl use strict; use warnings; use CGI; my $q = CGI-new(); # bold the referrer if present $ENV{http_referer} = $q-b( $ENV{http_referer} ) if exists $ENV{http_referer}; my $log_entry = join \n, values %ENV; print $q-header(), $q-start_html(), $q-pre( qq|Referrer (if any): $ENV{http_referer}\n|, $log_entry, ), $q-br(), $q-a( { href = $q-url() }, 'again' ); $q-end_html(); __END__ Type the url into the browser address bar the first time. The second time, click the again link. When I tried it on my local system (Apache on Windows) I got a referrer only after clicking the link. Notice that the referrer is included in the list when it is defined. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
use lib(''); Apache httpd.conf
Hi, I have a rather simple question that Google hasn't produced answers for. Basically, I am installing Mason in a virtual host under mod_perl. The libraries I need are housed in ~/my/lib How might I make Apache aware of ~/my/lib from the httpd.conf so that the following: PerlModule HTML::Mason::ApacheHandler will load? What is the equivalent for the httpd.conf of use lib('/my/lib'); ? Thanks is advance. - Sincerely, Alex Newby E-mail: [EMAIL PROTECTED] Website: http://www.alexnewby.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
system() command
Hi, I hope this is the right mailing list. I have two questions. 1. I was wondering if anyone here knows what this command is doing, besides calling the program neighbor? system (neighbor /dev/null 21 ! $inpwd 2 3 Y !) I understand up to 21, does anyone knows what comes after that. I am guessing they are all arguments, but what do and ! in particular mean? 2. Ok, the situation is a bit hard to describe, but here goes. I have a program that is interactive (character user interface), and I want to call this program from perl. So far I know that system() can call the program, but how do we interactively communicate with the program afterwards? By that I mean, which commands are available? Or are there other methods for doing so? I have heard of batch files, but I'm not sure how to apply that here. Thank you very much beforehand. Any help appreciated. Regards June __ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
system() command
Hi, I hope this is the right mailing list. I have two questions. 1. I was wondering if anyone here knows what this command is doing, besides calling the program neighbor? system (neighbor /dev/null 21 ! $inpwd 2 3 Y !) I understand up to 21, does anyone knows what comes after that. I am guessing they are all arguments, but what do and ! in particular mean? 2. Ok, the situation is a bit hard to describe, but here goes. I have a program that is interactive (character user interface), and I want to call this program from perl. So far I know that system() can call the program, but how do we interactively communicate with the program afterwards? By that I mean, which commands are available? Or are there other methods for doing so? I have heard of batch files, but I'm not sure how to apply that here. Thank you very much beforehand. Any help appreciated. Regards June __ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
system() command
Hi, I hope this is the right mailing list. I have two questions. 1. I was wondering if anyone here knows what this command is doing, besides calling the program neighbor? system (neighbor /dev/null 21 ! $inpwd 2 3 Y !) I understand up to 21, does anyone knows what comes after that. I am guessing they are all arguments, but what do and ! in particular mean? 2. Ok, the situation is a bit hard to describe, but here goes. I have a program that is interactive (character user interface), and I want to call this program from perl. So far I know that system() can call the program, but how do we interactively communicate with the program afterwards? By that I mean, which commands are available? Or are there other methods for doing so? I have heard of batch files, but I'm not sure how to apply that here. Thank you very much beforehand. Any help appreciated. Regards June __ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: system() command
Before going any further, you might want to tell us what operating system you are using. As far as I know, the operator can be used to feed a program certain input as if it came from STDIN, but I've never used it because it always sounded a bit kludgy to me. -Original Message- From: june tantoolvesm [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 08, 2004 1:25 AM To: [EMAIL PROTECTED] Subject: system() command Hi, I hope this is the right mailing list. I have two questions. 1. I was wondering if anyone here knows what this command is doing, besides calling the program neighbor? system (neighbor /dev/null 21 ! $inpwd 2 3 Y snip -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Yet Another Regex Problem
Hi guyz, this regex are goin' to drive me crazy! My problem is: I have to find URLs in a text file (so, cannot use LWP or HTML parser) I've tried with something like /(http.:\/\/.*\s)/ willing to find anything starting with http/https with //: and catching everything up to a space or newline. It works in some cases but it catch the widest possible matching, so if I have something like try to click here http://www.yahoo.com or there http://www.google.com; the result for $1 is: http://www.yahoo.com or there http://www.google.com; How can I get simply http://www.yahoo.com; and then http://www.google.com;? thanx very much...you'r saving a man Francesco __ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: GD::Graph
On Mon, 2004-06-07 at 21:35, Josimar Nunes de Oliveira wrote: screen-copy Microsoft Windows 2000 [Versão 5.00.2195] (C) Copyright 1985-2000 Microsoft Corp. C:\Documents and Settings\Administradorppm install GD-Graph Error: Package 'GD-Graph' not found. Please 'search' for it first. C:\Documents and Settings\Administrador /screen-copy http://theoryx5.uwinnipeg.ca/ppms/ Has a copy of compiled modules as ppd(s). I am not sure whether I installed from this URL. I lost the URL from which I installed when I installed my stuff on Windows. I don't have a windows box to test on right now. Use the full URL of the ppd instead of GD-Graph. -Tarun -- You know, it's at times like this when I'm trapped in a Vogon airlock with a man from Betelgeuse and about to die of asphyxiation in deep space that I really wish I'd listened to what my mother told me when I was young! Why, what did she tell you? I don't know, I didn't listen. -- Douglas Adams, The Hitchhiker's Guide to the Galaxy -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: use lib(''); Apache httpd.conf
-Original Message- From: Alex Newby [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 08, 2004 9:54 AM To: [EMAIL PROTECTED] Subject: use lib(''); Apache httpd.conf Hi, I have a rather simple question that Google hasn't produced answers for. Basically, I am installing Mason in a virtual host under mod_perl. The libraries I need are housed in ~/my/lib How might I make Apache aware of ~/my/lib from the httpd.conf so that the following: PerlModule HTML::Mason::ApacheHandler will load? What is the equivalent for the httpd.conf of use lib('/my/lib'); ? Have you RTFM ? http://www.masonhq.com/docs/manual/Admin.html HTH, José. DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: how to check for dots in filename
Sid, try: my $ty=polica.op; if($ty =~ /\.+/) { print Found a dot!\n; } Steve On Tue, Jun 08, 2004 at 03:34:29AM +0530, Sidharth wrote: hi all, can anyone tel me how to look for files which conatain dotsin it. i.e file1.txt file2.txt how to check for dots in filename using regular expression. is it correct my $ty=polica.op if($ty =m/ (.*)\.o/) print found; plz reply soon sid - There is nothing in a caterpillar that tells you it's going to be a butterfly. - Anonymous * Sidharth M Patil Engineer Kyocera-Wireless (India) Pvt Ltd 5th Floor, Phase I, Divyashree Towers, Guruppanapalya, Bannerghatta Road, Bangalore-560072 Tel : 51106988 extn 5171 * -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: system() command
June Tantoolvesm wrote: Hi, Hello, I hope this is the right mailing list. I have two questions. 1. I was wondering if anyone here knows what this command is doing, besides calling the program neighbor? system (neighbor /dev/null 21 ! $inpwd 2 3 Y !) I understand up to 21, does anyone knows what comes after that. I am guessing they are all arguments, but what do and ! in particular mean? That is a here document and is used for input. 2. Ok, the situation is a bit hard to describe, but here goes. I have a program that is interactive (character user interface), and I want to call this program from perl. So far I know that system() can call the program, but how do we interactively communicate with the program afterwards? By that I mean, which commands are available? Or are there other methods for doing so? I have heard of batch files, but I'm not sure how to apply that here. http://search.cpan.org/~rgiersig/Expect-1.15/ http://search.cpan.org/~djerius/Expect-Simple-0.02/ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
accesing a table inside word from Perl
Does anyone know where I can get some information on how to access, create, modify a table and add rows to a table in Microsoft Word from Perl? Henri - Original Message - From: Ravinder Arepally [EMAIL PROTECTED] To: 'Wiggins d'Anconia' [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, June 07, 2004 8:46 PM Subject: RE: XML::DOM::Parser question ! I need to change value in file itself. It is not doing that. I am thinking setAttribute should change value of element in file. But my below code is not doing that even though I am using same. My intention is to change value of javaTask className = tool.update.languagepack.MergeConfig arg name=sample value=false/ to javaTask className = tool.update.languagepack.MergeConfig arg name=sample value=true/ Thanks, Ravi -Original Message- From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED] Sent: Monday, June 07, 2004 8:09 PM To: Ravinder Arepally Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: XML::DOM::Parser question ! Ravinder Arepally wrote: All, I am trying to parse a XML file and change an element value. Below is code of mine where I am doing this. However, setAttribute doesn't work and it doesn't give any error message too. I spent enough time and doesn't make sense to me. I get right value using getAttribute('value). XML file is also pasted at the end of this mail. Any help or pointer is greatly appreciated. Any suggestions in writing better code for this task is also appreciated. Thank you, Ravi. --- my $udtTaskFile = $depotLocation/updates/$udtBaseName/tasks/$udtBaseName._cs_udt.xml ; print (udtTaskfile is : $udtTaskFile \n); --- XML file which is pasted at end of this mail. Util::safeCopy($udtTaskFile, $udtTaskFile.time()); -- I have Util.pm my $parser = new XML::DOM::Parser; my $doc = $parser-parsefile($udtTaskFile); my @taskList = $doc-getElementsByTagName('taskEntry'); foreach my $task (@taskList) { if ($task-getAttribute('uniqueName') eq MergeConfig){ my $javaTask = $task-getElementsByTagName('javaTask'); if (! $javaTask) { $log-write(ERROR: Couldn't find any Java tasks in $udtTaskFile ); return Problem configuring installLPI. Couldn't find any Java Tasks in $udtTaskFile. ; } my $innerTask = $javaTask-item(0)-getElementsByTagName('arg'); if (! $innerTask) { $log-write(ERROR: Couldn't find any languagepack tasks in $udtTaskFile ); return Problem configuring installLPI. Couldn't find any languagepack Tasks in $udtTaskFile. ; } my $value = $innerTask-item(0)-getAttribute('value'); print (value is $value \n); This prints right value $innerTask-item(0)-setAttribute('value', true); - This is not working. No error and it doesn't change value } } Please don't cross post, try one list then the other if the first doesn't provide acceptable resolution. snip sample file Does it not change the value of the internally represented structure, or in the file itself? Have you tried dumping the structure (not sure if it works with XML::DOM) using Data::Dumper? I am assuming it isn't throwing an exception about missing methods, I tried to track down where setAttribute is inherited from but the XML::DOM tree is a pretty big tangle. Can you be more specific about precisely what isn't working? http://danconia.org ___ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
How to readline when using more option in script.
Hi, I could use open(STDOUT,| more) option to more big file. After this, I close STDOUT as if I do not close, readline prints the prompt even when more is not 100%. ### open(STDOUT,| more) || Cannot open stdout for more $!; $status = system(cat report.txt); $status = system(clear); close STDOUT; ## If I do not close handler then I get the prompt(see below) on ## the very first page of the screen. I need to ask this once # more is done with 100% display of file. Actually, before #deletion I want to show the data to user and then ask about his #consent for deletion. $term = new Term::ReadLine '999'; $prompt = All the rows displayed above will be removed\nDo you want to continue?(Y/N) :; $option = $term-readline($prompt); ## Now if i try to print the option. I do not get anything even if user says 'y'. Looks like if i close STDOUT, readline does not read. Any pointers will be appreciated. Thanks, Raminder -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
How to readline when using more option in script.
Hi, I could use open(STDOUT,| more) option to more big file. After this, I close STDOUT as if I do not close, readline prints the prompt even when more is not 100%. ### open(STDOUT,| more) || Cannot open stdout for more $!; $status = system(cat report.txt); $status = system(clear); close STDOUT; ## If I do not close handler then I get the prompt(see below) on ## the very first page of the screen. I need to ask this once # more is done with 100% display of file. Actually, before #deletion I want to show the data to user and then ask about his #consent for deletion. $term = new Term::ReadLine '999'; $prompt = All the rows displayed above will be removed\nDo you want to continue?(Y/N) :; $option = $term-readline($prompt); ## Now if i try to print the option. I do not get anything even if user says 'y'. Looks like if i close STDOUT, readline does not read. Any pointers will be appreciated. Thanks, Raminder -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Calling more in perl script for large files.
Hi, I could use open(STDOUT,| more) option to more big file. After this, I close STDOUT as if, I do not close, readline prints the prompt even when more is not 100%. ### open(STDOUT,| more) || Cannot open stdout for more $!; $status = system(cat report.txt); $status = system(clear); close STDOUT; ## If I do not close handler then I get the prompt(see below) on ## the very first page of the screen. I need to ask this once # more is done with 100% display of file. Actually, before #deletion I want to show the #data to user and then ask about his #consent for deletion. $term = new Term::ReadLine '999'; $prompt = All the rows displayed above will be removed\nDo you want to continue?(Y/N) :; $option = $term-readline($prompt); ## Now if i try to print the option. I do not get anything even if user says 'y'. Looks like if i close STDOUT, readline does not read. Any pointers will be appreciated. Thanks, Raminder Bob Showalter [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Hi There, Any pointers to how to call more on a file in perl script. I am writing one script which displays one report to user and then asks some inputs. User need to see complete file. To solve this, I thought I can call `more in the script and continue. But looks loke it is not possible. You didn't post your script, so I can only guess. You can't use backticks, since they capture the output. If more is writing to a non-tty (because you're capturing the output), it obviously has no way to pause at a screenful, so it just passes the entire input to the output. You need to use system() instead. Also, it's customary to respect $ENV{PAGER}. I have my pager set to less, for example. Read perldoc perlopentut and search for PAGER to see an example of how to do this kind of thing. - Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger
about ppm
hi, i have installed perl 5.8 on windows XP.but the ppm is not working,it says ,it doesn't contain any packages or repositories,also it couldn't connect to activestate. can i get ppm separately or i have to install perl again. thanx in advance, aditi Yahoo! India Matrimony: Find your partner online.
Re: about ppm
hi, i have to install bioperl modules. i gave its full address: ppm install http://bioperl.org/DIST/ it said: Error: No valid repositories Error: 500 Can't connect to ppm.ActiveState.com:80(Bad hostname 'ppm.ActiveState.com') Error: 500 Can't connect to ppm.ActiveState.com:80(Bad hostname 'ppm.ActiveState.com') it seems there are no repositories . what should i do?? -aditi Tarun Dua [EMAIL PROTECTED] wrote: Aditi gupta wrote: i have installed perl 5.8 on windows XP.but the ppm is not working,it says ,it doesn't contain any packages or repositories,also it couldn't connect to activestate. can i get ppm separately or i have to install perl again. Aditi, You can use the full URL of the package you want to install with ppm install. -Tarun Yahoo! India Matrimony: Find your partner online.
Re: about ppm
Aditi gupta wrote: hi, i have to install bioperl modules. i gave its full address: ppm install http://bioperl.org/DIST/ it said: Error: No valid repositories Error: 500 Can't connect to ppm.ActiveState.com:80(Bad hostname 'ppm.ActiveState.com') Error: 500 Can't connect to ppm.ActiveState.com:80(Bad hostname 'ppm.ActiveState.com') it seems there are no repositories . what should i do?? Aditi, try something like ppm install http://bioperl.org/DIST/Bioperl-1.2.1.ppd or similar. -Tarun -- Where's the man could ease a heart Like a satin gown? -- Dorothy Parker, The Satin Dress -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: if -s clause
I have tried all three methods if -s OUT, if -f $filename and if -s @arrayname with no evail. I did make a test.pl file so that I am just testing whether the file is greater than 0 bytes. Here is the code. autoflush is turned on. Is this the correct spot for this? Is it this tedious to test if a file is greater than 0 bytes I thought perl is supposed to be this great language for UNIX and C people??? thank you, ## Set pragmas use strict; my $foreigntapes=/usr/local/log/foreign_tapes.log; delete $ENV{'IFS'}; local $ENV{'PATH'} = /usr/epoch/bin:/usr/epoch/EB/bin:/usr/bin:/usr/sbin:/bin:/sbin; open (OUT, $foreigntapes) || die could not open file:$!; my @ftapes = grep s/^barcode=//, `evmvol -w label_state=1`; $| = 1; print OUT @ftapes; if ( -s OUT ) { print file is greater than 0 bytes \n; } Wiggins d'Anconia [EMAIL PROTECTED] 06/07/2004 10:36 PM To: [EMAIL PROTECTED] cc: [EMAIL PROTECTED] Subject:Re: if -s clause Please bottom post. [EMAIL PROTECTED] wrote: I originally had if ( -s OUT ) { print file is greater than 0 bytes \n; } so is this what I want to use? Because I just ran it and it is still not printing this string. Well theoretically that might work since the def in the docs indicates a filehandle is possible. I am wondering if maybe it is because your output does not contain a new line and is buffered. One of the gurus with internals knowledge would be better suited to answer that. You might try turning on autoflush for the handle before printing it, or alternatively as I already suggested close the filehandle, which will force the flush to occur (and conveniently force you to test the file rather than the handle which is my next suggestion). This is probably the copout approach, but to me the easiest least worrisome approach. No guesses needed. Please excuse my indentation as I cut and pasted it. My goal is to send a mail message using MIME:Lite if the file is greater than 0 bytes else just touch a file. The reason for opening the RUNFILE is b/c I wanted to create a file to verify there the if -s clase produced no output. In other words, there is no data being appended to $foreigntapes variable. thank you! Here is my code use strict; use MIME::Lite; ## Set and edit variables my $foreigntapes=/usr/local/log/foreign_tapes.log; delete $ENV{'IFS'}; local $ENV{'PATH'} = /usr/epoch/bin:/usr/epoch/EB/bin:/usr/bin:/usr/sbi n:/bin:/sbin; #print $ENV{'PATH'},\n; ## Traverse through array and play with data open (OUT, $foreigntapes) || die could not open file:$!; my @ftapes = grep s/^barcode=//, `evmvol -w label_state=1`; print OUT @ftapes; close OUT or warn Can't close write handle: $!; if ( -s OUT ) { if (-s $foreigntapes) { print file is greater than 0 bytes \n; `ls -la /usr/local/log/foreign_tapes.log`; Like I said before, what are you trying to accomplish with the above? foreach (@ftapes) { print $_; #`evmlabel -l st_9840_acs_0 -t 9840S -b$_` } close (OUT); } else { my $foo=/tmp/ftapes_runfile; open (RUNFILE, $foo) || die could not open runfile: $!; } close (RUNFILE); snip old posts http://danconia.org
Re: Yet Another Regex Problem
On Jun 8, Francesco del Vecchio said: I have to find URLs in a text file (so, cannot use LWP or HTML parser) I'm curious why you can't use a module to extract URLs, but I'll continue anyway. /(http.:\/\/.*\s)/ That regex is broken in a few ways. First, it does NOT match 'http:', it only matches 'http_:', where there is some character between the p and the colon. Second, the .* in it is greedy (it matches as much as it can). Third, it requires your URL to be followed by a space, which won't always be the case. try to click here http://www.yahoo.com or there http://www.google.com; I would suggest trying: @urls = $string =~ m{(https?://\S+)}g; Using \S+ makes it match one or more non-whitespace characters. The only problem with this is that if there happens to be punctuation after the URL, it'll get included. An example is this: Go to http://www.yahoo.com, and you'll see what I mean. That will match `http://www.yahoo.com,' (including the comma). -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ CPAN ID: PINYAN[Need a programmer? If you like my work, let me know.] stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
OT - problem with script running on a refresh
Hi I have a CGI/dbi script which whenever the page is reloaded the following executes print start_multipart_form (POST); print Subject, popup_menu(-name='Subject1',-values=[EMAIL PROTECTED]); print Area, popup_menu(-name='area1',-values=[EMAIL PROTECTED]),p; print Description,textfield(-name='file_desc',-size='50'); $subj1=param('Subject1'); $area1=param('area1'); $desc=param('file_desc'); #print $subj1; #$subj2=param('Subject1'); #$area2=param('area1'); $row3=$dbh-prepare(SELECT subj_id FROM tb_file_subj WHERE subj_desc = ?); $row4=$dbh-prepare(SELECT area_id FROM tb_file_area WHERE area_desc = ?); $row3-bind_param(1,$subj1); $row4-bind_param(1,$area1); $row3-execute(); $row4-execute(); while (($subj2) = $row3-fetchrow_array()){ $subj3=$subj2; } print $subj3; while (($area2) = $row4-fetchrow_array()){ $area3=$area2; } print $area3; $sth=$dbh-prepare(q{INSERT INTO tb_files (subj, area, file_no, file_desc) select ?, ?,(SELECT coalesce(max(file_no),0)+1 FROM tb_files WHERE subj = ? AND area = ?),?}) ; $sth-bind_param(1,$subj3); $sth-bind_param(2,$area3); $sth-bind_param(3,$subj3); $sth-bind_param(4,$area3); $sth-bind_param(5,$desc); $sth-execute ; print p; if($DBI::errstr ne ''){ print $DBI::errstr\n; } print p; print submit; print end_form; This is not I want - I only want it to execute when I click submit - is this possible? Curioisly, when I click refresh, the values dont reset -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: if -s clause
[EMAIL PROTECTED] wrote: I have tried all three methods if -s OUT, if -f $filename and if -s @arrayname with no evail. I did make a test.pl file so that I am just testing whether the file is greater than 0 bytes. Here is the code. autoflush is turned on. Is this the correct spot for this? 1. Autoflush is not turned on for the handle OUT. To do that, you would need to use: my $svsel = select; select OUT; $| = 1; or, better yet: use IO::Handle; OUT-autoflush(1); 2. Because of buffering, even though you have printed to OUT, the data has not actually been written to disk yet (still in the stdio buffers), so 3. -s OUT returns 0 (which is true) The proper test for your program is if (@ftapes) This evaluates the array in boolean (scalar) context, which gives the number of elements in the array. If the array is not empty, the test is true, regardless of what's going on with the file. Is it this tedious to test if a file is greater than 0 bytes Nope. You are testing, and the file is 0 bytes. I thought perl is supposed to be this great language for UNIX and C people??? Your algorithim is the problem, not Perl. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Yet Another Regex Problem
CHange your regex to /http(s)*:\/\/.*?\s/ To see the docs perldoc perlre ... look for greedy HTH Ram On Tue, 2004-06-08 at 16:15, Francesco del Vecchio wrote: Hi guyz, this regex are goin' to drive me crazy! My problem is: I have to find URLs in a text file (so, cannot use LWP or HTML parser) I've tried with something like /(http.:\/\/.*\s)/ willing to find anything starting with http/https with //: and catching everything up to a space or newline. It works in some cases but it catch the widest possible matching, so if I have something like try to click here http://www.yahoo.com or there http://www.google.com; the result for $1 is: http://www.yahoo.com or there http://www.google.com; How can I get simply http://www.yahoo.com; and then http://www.google.com;? thanx very much...you'r saving a man Francesco __ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: if -s clause
ok I can take some blame! : ) I made some changes and I am still not getting the print message. ## Set pragmas use strict; my $foreigntapes=/usr/local/log/foreign_tapes.log; delete $ENV{'IFS'}; local $ENV{'PATH'} = /usr/epoch/bin:/usr/epoch/EB/bin:/usr/bin:/usr/sbin:/bin:/sbin; open (OUT, $foreigntapes) || die could not open file:$!; my @ftapes = grep s/^barcode=//, `evmvol -w label_state=1`; my $svsel = select; select OUT; $| = 1; print OUT @ftapes; if ( -s OUT ) { print file is greater than 0 bytes \n; } Bob Showalter [EMAIL PROTECTED] 06/08/2004 09:45 AM To: '[EMAIL PROTECTED]' [EMAIL PROTECTED], [EMAIL PROTECTED] cc: Subject:RE: if -s clause [EMAIL PROTECTED] wrote: I have tried all three methods if -s OUT, if -f $filename and if -s @arrayname with no evail. I did make a test.pl file so that I am just testing whether the file is greater than 0 bytes. Here is the code. autoflush is turned on. Is this the correct spot for this? 1. Autoflush is not turned on for the handle OUT. To do that, you would need to use: my $svsel = select; select OUT; $| = 1; or, better yet: use IO::Handle; OUT-autoflush(1); 2. Because of buffering, even though you have printed to OUT, the data has not actually been written to disk yet (still in the stdio buffers), so 3. -s OUT returns 0 (which is true) The proper test for your program is if (@ftapes) This evaluates the array in boolean (scalar) context, which gives the number of elements in the array. If the array is not empty, the test is true, regardless of what's going on with the file. Is it this tedious to test if a file is greater than 0 bytes Nope. You are testing, and the file is 0 bytes. I thought perl is supposed to be this great language for UNIX and C people??? Your algorithim is the problem, not Perl.
Re: use lib(''); Apache httpd.conf
Hi, I have a rather simple question that Google hasn't produced answers for. Basically, I am installing Mason in a virtual host under mod_perl. The libraries I need are housed in ~/my/lib Really, your exact subject line gave 3-4 pages that provided similar answers at the top of the listing... How might I make Apache aware of ~/my/lib from the httpd.conf so that the following: PerlModule HTML::Mason::ApacheHandler will load? What is the equivalent for the httpd.conf of use lib('/my/lib'); ? http://perl.apache.org/docs/2.0/user/config/config.html#Adjusting_C__INC_ http://perl.apache.org/docs/2.0/user/porting/compat.html#Code_Porting May help. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: if -s clause
Please bottom post I have tried all three methods if -s OUT, if -f $filename and if -s @arrayname with no evail. See Bob's e-mail too, but why did the -s all of a sudden become a -f in the above statement? If this is not a typo, the -f will be true on the file if it exists and is normal, but doesn't tell you whether it has size. snip http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: if -s clause
Please bottom post ok I can take some blame! : ) I made some changes and I am still not getting the print message. You made *some* changes, but you still haven't listened to what Bob and I have said, and made the changes we have pointed out specifically. That is becoming tedious. I would suggest going back through the e-mails and re-reading every single statement made and see why your script still does not match what we have suggested. http://www.catb.org/~esr/faqs/smart-questions.html http://danconia.org ## Set pragmas use strict; my $foreigntapes=/usr/local/log/foreign_tapes.log; delete $ENV{'IFS'}; local $ENV{'PATH'} = /usr/epoch/bin:/usr/epoch/EB/bin:/usr/bin:/usr/sbin:/bin:/sbin; open (OUT, $foreigntapes) || die could not open file:$!; my @ftapes = grep s/^barcode=//, `evmvol -w label_state=1`; my $svsel = select; select OUT; $| = 1; print OUT @ftapes; if ( -s OUT ) { print file is greater than 0 bytes \n; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: if -s clause
yes -f is a typo! I want to use -s Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams 614-566-4145 Wiggins d Anconia [EMAIL PROTECTED] 06/08/2004 11:02 AM To: [EMAIL PROTECTED], [EMAIL PROTECTED] cc: Subject:Re: if -s clause Please bottom post I have tried all three methods if -s OUT, if -f $filename and if -s @arrayname with no evail. See Bob's e-mail too, but why did the -s all of a sudden become a -f in the above statement? If this is not a typo, the -f will be true on the file if it exists and is normal, but doesn't tell you whether it has size. snip http://danconia.org
OT - problem with script running on a refresh
Hi I have a CGI/dbi script which whenever the page is reloaded the following executes print start_multipart_form (POST); print Subject, popup_menu(-name='Subject1',-values=[EMAIL PROTECTED]); print Area, popup_menu(-name='area1',-values=[EMAIL PROTECTED]),p; print Description,textfield(-name='file_desc',-size='50'); $subj1=param('Subject1'); $area1=param('area1'); $desc=param('file_desc'); #print $subj1; #$subj2=param('Subject1'); #$area2=param('area1'); $row3=$dbh-prepare(SELECT subj_id FROM tb_file_subj WHERE subj_desc = ?); $row4=$dbh-prepare(SELECT area_id FROM tb_file_area WHERE area_desc = ?); $row3-bind_param(1,$subj1); $row4-bind_param(1,$area1); $row3-execute(); $row4-execute(); while (($subj2) = $row3-fetchrow_array()){ $subj3=$subj2; } print $subj3; while (($area2) = $row4-fetchrow_array()){ $area3=$area2; } print $area3; $sth=$dbh-prepare(q{INSERT INTO tb_files (subj, area, file_no, file_desc) select ?, ?,(SELECT coalesce(max(file_no),0)+1 FROM tb_files WHERE subj = ? AND area = ?),?}) ; $sth-bind_param(1,$subj3); $sth-bind_param(2,$area3); $sth-bind_param(3,$subj3); $sth-bind_param(4,$area3); $sth-bind_param(5,$desc); $sth-execute ; print p; if($DBI::errstr ne ''){ print $DBI::errstr\n; } print p; print submit; print end_form; This is not I want - I only want it to execute when I click submit - is this possible? Curioisly, when I click refresh, the values dont reset -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: about ppm
i tried this too,it is still giving the same error messages.. also,each time i open ppm window ,this warning comes: Warning:save c:\Perl\site\lib/ppm-conf\clientlib.cfg:Permission denied =Configuration not saved. what does this mean?? what should i do?do you think this ppm will work? -aditi Tarun Dua [EMAIL PROTECTED] wrote: Aditi gupta wrote: hi, i have to install bioperl modules. i gave its full address: ppm install http://bioperl.org/DIST/ it said: Error: No valid repositories Error: 500 Can't connect to ppm.ActiveState.com:80(Bad hostname 'ppm.ActiveState.com') Error: 500 Can't connect to ppm.ActiveState.com:80(Bad hostname 'ppm.ActiveState.com') it seems there are no repositories . what should i do?? Aditi, try something like ppm install http://bioperl.org/DIST/Bioperl-1.2.1.ppd or similar. -Tarun -- Where's the man could ease a heart Like a satin gown? -- Dorothy Parker, The Satin Dress -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Yahoo! India Matrimony: Find your partner online.
RE: if -s clause
ok so here is what I did and it is now working. one thing I do not fully understand is the diff between my $svsel = select; select OUT ; $|=1; and select (select(OUT), $| = 1 ) [0] ); the second line works while the first does not and from my understanding I am selecting OUT and never re-selecting the original filehandle? thanks! Here is the working code. ## Set pragmas use strict; use MIME::Lite; ## Set and edit variables my $foreigntapes=/usr/local/log/foreign_tapes.log; delete $ENV{'IFS'}; local $ENV{'PATH'} = /usr/epoch/bin:/usr/epoch/EB/bin:/usr/bin:/usr/sbin:/bin:/sbin; #print $ENV{'PATH'},\n; ## Traverse through array and play with data open (OUT, $foreigntapes) || die could not open file:$!; my @ftapes = grep s/^barcode=//, `evmvol -w label_state=3`; select( (select(OUT), $|=1 ) [0] ); print OUT @ftapes; if ( -s OUT ) { my $msg = MIME::Lite-new( From= 'EDM01 [EMAIL PROTECTED]', To = 'Derek Smith [EMAIL PROTECTED]', Subject = Foreign Tapes Found, now attmepting to label, Data= @ftapes ); $msg-send; foreach (@ftapes) { print $_; #`evmlabel -l st_9840_acs_0 -t 9840S -b$_` } } else { my $foo=/tmp/ftapes_runfile; open (RUNFILE, $foo) || die could not open runfile: $!; } close (RUNFILE); Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams 614-566-4145 Wiggins d Anconia [EMAIL PROTECTED] 06/08/2004 11:06 AM To: [EMAIL PROTECTED], [EMAIL PROTECTED] cc: Subject:RE: if -s clause Please bottom post ok I can take some blame! : ) I made some changes and I am still not getting the print message. You made *some* changes, but you still haven't listened to what Bob and I have said, and made the changes we have pointed out specifically. That is becoming tedious. I would suggest going back through the e-mails and re-reading every single statement made and see why your script still does not match what we have suggested. http://www.catb.org/~esr/faqs/smart-questions.html http://danconia.org ## Set pragmas use strict; my $foreigntapes=/usr/local/log/foreign_tapes.log; delete $ENV{'IFS'}; local $ENV{'PATH'} = /usr/epoch/bin:/usr/epoch/EB/bin:/usr/bin:/usr/sbin:/bin:/sbin; open (OUT, $foreigntapes) || die could not open file:$!; my @ftapes = grep s/^barcode=//, `evmvol -w label_state=1`; my $svsel = select; select OUT; $| = 1; print OUT @ftapes; if ( -s OUT ) { print file is greater than 0 bytes \n; }
RE: if -s clause
[EMAIL PROTECTED] wrote: ok so here is what I did and it is now working. one thing I do not fully understand is the diff between my $svsel = select; select OUT ; $|=1; and select (select(OUT), $| = 1 ) [0] ); the second line works while the first does not and from my understanding I am selecting OUT and never re-selecting the original filehandle? My bad. I should have added select($svsel) to the first line in order to reselect the previous handle (i.e. STDOUT). But as I said before, this is NOT the right approach to your problem. Just test your @ftapes array and be done with it. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: if -s clause
that's ok! thanks! my goal is to run the system app command only if the file handle OUT is greater than 0 bytes else create a runfile. You say test @ftapes but you never said how? is there a better way to just create a file rather than opening it and doing nothing. currently I am stating my $foo=/tmp/ftapes_runfile; open (RUNFILE, $foo) || die could not open runfile: $!; open (OUT, $foreigntapes) || die could not open file:$!; my @ftapes = grep s/^barcode=//, `evmvol -w label_state=3`; select( (select(OUT), $|=1 ) [0] ); print OUT @ftapes; if ( -s OUT ) { . } Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams 614-566-4145 Bob Showalter [EMAIL PROTECTED] 06/08/2004 11:40 AM To: '[EMAIL PROTECTED]' [EMAIL PROTECTED] cc: [EMAIL PROTECTED] Subject:RE: if -s clause [EMAIL PROTECTED] wrote: ok so here is what I did and it is now working. one thing I do not fully understand is the diff between my $svsel = select; select OUT ; $|=1; and select (select(OUT), $| = 1 ) [0] ); the second line works while the first does not and from my understanding I am selecting OUT and never re-selecting the original filehandle? My bad. I should have added select($svsel) to the first line in order to reselect the previous handle (i.e. STDOUT). But as I said before, this is NOT the right approach to your problem. Just test your @ftapes array and be done with it.
Mail Server in Perl on Win32 platform.
Am trying to get Activestate Perl to run a Mail server... been searching CPAN and found Net::Server::Mail::SMTP. the line: my $smtp = new Net::Server::Mail::SMTP socket = $conn; gives me the error: -- Can't locate object method new via package Net::Server::Mail::SMTP at testserver3.pl line 11. -- when I try to send mail through it. I would very much like to have a working mailserver- no need for security .. just a simple server. the server code follows:: (straight from the CPAN documentation) (http://search.cpan.org/~rsoliv/Net-Server-Mail-0.08/lib/Net/Server/Mail.pm) use Net::Server::Mail::SMTP; my @local_domains = qw(example.com example.org); my $server = new IO::Socket::INET Listen = 1, LocalPort = 25; my $conn; while($conn = $server-accept) { my $smtp = new Net::Server::Mail::SMTP socket = $conn; $smtp-set_callback(RCPT = \validate_recipient); $smtp-set_callback(DATA = \queue_message); $smtp-process; } sub validate_recipient { my($session, $recipient) = @_; my $domain; if($recipient =~ /@(.*)\s*$/) { $domain = $1; } if(not defined $domain) { return(0, 513, 'Syntax error.'); } elsif(grep $domain eq $_, @local_domains) { return(0, 554, $recipient: Recipient address rejected: Relay access denied); } return(1); } sub queue_message { my($session, $data) = @_; my $sender = $session-get_sender(); my @recipients = $session-get_recipients(); return(0, 554, 'Error: no valid recipients') unless(@recipients); my $msgid = add_queue($sender, [EMAIL PROTECTED], $data); or return(0); return(1, 250, message queued $msgid); } thank you, willy -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
FW: :DOM::Parser question !
All, Any help regarding below problem is greatly appreciated. My intention is to change value to true. javaTask className = tool.update.languagepack.MergeConfig arg name=sample value=false/ to javaTask className = tool.update.languagepack.MergeConfig arg name=sample value=true/ Thanks, Ravi -Original Message- From: Ravinder Arepally Sent: Monday, June 07, 2004 5:56 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: XML::DOM::Parser question ! All, I am trying to parse a XML file and change an element value. Below is code of mine where I am doing this. However, setAttribute doesn't work and it doesn't give any error message too. I spent enough time and doesn't make sense to me. I get right value using getAttribute('value). XML file is also pasted at the end of this mail. Any help or pointer is greatly appreciated. Any suggestions in writing better code for this task is also appreciated. Thank you, Ravi. --- my $udtTaskFile = $depotLocation/updates/$udtBaseName/tasks/$udtBaseName._cs_udt.xml; print (udtTaskfile is : $udtTaskFile \n); --- XML file which is pasted at end of this mail. Util::safeCopy($udtTaskFile, $udtTaskFile.time()); -- I have Util.pm my $parser = new XML::DOM::Parser; my $doc = $parser-parsefile($udtTaskFile); my @taskList = $doc-getElementsByTagName('taskEntry'); foreach my $task (@taskList) { if ($task-getAttribute('uniqueName') eq MergeConfig){ my $javaTask = $task-getElementsByTagName('javaTask'); if (! $javaTask) { $log-write(ERROR: Couldn't find any Java tasks in $udtTaskFile ); return Problem configuring installLPI. Couldn't find any Java Tasks in $udtTaskFile. ; } my $innerTask = $javaTask-item(0)-getElementsByTagName('arg'); if (! $innerTask) { $log-write(ERROR: Couldn't find any languagepack tasks in $udtTaskFile ); return Problem configuring installLPI. Couldn't find any languagepack Tasks in $udtTaskFile. ; } my $value = $innerTask-item(0)-getAttribute('value'); print (value is $value \n); This prints right value $innerTask-item(0)-setAttribute('value', true); - This is not working. No error and it doesn't change value } } -- !DOCTYPE harnessTaskList SYSTEM harnessTaskList.dtd harnessTaskList extensionClassname = tools.update.TaskHarnessExtForUDT logCategory = update/info !-- Task UDT Runs the update delivery tool -- taskEntry uniqueName = DiskSpace description = Checks if the necessary space is available on disk to proceed with update logCategory = update/info canRerun = true javaTask className = tools.update.DiskSpace/ /taskEntry taskEntry uniqueName = UDT description = Runs the update delivery tool dependency = DiskSpace logCategory = update/info canRerun = true javaTask className = tools.update.UpdateDeliveryTool/ /taskEntry taskEntry uniqueName = EnableLanguages description = Install files for language pack. dependency = UDT canRerun = true logCategory = lpi/info javaTask className = tool.update.languagepack.EnableLanguage/ /taskEntry taskEntry uniqueName = MergeConfig description = Merges language related files to config. dependency = UDT, EnableLanguages logCategory = lpi/info canRerun = true javaTask className = tool.update.languagepack.MergeConfig arg name=sample value=false/ -- This is the value I am trying to change /javaTask /taskEntry /harnessTaskList -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Retrieving Cookie from header
Folks: I am using the Net::HTTP package in building a small http client. I am trying to reuse an existing mechanism to talk to a db service through a servlet rather than code a new application in perl. Since I need to issue several http GET requests, cookies are used to keep session state. The problem is that the Net::HTTP package does not expose the cookie. Here is the perl http client code: use Net::HTTP; $product_id = $ARGV[0]; $doc_title = $ARGV[1]; $hname = $ARGV[2]; my $buf; #log into the host print SENDING login command\n; my $s = Net::HTTP-new(Host = $hname, keep_alive = TRUE) || die $@; $login_request = /XXX/home.jsp?NT_ID=ntid; $s-write_request(GET = $login_request, 'User-Agent' = Mozilla/5.0); ($code, $mess, %h) = $s-read_response_headers; print LOGIN CODE: , $code, \nMESS , $mess, \nh , %h,\n; #read login response page print READING login request\n; while (1) { my $n = $s-read_entity_body($buf, 4096); last unless $n; #print $buf; } - The line ($code, $mess, %h) = $s-read_response_headers; returns some header info but not access to the cookie. I believe the cookie is embedeed in the %h hash. Does anyone have any ideas? Joe Gajewski MLIM Information Technology (609) 274-4564 [EMAIL PROTECTED] If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Click here for important additional terms relating to this e-mail. http://www.ml.com/email_terms/
Exception Handling - Professionally
Greetings, For you professional Perl programmers: how do you approach exception-handling in the your world? I know there are a lot of ways Perl gives us to do this: basic 'die', eval'ing blocks of code and the Exception.pm module but is there a standard in the real world for handling exceptions? If I was assigned to modify some existing Perl code, what type of x-handling should I expect to see? Thanks, Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: how to generate array name dynamically
From: Sidharth [EMAIL PROTECTED] hi all, i hav a requirement wherein i hav to generate array name dynamically durin recursive function cal how can i do this . sid Please read the Why it's stupid to `use a variable as a variable name' - by M-J. Dominus http://www.plover.com/~mjd/perl/varvarname.html Jenda P.S.: How about starting to use a spellcheck? i hav? durin? cal? = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Exception Handling - Professionally
Greetings, For you professional Perl programmers: how do you approach exception-handling in the your world? I know there are a lot of ways Perl gives us to do this: basic 'die', eval'ing blocks of code and the Exception.pm module but is there a standard in the real world for handling exceptions? In my world, and a scary place it tis', I use a home grown object and just throw it as a return value. Subs generally then return either undef or the exception, or in the case I need a return value back I just check that return value to see if it is an instance of my exception object type. At the time, I was weary of using the die/eval model, if I had it to do over again (aka I will probably switch in the future) I would probably use a combination of the two since die/eval allows you to throw objects. perldoc Carp Might also be a useful read. If I was assigned to modify some existing Perl code, what type of x-handling should I expect to see? This is a trick question right? From the code I have seen/inherited I would have to answer: None. ;-) Being that this is a TMTOWTDI world I would imagine code you inherit could deal in multiple types of exception/error handling, especially depending on how many CPAN modules it might use. This is why being able to read documentation (I mean for comprehension) and learn APIs is so valueable for Perl developers http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: FW: :DOM::Parser question !
Thanks for your reply, Deane. It should work from the code, but I don't understand why it isn't. Annoying to me. Any pointers ? -Ravi _ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 08, 2004 10:28 AM To: Ravinder Arepally Cc: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]; '[EMAIL PROTECTED]' Subject: Re: FW: :DOM::Parser question ! Ravi, This seems like it ought to work--I do a lot of changing to an HTML file using similar code: # assume that $line contains the text you're working with--a line from a file--then... if ($line =~ /arg name = \sample\/) { $line =~ s/true/false/; } HTH, Deane Ravinder Arepally [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] 06/08/2004 12:07 To:'[EMAIL PROTECTED]' [EMAIL PROTECTED] cc:'[EMAIL PROTECTED]' [EMAIL PROTECTED] Subject:FW: :DOM::Parser question ! All, Any help regarding below problem is greatly appreciated. My intention is to change value to true. javaTask className = tool.update.languagepack.MergeConfig arg name=sample value=false/ to javaTask className = tool.update.languagepack.MergeConfig arg name=sample value=true/ Thanks, Ravi -Original Message- From: Ravinder Arepally Sent: Monday, June 07, 2004 5:56 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: XML::DOM::Parser question ! All, I am trying to parse a XML file and change an element value. Below is code of mine where I am doing this. However, setAttribute doesn't work and it doesn't give any error message too. I spent enough time and doesn't make sense to me. I get right value using getAttribute('value). XML file is also pasted at the end of this mail. Any help or pointer is greatly appreciated. Any suggestions in writing better code for this task is also appreciated. Thank you, Ravi. --- my $udtTaskFile = $depotLocation/updates/$udtBaseName/tasks/$udtBaseName._cs_udt.xml; print (udtTaskfile is : $udtTaskFile \n); --- XML file which is pasted at end of this mail. Util::safeCopy($udtTaskFile, $udtTaskFile.time()); -- I have Util.pm my $parser = new XML::DOM::Parser; my $doc = $parser-parsefile($udtTaskFile); my @taskList = $doc-getElementsByTagName('taskEntry'); foreach my $task (@taskList) { if ($task-getAttribute('uniqueName') eq MergeConfig){ my $javaTask = $task-getElementsByTagName('javaTask'); if (! $javaTask) { $log-write(ERROR: Couldn't find any Java tasks in $udtTaskFile ); return Problem configuring installLPI. Couldn't find any Java Tasks in $udtTaskFile. ; } my $innerTask = $javaTask-item(0)-getElementsByTagName('arg'); if (! $innerTask) { $log-write(ERROR: Couldn't find any languagepack tasks in $udtTaskFile ); return Problem configuring installLPI. Couldn't find any languagepack Tasks in $udtTaskFile. ; } my $value = $innerTask-item(0)-getAttribute('value'); print (value is $value \n); This prints right value $innerTask-item(0)-setAttribute('value', true); - This is not working. No error and it doesn't change value } } -- !DOCTYPE harnessTaskList SYSTEM harnessTaskList.dtd harnessTaskList extensionClassname = tools.update.TaskHarnessExtForUDT logCategory = update/info !-- Task UDT Runs the update delivery tool-- taskEntry uniqueName = DiskSpace description = Checks if the necessary space is available on disk to proceed with update logCategory = update/info canRerun = true javaTask className = tools.update.DiskSpace/ /taskEntry taskEntry uniqueName = UDT description = Runs the update delivery tool dependency = DiskSpace logCategory = update/info canRerun = true javaTask className = tools.update.UpdateDeliveryTool/ /taskEntry taskEntry uniqueName = EnableLanguages description = Install files for language pack. dependency = UDT canRerun = true logCategory = lpi/info javaTask className = tool.update.languagepack.EnableLanguage/ /taskEntry taskEntry uniqueName = MergeConfig description = Merges language related files to config. dependency = UDT, EnableLanguages logCategory = lpi/info canRerun = true javaTask className = tool.update.languagepack.MergeConfig arg name=sample
Glossary
I'm in the process of learning perl (hmm - right at the beginning of this process), and I'm having great difficulty working my way through the man pages. I'm a Windows user and perl is the first language I'm learning, so *everything* is new to me. I am also having to get to grips with using my shell account which is just adding to the difficulties. What would really make my life easier right now is a glossary of programming specific terms so that I'm not struggling to find meanings for the terminology used in some of the man pages (specifically I'm trying to work my way through man screen) every other word. Does such a glossary exist? I'm aware of the Jargon Files and I'm aware that many of these terms have man pages of their own (but my entire reason for reading man screen is to learn how to have different windows open with different things going on in each window!). Thank you for all your help, Karen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: XML::Simple
Wig, My Poor Mail client is very poor @ bottom post Any idea why it does not print exactly like it readslook @ tittle attribute. In source file, it is almost on top, while in output it's nearly on bottom ?? Thanks Mark G - Original Message - From: Wiggins d'Anconia [EMAIL PROTECTED] Date: Monday, June 7, 2004 11:33 pm Subject: Re: XML::Simple Please bottom post Mark Goland wrote: Wiggings, I should of been more clear. It does work, but does not produce same output as input. My best guess, it doesn't read in all the tags properly. AttrIndent is just a spacing thing, if if removed still does not work properly. C:\xml_parseperl -MXML::Simple -e print $XML::Simple::VERSION 2.12 That helps. I am assuming you are talking about how it is folding the single tags into attributes. This seems kind of contrived but I believe the following produces the same structure (aka out of order but that isn't strict), #!/usr/local/bin/perl use strict; use warnings; use XML::Simple; use Data::Dumper; my $ref = XMLin('./NMS.xml', ForceArray = [ 'itemList','menu','startPage','display','sortby','define','item','a','page' ], KeyAttr = [], ) or die $!\n; #print Dumper($ref); print XMLout($ref, XMLDecl = 1, RootName = 'root', NoAttr = 1); exit; The main changes are the list I had to pass to ForceArray, turning off the KeyAttr default list, not keeping the root element, but then also setting what the root element string should be, and finally telling it that none of the tags should be folded into attributes on output. I haven't come up with a good way to figure all of this out yet, usually I just do a lot of guess and test until it produces exactly what I want. Generally messing with ForceArray and KeyAttr has gotten me where I needed to go. You might re-examine the docs on these particular attributes. Helps? http://danconia.org - Original Message - From: Wiggins d'Anconia [EMAIL PROTECTED] To: Mark Goland [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, June 07, 2004 10:25 PM Subject: Re: XML::Simple Mark Goland wrote: Hello all, I am trying to play with simple XML. I hace reated a file, and am trying to read it in using XML::Simple and write it out, but with no luck :O(. Can someone point me to the correct error. Thanks in Advance, Mark G CODE: #!PERl -w use XML::Simple; use Data::Dumper; $ref = XMLin('.\NMS.xml', ForceArray = [ 'itemList', 'root' ,'menu' ],KeepRoot = 1,KeyAttr =define ) or die $!\n; print XMLout($ref, XMLDecl = 1,AttrIndent = 1); exit; snip xml file What version of XML::Simple are you using? My version at 2.07 does not have the 'AttrIndent' option and throws the following exception: Unrecognised option: AttrIndent at ./test.pl line 13 Which does appear in the docs on CPAN for version 2.12. If I remove that option then your program with the provided file works fine as far as I can tell, aka it runs. You didn't specifically state what problemyou are seeing. If this doesn't help give us the precise meaning of what isn't working, what the exact error is, etc. perl -MXML::Simple -e 'print $XML::Simple::VERSION' Should tell you your version number. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Glossary
I'm in the process of learning perl (hmm - right at the beginning of this process), and I'm having great difficulty working my way through the man pages. I'm a Windows user and perl is the first language I'm learning, so *everything* is new to me. I am also having to get to grips with using my shell account which is just adding to the difficulties. What would really make my life easier right now is a glossary of programming specific terms so that I'm not struggling to find meanings for the terminology used in some of the man pages (specifically I'm trying to work my way through man screen) every other word. Does such a glossary exist? I'm aware of the Jargon Files and I'm aware that many of these terms have man pages of their own (but my entire reason for reading man screen is to learn how to have different windows open with different things going on in each window!). Thank you for all your help, The wikipedia is often a good place to find definitions of various types. http://en.wikipedia.org/wiki/Main_Page HTH, http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: XML::Simple
Wig, My Poor Mail client is very poor @ bottom post Bummer, time to upgrade the mail client? ;-) Any idea why it does not print exactly like it readslook @ tittle attribute. In source file, it is almost on top, while in output it's nearly on bottom ?? I suspect because the structure is stored in a regular Perl hash, which does not guarantee ordering. See point number two at: http://search.cpan.org/~grantm/XML-Simple-2.12/lib/XML/Simple.pm#WHERE_TO_FROM_HERE? http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Exception Handling - Professionally
Scott == Scott Stearns [EMAIL PROTECTED] writes: Scott For you professional Perl programmers: how do you approach Scott exception-handling in the your world? I know there are a lot of Scott ways Perl gives us to do this: basic 'die', eval'ing blocks of Scott code and the Exception.pm module but is there a standard in the Scott real world for handling exceptions? If I was assigned to modify Scott some existing Perl code, what type of x-handling should I Scott expect to see? In a few weeks, you'll be able to read http://www.stonehenge.com/merlyn/PerlJournal/col12.html, or you can get it from TPJ now if you're a subscriber. But in there, I tout Exception::Class as a good solution. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Query Oracle, show results (need help!!)
Hello all. I am trying to log into an Oracle database, send this query { select * from ban where row num 100} and I am getting erros like: can't call method 'execute' on an undefined value at (filename) line_number. Got any suggestions? using the following perl script: #!/usr/bin/perl -w use strict; use DBI; # $ENV{ORACLE_HOME}=/orav101/oracle/8.0.6; #Gather data for connecting to database: print Enter the database name that you want to connect to: ; chomp (my $database_name1=STDIN); print Enter the username: ; chomp (my $username=STDIN); print Enter the password: ; chomp (my $passwd=STDIN); #Must define the database here: my $database=dbi:Oracle:$database_name1; #Connecting to the database:database=database_name1','$username','$passwd' #Note the variables for username and password must be username and passwd ONLY!! my $dbh = DBI-connect($database, $username, $passwd) or die Can't connect to Oracle database: \n $DBI::errstr\n; #Set up your sql statement that you want to run in Oracle my $sql=qq(select * from ban where row num 100); Prepare the SQL statement for running and it'll be stored in Oracle buffer my $sth=$dbh-prepare($sql); #Execute the SQL statememt $sth-execute || die Couldn't execute statement; while (my @record= $sth-fetchrow_array) { for (@record){ print (@record); } print \n\n; } $dbh-disconnect; - Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger
Re: Glossary
Karen, I realize I am not answering your question directly but may I suggest that you purchase a copy of 'Learning Perl' by Randal Schwartz Tom Phoenix. It is an excellent introduction to Perl. You may find it easier than going through the man pages. Cheers, Levon Barker On Tue, 2004-06-08 at 15:36, Karen McAtamney wrote: I'm in the process of learning perl (hmm - right at the beginning of this process), and I'm having great difficulty working my way through the man pages. I'm a Windows user and perl is the first language I'm learning, so *everything* is new to me. I am also having to get to grips with using my shell account which is just adding to the difficulties. What would really make my life easier right now is a glossary of programming specific terms so that I'm not struggling to find meanings for the terminology used in some of the man pages (specifically I'm trying to work my way through man screen) every other word. Does such a glossary exist? I'm aware of the Jargon Files and I'm aware that many of these terms have man pages of their own (but my entire reason for reading man screen is to learn how to have different windows open with different things going on in each window!). Thank you for all your help, Karen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Glossary
I agree. Also Perl for Dummies might help a bit. In the back there is a list of major commands typically used in Perl. The book was ok. Learning Perl 3rd Edition by Oreilly was better IMO. Karen, I realize I am not answering your question directly but may I suggest that you purchase a copy of 'Learning Perl' by Randal Schwartz Tom Phoenix. It is an excellent introduction to Perl. You may find it easier than going through the man pages. Cheers, Levon Barker On Tue, 2004-06-08 at 15:36, Karen McAtamney wrote: I'm in the process of learning perl (hmm - right at the beginning of this process), and I'm having great difficulty working my way through the man pages. I'm a Windows user and perl is the first language I'm learning, so *everything* is new to me. I am also having to get to grips with using my shell account which is just adding to the difficulties. What would really make my life easier right now is a glossary of programming specific terms so that I'm not struggling to find meanings for the terminology used in some of the man pages (specifically I'm trying to work my way through man screen) every other word. Does such a glossary exist? I'm aware of the Jargon Files and I'm aware that many of these terms have man pages of their own (but my entire reason for reading man screen is to learn how to have different windows open with different things going on in each window!). Thank you for all your help, Karen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Query Oracle, show results (need help!!)
I think you should turn on errors... by debault DBI will supress them. After the DB connection, put this... $db-{RaiseError} = 1; Once you do this you will see that your prepare failed, your SQL syntax is not valid. select * from ban where row num 100 It should be rownum, not row num. Rob -Original Message- From: jason corbett [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 08, 2004 3:53 PM To: [EMAIL PROTECTED] Subject: Query Oracle, show results (need help!!) Hello all. I am trying to log into an Oracle database, send this query { select * from ban where row num 100} and I am getting erros like: can't call method 'execute' on an undefined value at (filename) line_number. Got any suggestions? using the following perl script: #!/usr/bin/perl -w use strict; use DBI; # $ENV{ORACLE_HOME}=/orav101/oracle/8.0.6; #Gather data for connecting to database: print Enter the database name that you want to connect to: ; chomp (my $database_name1=STDIN); print Enter the username: ; chomp (my $username=STDIN); print Enter the password: ; chomp (my $passwd=STDIN); #Must define the database here: my $database=dbi:Oracle:$database_name1; #Connecting to the database:database=database_name1','$username','$passwd' #Note the variables for username and password must be username and passwd ONLY!! my $dbh = DBI-connect($database, $username, $passwd) or die Can't connect to Oracle database: \n $DBI::errstr\n; #Set up your sql statement that you want to run in Oracle my $sql=qq(select * from ban where row num 100); Prepare the SQL statement for running and it'll be stored in Oracle buffer my $sth=$dbh-prepare($sql); #Execute the SQL statememt $sth-execute || die Couldn't execute statement; while (my @record= $sth-fetchrow_array) { for (@record){ print (@record); } print \n\n; } $dbh-disconnect; - Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Glossary
From: [EMAIL PROTECTED]: I agree. Also Perl for Dummies might help a bit. In the back there is a list of major commands typically used in Perl. The book was ok. Learning Perl 3rd Edition by Oreilly was better IMO. I've already got a copy of Learning Perl, and I've made it few the first couple of chapters without too much grief, but it doesn't help with this particular problem:-( Karen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Glossary
Understood however I thought you were also lookinig for a glossary of Perl commands. The Perl for Dummies book has such a list in the back. Learning Perl doesn't have a list. Still... it's currently my favorite Perl book :D From: [EMAIL PROTECTED]: I agree. Also Perl for Dummies might help a bit. In the back there is a list of major commands typically used in Perl. The book was ok. Learning Perl 3rd Edition by Oreilly was better IMO. I've already got a copy of Learning Perl, and I've made it few the first couple of chapters without too much grief, but it doesn't help with this particular problem:-( Karen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
can't coerce array into hash
My boss wants me to write a script that will allow him to browse through the customers in our DB alphabetically. He wants all the customer's information to display on the page. I wrote the following as part of the script. I get the error 'Can't coerce array into hash' at the first 'if' into the loop. What am I doing wrong? my $sth2 = $dbh-prepare(SELECT id FROM people ORDER BY lname, fname, mname); $sth2-execute; my $people = $sth2-fetchall_arrayref; my $lastperson, $nextperson; for my $lv (0..$#{$people}) { if($people-[$lv]-{id} eq $id) { if(!$lv) { $lastperson = $people-[$lv-1]-{id}; } else { $lastperson = -1; } if($lv != $#{$people}) { $nextperson = $people-[$lv+1]-{id}; } else { $nextperson = -1; } } } -- Andrew Gaffney Network Administrator Skyline Aeronautics, LLC. 636-357-1548 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: can't coerce array into hash
Andrew Gaffney [EMAIL PROTECTED] wrote: : My boss wants me to write a script that will allow him to browse : through the customers in our DB alphabetically. He wants all the : customer's information to display on the page. I wrote the following : as part of the script. I get the error 'Can't coerce array into hash' : at the first 'if' into the loop. What am I doing wrong? : : my $sth2 = $dbh-prepare(SELECT id FROM people ORDER BY lname, : fname, mname); $sth2-execute; : my $people = $sth2-fetchall_arrayref; What does $people look like? use Data::Dumper 'Dumper'; print Dumper $people; __END__ Tell us what you get. Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: can't coerce array into hash
Charles K. Clarkson wrote: Andrew Gaffney [EMAIL PROTECTED] wrote: : My boss wants me to write a script that will allow him to browse : through the customers in our DB alphabetically. He wants all the : customer's information to display on the page. I wrote the following : as part of the script. I get the error 'Can't coerce array into hash' : at the first 'if' into the loop. What am I doing wrong? : : my $sth2 = $dbh-prepare(SELECT id FROM people ORDER BY lname, : fname, mname); $sth2-execute; : my $people = $sth2-fetchall_arrayref; What does $people look like? use Data::Dumper 'Dumper'; print Dumper $people; __END__ Tell us what you get. I'm loving Data::Dumper more and more. Apparently, it doesn't return a ref to an array of hashrefs like I figured it would. It it an array of array refs. I only requested one field from the DB so it is $people-[$lv]-[0]. -- Andrew Gaffney Network Administrator Skyline Aeronautics, LLC. 636-357-1548 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Calling subroutines from another file
Hi all. I have a main script file, a package in a separate 'package_name.pm' file and a file 'stuff.pl' that contains functions that both the main script and the package need to use. I've tried adding: require stuff.pl; to both the main script and the package. I can then call functions in 'stuff.pl' from the main script, but when I try from the package, I get: *** Undefined subroutine package_name::function_name called at package_name.pm line 545. So Perl is only looking inside the package for functions, it that right? How do I tell it to look outside the package for functions? -- Daniel Kasak IT Developer NUS Consulting Group Level 5, 77 Pacific Highway North Sydney, NSW, Australia 2060 T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989 email: [EMAIL PROTECTED] website: http://www.nusconsulting.com.au -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Calling subroutines from another file
Daniel Kasak [EMAIL PROTECTED] wrote: : I have a main script file, a package in a separate 'package_name.pm' : file and a file 'stuff.pl' that contains functions that both the : main script and the package need to use. : : I've tried adding: : : require stuff.pl; : : to both the main script and the package. I can then call functions : in 'stuff.pl' from the main script, but when I try from the package, : I get: : : *** Undefined subroutine package_name::function_name called at : package_name.pm line 545. : : So Perl is only looking inside the package for functions, it : that right? Probably. It's hard to tell without the code. : How do I tell it to look outside the package for functions? IMO, the easiest thing to do in the log run is to change stuff.pl into a module called (perhaps) stuff.pm. The you can use it. You might end up with something like this: package stuff; require Exporter; @ISA = qw(Exporter); @EXPORT_OK = qw( foo ); sub foo { return 'foo'; } 1; It would be called like this: #!/usr/bin/perl use strict; use warnings; use lib '.'; use stuff 'foo'; print foo(); __END__ Read the docs for Exporter on how to export functions and variables easily. Read perlmod for more info on writing modules. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Storable Problem
Hello Everyone, I have a problem is getting some data from database. I am getting the error like this: Storable binary image v2.6 more recent than I am (v2.4) at blib/lib/Storable.pm (autosplit into blib/lib/auto/Storable/thaw.al) line 342, Can someone tell me what is the error and some suggestions to overcome this problem.. Thanks in advance Regards, A+ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response