Re: CGI.pm *with* a templating system?
On Wed, 2004-01-21 at 01:45, Andrew Gaffney wrote: Dan Anderson wrote: On Tue, 2004-01-13 at 16:05, R. Bryant wrote: Hi List, Is it possible to use CGI.pm in conjunction with a templating system? Whenever you send out anything from your CGI object you'll do something like this, correct? my $cgi = CGI-new; print $cgi-header; Well you're *printing* anything you send out. So if you wanted to insert something between something else you would just print it. However, I'm not quite sure this response is exactly what you're looking for. I don't know of any templating systems off the top of my head that allow you to read in some template file and spit out some data. However, I would assume it would not be too hard to implement. Back when I was writing CGI in C (my pre-Perl days), I would create an HTML file that contained %s, %d, etc. in place of where values should go. I would then read in the file to a variable. I would do something like: printf($file_that_i_read, value1, value2, value3, value4, value5, value6); which worked fairly well. The only problem was that I had to create/edit the HTML templated by hand because any HTML editor would try to escape my '%s' and '%d'. Of course, since I write my HTML by hand anyway, that's not really a problem ;) Perl's substitution regular expressions work great for that. I often use HTML templates where in a section for a table I'll put something like: ##PUT#DATA#HERE## And regular expression s[##PUT#DATA#HERE##][$foo] where foo is what I'm putting in works wonderfully. -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: CGI.pm *with* a templating system?
-Original Message- From: Dan Anderson [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 2:30 PM To: Andrew Gaffney Cc: R. Bryant; [EMAIL PROTECTED] Subject: Re: CGI.pm *with* a templating system? On Wed, 2004-01-21 at 01:45, Andrew Gaffney wrote: Dan Anderson wrote: On Tue, 2004-01-13 at 16:05, R. Bryant wrote: Hi List, Is it possible to use CGI.pm in conjunction with a templating system? Whenever you send out anything from your CGI object you'll do something like this, correct? my $cgi = CGI-new; print $cgi-header; Well you're *printing* anything you send out. So if you wanted to insert something between something else you would just print it. However, I'm not quite sure this response is exactly what you're looking for. I don't know of any templating systems off the top of my head that allow you to read in some template file and spit out some data. However, I would assume it would not be too hard to implement. Back when I was writing CGI in C (my pre-Perl days), I would create an HTML file that contained %s, %d, etc. in place of where values should go. I would then read in the file to a variable. I would do something like: printf($file_that_i_read, value1, value2, value3, value4, value5, value6); which worked fairly well. The only problem was that I had to create/edit the HTML templated by hand because any HTML editor would try to escape my '%s' and '%d'. Of course, since I write my HTML by hand anyway, that's not really a problem ;) Perl's substitution regular expressions work great for that. I often use HTML templates where in a section for a table I'll put something like: ##PUT#DATA#HERE## And regular expression s[##PUT#DATA#HERE##][$foo] where foo is what I'm putting in works wonderfully. -Dan In my HTML files I use [NAME] for the items I want to replace, then use regular expressions to replace the tags. Code looks like this: Open(INF, filename.html); @my_web_page = INF; Close(INF); Foreach $line(@my_web_page) { $line =~ s/\[NAME\]/ $what_i_want_to_replace_it_with /g; } Print @my_web_page; Does the job just fine. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.564 / Virus Database: 356 - Release Date: 1/19/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.564 / Virus Database: 356 - Release Date: 1/19/2004 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
IO File Problems
hi there, couse of my missing skills with filehandling i would be happy if you provide me help. this is my problem: 1) I´m getting a list of email adresses (strings) from a database into an array - o.k. no problem ... 2) now i have to merge this strings with strings from a file. in this file there are many configuration sections. the section i need looks like this: [WHITELIST] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] so i need to get all adresse under the [whitelist] tag into an array and merge them with my other array. i need to move the filepointer unter the tag - than cut the digit number and the = out - put the email adress in a array and calc to the digit number of the last entry +1. how can i handle this? i would be happy if you provide me some functions to search the string in the file and filter spec. chars from a line out. sorry 4 my bad english but i am from austria :) best regards, lukas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
IO File Problems
hi there, couse of my missing skills with filehandling i would be happy if you provide me help. this is my problem: 1) I´m getting a list of email adresses (strings) from a database into an array - o.k. no problem ... 2) now i have to merge this strings with strings from a file. in this file there are many configuration sections. the section i need looks like this: [WHITELIST] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] so i need to get all adresse under the [whitelist] tag into an array and merge them with my other array. i need to move the filepointer unter the tag - than cut the digit number and the = out - put the email adress in a array and calc to the digit number of the last entry +1. how can i handle this? i would be happy if you provide me some functions to search the string in the file and filter spec. chars from a line out. sorry 4 my bad english but i am from austria :) best regards, lukas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: usage of Net::Telnet
This is what I do.. The only difference I see is that you haven't logged on.. my $rmhost = new Net::Telnet (Host = $nodesrch, Timeout = 100 ); $rmhost-login($uname_EGATE, $passwd_EGATE); $cat_command='cat ./data/journal/chopler'; @cat_result=$rmhost-cmd($cat_command); print @cat_result; Tim [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Try using input_log and output_log when you instantiate your telnet class. $obj = new Net::Telnet ([Binmode= $mode,] [Cmd_remove_mode = $mode,] [Dump_Log = $filename,] [Errmode= $errmode,] [Fhopen = $filehandle,] [Host = $host,] [Input_log = $file,] [Input_record_separator = $chars,] [Option_log = $file,] [Ors= $chars,] [Output_log = $file,] [Output_record_separator = $chars,] [Port = $port,] [Prompt = $matchop,] [Rs = $chars,] [Telnetmode = $mode,] [Timeout= $secs,]); This info can be further illustrated by entering 'perldoc Net::Telnet' form the command line. At 10:46 AM 1/20/04 +, you wrote: Hi , I am trying to use the Net::Telnet module after installing in my solaris 2.8 machine. But I am unable to get the output. There is no error messages either.The program just exists. Could you help me out on this please... #!/usr/bin/perl -w use Net::Telnet (); $t = new Net::Telnet (Timeout = 1000, Port = 8667); $t-open(ss-ps.demon.net); @output = $t-cmd(01244530112); print @output; --- - regards, Ajitpal Singh, Wipro Technologies. Finchley,London. Tel:044 208 495 6317 Mobile:07900534143 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Sub not working as it should
#!C:/Perl/bin/perl.exe #use IO::File; $file = comp.lst; $new = ee.lst; open (FH, $file) or die Cannot open file $file $!; open(NEW, $new) or die can't open $new: $!; while($line = FH) { chomp $line; opendir(DIR,$line\\c\$\\Docume~12) or errornos($line,1,NEW); print \nPrinting for machine $line\n; while ($d = readdir DIR) { print $d\n; } } close (FH); close (NEW); sub errornos($machine,$errorno,FIL) { print FIL error $errorno $machine; } For some reason the above code doesn't pass parameters to my subroutine? How why or am I misguided here! __ Do you Yahoo!? Yahoo! Hotjobs: Enter the Signing Bonus Sweepstakes http://hotjobs.sweepstakes.yahoo.com/signingbonus -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Sub not working as it should
On Jan 21, Saadat Saeed said: opendir(DIR,$line\\c\$\\Docume~12) or errornos($line,1,NEW); [snip] sub errornos($machine,$errorno,FIL) { print FIL error $errorno $machine; } For some reason the above code doesn't pass parameters to my subroutine? How why or am I misguided here! I don't know what Perl documentation you've read, but Perl subroutines don't look like that. You don't declare parameters. errornos($line, 1, \*NEW); # ... sub errornos { my ($machine, $errorno, $fh) = @_; print $fh error $errorno $machine\n; } Where did you pick up your current idea about Perl's subroutines? -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Re: Sub not working as it should
Thanks for the quick reponse - looks like I confuse my vbscript skills a bit... I am new to perl and am migrating over to vbscript! Regards --- Jeff 'japhy' Pinyan [EMAIL PROTECTED] wrote: On Jan 21, Saadat Saeed said: opendir(DIR,$line\\c\$\\Docume~12) or errornos($line,1,NEW); [snip] sub errornos($machine,$errorno,FIL) { print FIL error $errorno $machine; } For some reason the above code doesn't pass parameters to my subroutine? How why or am I misguided here! I don't know what Perl documentation you've read, but Perl subroutines don't look like that. You don't declare parameters. errornos($line, 1, \*NEW); # ... sub errornos { my ($machine, $errorno, $fh) = @_; print $fh error $errorno $machine\n; } Where did you pick up your current idea about Perl's subroutines? -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response __ Do you Yahoo!? Yahoo! Hotjobs: Enter the Signing Bonus Sweepstakes http://hotjobs.sweepstakes.yahoo.com/signingbonus -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Re: Re: Sub not working as it should
I am sorry I am migrating over to perl (love the built in debugger) --- Saadat Saeed [EMAIL PROTECTED] wrote: Thanks for the quick reponse - looks like I confuse my vbscript skills a bit... I am new to perl and am migrating over to vbscript! Regards --- Jeff 'japhy' Pinyan [EMAIL PROTECTED] wrote: On Jan 21, Saadat Saeed said: opendir(DIR,$line\\c\$\\Docume~12) or errornos($line,1,NEW); [snip] sub errornos($machine,$errorno,FIL) { print FIL error $errorno $machine; } For some reason the above code doesn't pass parameters to my subroutine? How why or am I misguided here! I don't know what Perl documentation you've read, but Perl subroutines don't look like that. You don't declare parameters. errornos($line, 1, \*NEW); # ... sub errornos { my ($machine, $errorno, $fh) = @_; print $fh error $errorno $machine\n; } Where did you pick up your current idea about Perl's subroutines? -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response __ Do you Yahoo!? Yahoo! Hotjobs: Enter the Signing Bonus Sweepstakes http://hotjobs.sweepstakes.yahoo.com/signingbonus -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response __ Do you Yahoo!? Yahoo! Hotjobs: Enter the Signing Bonus Sweepstakes http://hotjobs.sweepstakes.yahoo.com/signingbonus -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Re: Re: Sub not working as it should
You don't need to be sorry - it's the right choice ;-) Philipp -Original Message- I am sorry I am migrating over to perl (love the built in debugger) --- Saadat Saeed [EMAIL PROTECTED] wrote: Thanks for the quick reponse - looks like I confuse my vbscript skills a bit... I am new to perl and am migrating over to vbscript! Regards --- Jeff 'japhy' Pinyan [EMAIL PROTECTED] wrote: On Jan 21, Saadat Saeed said: opendir(DIR,$line\\c\$\\Docume~12) or errornos($line,1,NEW); [snip] sub errornos($machine,$errorno,FIL) { print FIL error $errorno $machine; } For some reason the above code doesn't pass parameters to my subroutine? How why or am I misguided here! I don't know what Perl documentation you've read, but Perl subroutines don't look like that. You don't declare parameters. errornos($line, 1, \*NEW); # ... sub errornos { my ($machine, $errorno, $fh) = @_; print $fh error $errorno $machine\n; } Where did you pick up your current idea about Perl's subroutines? -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response __ Do you Yahoo!? Yahoo! Hotjobs: Enter the Signing Bonus Sweepstakes http://hotjobs.sweepstakes.yahoo.com/signingbonus -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response __ Do you Yahoo!? Yahoo! Hotjobs: Enter the Signing Bonus Sweepstakes http://hotjobs.sweepstakes.yahoo.com/signingbonus -- 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: RadioButton question
Figured it out.. in case anyone was wondering... sub OnSetNodeDialog { # Construct the DialogBox my $setNode = $mw-DialogBox( -title=Set Node Dialog, -default_button = Cancel, -buttons=[OK, Cancel] ); # Now we need to add a Label widget so we can show some text $setNode-add('Label', -anchor = 'w', -justify = 'left', -text = qq(Choose Node to search on.\n\tCurrent Node = $nodesrch ))-pack; $setNode-Label(-text = 'Search on Node')-pack; my $org_value = $nodesrch; my $rb2_value = $nodesrch; my $answer2 = ; my $rb2_valueA = node-ex'; my $rb2_valueB = 'edwdev'; # my $rb2_value = node-ex'; $setNode-Radiobutton(-text = node-ex', -value = node-ex , -variable = \$rb2_value, -command = sub {OnSetNode(node-ex); })-pack; $setNode-Radiobutton(-text = 'edwdev', -value = edwdev, -variable = \$rb2_value, -command = sub {OnSetNode( edwdev); } )-pack; $answer2 = $setNode-Show(); if ($answer2 eq 'OK') { # ... nothing to do, accept the change... } else { # ... revert back to previous value ... $nodesrch = $org_value; } } [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello all.. the radiobuttons execute the code in the command whether I select OK or Cancel.. How can I execute on ok only? I have the following code: sub OnPowerSearchDialog { # Construct the DialogBox my $setpwrsrch = $mw-DialogBox( -title=Set Node Dialog, -buttons=[OK, Cancel] ); $setpwrsrch-add('Label', -anchor = 'w', -justify = 'left', -text = qq(Choose Node to search on.\n\tCurrent Node = $pwrsrch ))-pack; $setpwrsrch-Label(-text = 'Search on Node')-pack; my $rb3_value = $pwrsrch ; $setpwrsrch-Radiobutton(-text = 'NO', -value = NO , -variable = \$rb3_value, -command = sub {OnPowerSearch(NO); })-pack; $setpwrsrch-Radiobutton(-text = 'YES', -value = YES, -variable = \$rb3_value, -command = sub {OnPowerSearch(YES); } )-pack; $setpwrsrch-Show(); } sub OnPowerSearch { # set the power search variable $pwrsrch = $_[0] ; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: File::Copy
On Jan 21, zentara said: copy( $ARGV[0], $ARGV[0]\.bak ); chmod ($mode, $ARGV[0]\.bak); print Backup completed.\n; Why do you backslash the . in $ARGV[0]\.bak but not in completed.\n? Long story short, you don't need to \ the . in either case, and you don't need quotes around $ARGV[0] as the first argument to copy(). copy($ARGV[0] = $ARGV[0].bak); -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Loop Runners
Amit Phatak wrote: To run through a loop there more than one ways (a lot actually!) in PERL. It is Perl for the language and perl for the interpreter but never PERL. The ones I'm aware of are: To run through @array #1 $size = @array; for($i=0;$i$size;$i++) { print $array[$i]\n; } #2 foreach $i (@array) { print $i\n; } Can people please contribute on other ways to do the same thing. Please begin by #3, #4.. etc as you read on different ways. print $_\n for @array; for my $i ( @array ) { print $i\n; } print $array[$_]\n for 0 .. $#array; for my $i ( 0 .. $#array ) { print $array[$i]\n; } for ( my $i = 0; $i @array; ++$i ) { print $array[$i]\n; } my $i = 0; print $array[ $i++ ], \n while $i @array; my $i = 0; while ( $i @array ) { print $array[ $i++ ], \n; } my $i = 0; print $array[ $i++ ], \n until $i == @array; my $i = 0; until ( $i == @array ) { print $array[ $i++ ], \n; } print map $_\n, @array; map print( $_\n ), @array; grep print( $_\n ), @array; print map $array[$_]\n, 0 .. $#array; map print( $array[$_]\n ), 0 .. $#array; grep print( $array[$_]\n ), 0 .. $#array; my $i = 0; { print $array[ $i++ ], \n; redo if $i @array } my $i = 0; LOOP: { print $array[ $i++ ], \n; goto LOOP if $i @array } 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
Book review: Network Programming With Perl by Lincoln Stein
http://www.amazon.com/exec/obidos/tg/detail/-/0201615711/qid=1074699239/sr=1 -1/ref=sr_1_1/102-8963439-4561724?v=glances=books Drieux and others mentioned this book a couple of weeks ago. I just got a copy and spent yesterday afternoon exploring several parts of interest. I'm impressed: For one thing, it really is for novice/intermediate Perl folks. There is a *lot* of code in the book, and one of the neatest features is that each and every example is accompanied by a line-by-line explication of what each line of the program accomplishes. This is valuable because much of the CPAN code and OO-ish syntax is new to me, and just seeing it in a program without explanation is pretty opaque. The book is incidentally a pretty good introduction to CPAN and the CPAN shell. So much of the network code exists in CPAN modules that you are forced to negotiate CPAN in order to get the work done. Mr. Stein is a good guide to getting what you need from CPAN. There are a couple of caveats: all of the code is based on 5.003. I'm running 5.8, and have had to make a few concessions and adjustments here and there. (No warnings!). Also, it's pretty Unixy. The first script I tried did not in fact run properly on Windows, although it ran fine on FreeBSD. Finally, you should note that some of the programs in the book could get you in trouble with your local network admin. There are programs here that could set off intrusion alarms or even bring down applications if you make certain mistakes. All in all, a good investment I think, and my thanks to the list for recommending the book! -Chris -- 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 fileglob: Unix vs. Windows?
Hello... This script works fine on Unix: #!/usr/local/bin/perl use warnings; use strict; my $dir = /usr/home/admin; my @files = glob ($dir/*); print @files; But this script doesn't do right in Windows: use warnings; use strict; my $dir = E:\\Documents and Settings\\cmcmahon\\Desktop; print $dir\n; my @files = glob( $dir\\*); print @files; The print $dir\n statement works fine, but the print @files statement yields the value E:./Documentsand. Can someone explain what Windows needs here? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
tie STDOUT to TextUndo
Is there anyway to tie STDOUT to a TK::TextUndo widget or somehow call a save method for the TK::Text widget? Ideas and suggestions welcome. Thanks, Steve.. -- 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 strict and filehandles
On Tuesday, January 20, 2004, at 10:34 AM, B McKee wrote: Hi All, I'm having trouble understanding what use strict is trying to tell me. If I have run this program ...snipped open(MESSAGE, $datafile) or die Cannot open datafile: $!; while (!eof(MESSAGE)) { $page = new CGI(MESSAGE); ...more snippage I get this -RESULTS-- Bareword MESSAGE not allowed while strict subs in use at ./errorprog.pl line 16 (#1) (F) With strict subs in use, a bareword is only allowed as a subroutine identifier, in curly brackets or to the left of the = symbol. Perhaps you need to predeclare a subroutine? ...more snippage My questions are: 1) Why is it warning me at all? Using a bare word in the filehandle is common in my Perl manuals. In this case a bare word does everything I need it to do. What is this warning trying to prevent? 2) If I replace MESSAGE with $filehandlename and add $filehandlename to the my () block it doesn't complain. If I do that I haven't assigned a value to $filehandlename. Does that mean my filehandle is actually 'undef'? That doesn't seem right somehow, especially if I have multiple files open in a different circumstance. What value should I assign to $filehandlename? MESSAGE? Yep, I'm replying to my own post. I have now also determined that quoting the word 'MESSAGE' above e.g. open('MESSAGE', $datafile) clears the error. I guess use strict is trying to make sure I didn't actually mean to use some sort of variable. This is how I think I'll proceed in this case. I don't need to ever change the value of the filehandle in this subroutine. --side note: I gather the around $datafile are kinda pointless too. Brian -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: threads in perl
Igor Ryaboy wrote: I have no problem to alarm when timeout occurs in specific thread, I have a difficulty to abort a system command in that thread. in that case, fork a different process in your thread, replace system with exec and use the pid of the newly created process to abort itself when you need to. because exec replaces the running image, whatever you exec becomes the running process and because you have the pid to it, you can easily abort it without affecting the thread or your main process. david -- sub'_{print@_ ;* \ = * __ ,\ \} sub'__{print@_ ;* \ = * ___ ,\ \} sub'___{print@_ ;* \ = * ,\ \} sub'{print@_,\n}{_+Just}(another)-(Perl)-(Hacker) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Help with fileglob: Unix vs. Windows?
On Wednesday, January 21, 2004 10:53, McMahon, Chris queried: But this script doesn't do right in Windows: Modify the code as shown, and it should work: use warnings; use strict; my $dir = E:\\Documents and Settings\\cmcmahon\\Desktop; You have to escape the spaces, and for some reason, using backslashes seems to cause Perl problems here. And put the string in single quotes, so the backslash in front of the spaces is retained. So, change it to read as follows: my $dir = 'E:/Documents\ and\ Settings/cmcmahon/Desktop'; print $dir\n; my @files = glob( $dir\\*); You need a forward slash here as well. my @files = glob($dir/*); print @files; I would change this (only to make it look nicer, one filename per line) to: print $_\n for @files; HTH, Alan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: IO File Problems
hi there, hi | servus, 2) now i have to merge this strings with strings from a file. in this file there are many configuration sections. the section i need looks like this: [WHITELIST] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] so i need to get all adresse under the [whitelist] tag into an array and merge them with my other array. i need to move the filepointer unter the tag - than cut the digit number and the = out - put the email adress in a array and I assume @emails to be your array. #!/usr/bin/perl use strict; use warnings; my @emails=get_db_emails; open (FH, whitelist.txt) or die Cant open whitelist.txt: $!; while (FH){ next unless (/\[WHITELIST\]/); my $inlist=1; while ($inlist){ chomp ($_=FH); if (/^\d+=(.*)/) {push @emails, $1;} else {$in_list=0;} } } Yes, this is very dirty and only works if the whitelist.txt file looks like you showed - however, it can hold multiple [WHITELIST] sections. A section is assumed to end on the first line found that doesent hold the digits=email pair. Note that you shouldnt try to verify email syntax yourself (unless you want to spend weeks implementing the rfc822 and related).There is a Email::Valid modul at CPAN that does not only check the syntaxx but also if there is a MX server in that domain accepting email. calc to the digit number of the last entry +1. I didnt get what you want here - sorry. sorry 4 my bad english but i am from austria :) Nevermind, great skiing over there! Send me a mail in german (or austrian:-) if you need further help. Hope thats a start, Wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
capturing f1,f2, key presses instantlly
hello all, do any one of you know how can i capture f1 and f2 keypresses, and responding to them instantly without pressing enter ?? thanks
Re: capturing f1,f2, key presses instantlly
use Term::ReadKey; ReadMode 'cbreak'; $key = ReadKey(0); ReadMode 'normal'; At 09:34 AM 1/22/04 +0200, you wrote: hello all, do any one of you know how can i capture f1 and f2 keypresses, and responding to them instantly without pressing enter ?? thanks
Loading libraries into a static Perl
Hey, I am trying to create a stand alone (static) program in Perl (no shared libraries). I have tried perlcc -L /lib perl.pl but am not have any luck. This will create an executable but you still need the shared libraries. I have also typing in the path of each library (ie perlcc -L /lib/libperl.so -L /lib/libns1.so.1 perl.pl) This complied the perl program the same. Any Ideas. Thanks
format localtime()
Hi I have the following script that sucks in a file and converts unix timestamp to human readable.. The Goal is to do a search and replace of unix time to the format i need. But I'm just trying to get it to print in the format i need first... I cant get localtime to print in mm-dd- hh:mm:ss , I keep getting it like so Sun Dec 28 03:35:19 2003 #!/usr/bin/perl use strict; # #my $timestring = localtime(); open (FILE, ip.txt) || die (Open Failed: $!\n); my @lines = FILE; # file into array foreach (@lines) { next if /^S/; next if /^-/; my @line = split(/\t/, $_); my @time = split(/\n/, $line[0]); foreach (@time) { my ($sec,$min,$hour,$mday,$mon,$year) = localtime($_); # need to print like mm-dd- hh:mm:ss my $timestring = localtime($_); # but prints like Sun Dec 28 03:35:19 2003 print $timestring\n; } } close FILE; # more ip.txt: Start header header - - - 1072611319 rrr 1072611319 rrr 1072611319 rrr 1072611319 rrr Thanks Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: format localtime()
Hi I have the following script that sucks in a file and converts unix timestamp to human readable.. The Goal is to do a search and replace of unix time to the format i need. But I'm just trying to get it to print in the format i need first... I cant get localtime to print in mm-dd- hh:mm:ss , I keep getting it like so Sun Dec 28 03:35:19 2003 That's what it returns in scalra context. You can call it in array context and get the specifc values you want. You may have to modify them a bit ( add 1900 to the year for instance) Take a look at perldoc -f localtime to seee which parts of the array are which values you want in which format. HTH Dmuey #!/usr/bin/perl use strict; # #my $timestring = localtime(); open (FILE, ip.txt) || die (Open Failed: $!\n); my @lines = FILE; # file into array foreach (@lines) { next if /^S/; next if /^-/; my @line = split(/\t/, $_); my @time = split(/\n/, $line[0]); foreach (@time) { my ($sec,$min,$hour,$mday,$mon,$year) = localtime($_); # need to print like mm-dd- hh:mm:ss my $timestring = localtime($_); # but prints like Sun Dec 28 03:35:19 2003 print $timestring\n; } } close FILE; # more ip.txt: Start header header - - - 1072611319 rrr 1072611319 rrr 1072611319 rrr 1072611319 rrr Thanks Rob -- 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: double-log-tail
Cool, thanks - both look promising. j On Mon, 2004-01-19 at 14:47, Wiggins d'Anconia wrote: Joel Newkirk wrote: I'm interested in tailing two logs (qmail) simultaneously, and interleaving the data in something approaching chronological sequence, as well as dealing with logfile rotation gracefully. Any suggestions? Check out File::Tail on CPAN, particularly the section on 'select' and the mentioned example script, it should get you close. http://search.cpan.org/~mgrabnar/File-Tail-0.98/Tail.pm And I might as well throw a POE reference in here, as usual this sort of thing is trivial in POE, particularly since there is already a Wheel written to do it, check out the cookbook entry here (not for the faint of heart): http://poe.perl.org/?POE_Cookbook/Watching_Logs HTH, http://danconia.org -- Not all those who wander are lost. - JRR Tolkien -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: format localtime()
rmck wrote: I cant get localtime to print in mm-dd- hh:mm:ss , I keep getting it like so Sun Dec 28 03:35:19 2003 POSIX::strftime gives you complete control over the format. use POSIX 'strftime'; print strftime('%m-%d-%Y %H:%M:%S', localtime), \n; perldoc POSIX -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Help with fileglob: Unix vs. Windows?
On Wed, 2004-01-21 at 11:52, McMahon, Chris wrote: Hello... This script works fine on Unix: #!/usr/local/bin/perl use warnings; use strict; my $dir = /usr/home/admin; my @files = glob ($dir/*); print @files; But this script doesn't do right in Windows: use warnings; use strict; my $dir = E:\\Documents and Settings\\cmcmahon\\Desktop; print $dir\n; my @files = glob( $dir\\*); print @files; The print $dir\n statement works fine, but the print @files statement yields the value E:./Documentsand. Can someone explain what Windows needs here? It's not windows, your spaces aren't escaped. Either replace them with a \s (whitespace char) or properly escape them. -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Program to write code
Hi, could anyone recommend a good program to write code, currently using notepad. Thanks a lot in advance. Marcelo
Re: Program to write code
On Wed, 2004-01-21 at 17:32, Marcelo wrote: Hi, could anyone recommend a good program to write code, currently using notepad. I really like Emacs, but it has a high learning curve. Check out: http://www.xemacs.org/ And, of course, not everyone likes Emacs. Better check out ViM as well: http://www.vim.org/ -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: On import v. Just Do It.
On Jan 20, 2004, at 9:19 AM, Dan Muey wrote: Oops left out a sentence sorry for the delay. p0: yes, one can use an import() from a package to make something like the scam of 'require in line' Why is it a scam if that's what I want to do for myself? I presume we are talking about http://www.nntp.perl.org/group/perl.beginners/58676 eg: package Foo::Monkey; sub import { for my $pragma (qw(strict warnings)) { require $pragma.pm; $pragma-import; } } which does have the technical nit that it did not end with 1; so is not really ready to be rolled up as a perl module. cf: http://www.nntp.perl.org/group/perl.beginners/58551 rather than starting with a code template of #!/usr/bin/perl use strict; use warnings; So the idea of learning about how to do an 'import' is a worthwhile crusade in itself. I'm just not convinced that it really has the voodoo one would want since it of course is doing the obligatory two step of first requiring the pragma and then invoking it's import method... cf the distinctions between 'require' and 'use'. So my notion of 'scam' derives from the politer approach to the comedy of someone coming up with a Way to solve a problem that seems fundamentally structurally more complex than the problem that it is trying to solve. for the twin pragma of 'use strict' and 'use warnings' { oye! } p1: But there is this minor technical overhead that comes with the process - 1.a: one needs to use h2xs to make sure that the module will conform with the current best practices and be appropriately installable in the CPAN way my module or strict and warnings? One would assume the the developer has a responsibility to make their code solid and as compatible and compliant as possible oh quite right. So why would one want to add in a module that had merely the importing of the two lines that are pragma? which is the target of my rant. I of course would not feel morally upright if I had constructed a perl module that did not contain a. the version of perl that was my minimum to bid use 5.006001; b. the canonical brace of caution: use strict; use warnings; c. the version value: our $VERSION = '1.3'; The reason that I of course appeal to the h2xs approach is that it will include the base suite of files a. MANIFEST b. Makefile.PL c. foo.pm d. t/1.t So that I can have a basic framework for making sure that I can get the core steps done perl *.PL make make test make install So now the problem has evolved from merely two lines of pragma, to a minimum of four files that I need to keep under source code control. 1.b: one has to maintain that module just to make the two lines of pragma readily available to all of one's perl code. If that's the point of the module and users know that, isn't the maintainer supposed to, well er maintain it properly? Also wouldn't the script author have to do the same thing except in all his scripts instead of one place? Oh yes... and that of course is where we are now up to the four files in the SCCS du jure, and 1.c: the count of lines of the perl module vice the simple inclusion of the two lines makes the process a bit Wonky if you know what I mean. Not really, if we are talking strictly line counts then do this: in 50 scripts: use Foo::Monkey; = 50 lines ( ok 100 if you count: sub import { for('strict',warnings') { if(gotmodule($_) { $_-import; } } } # gotmodule is a function in side Foo::Monkey that basically does eval(use $_[0]) # and returns true if it was able to be loaded, it works too I tested it # also it avoids killing the script if it can't be loaded since it only does $_-import # if the module could be use()ed ) you get strict and warnings plus the many other nifty things about Foo::Monkey use strict;use warnings = 100 lines. So depending on how you look at it, there are less or the same amount of *lines* but many more advantages as far as I can tell. We're missing the part where all perl scripts start with #!/usr/bin/perl since we can be pedantic 8-) But of course so far we have not included a. the POD for the module b. the readme and change files p2: clearly the fact has been established that it can be done, but it also notes the 'and you want this pain why?' problem I don't understand the pain you speak of, could you define more clearly why I don't want to do the import() to make it automatic so this module's users have to consciously turn
Join strings problem
Hallo and thank in advance. what am I doing wrong? I'm new to Perl. my Building string is not being built. is it that I need to declare the joined strings a string?How? Lou #!/usr/local/bin/perl print qq|Content-type: text/html\n\n|; my $EW5NS5=TEST.gif; ##this is the string I need to build. print qq|TABLE\n|; for ($row=0; $row10; $row++) { print qq|TR\n|; for ($col=0; $col 10; $col++) { ##build variable $Building=join(.EW.$row.NS.$col); print qq|TD bgcolor=black$Building/TDTD/TD\n|; } print qq|/TR\n|; } print qq|/TABLE\n|; print qq|x $EW5NS5 x br\n|; print qq|x $Building x\n|;
Re: Join strings problem
On Jan 21, 2004, at 2:26 PM, Luinrandir Hernsen wrote: #!/usr/local/bin/perl use strict; use warnings; my ($Building, $row, $col); { dan's gonna kill me for that one... 8-) } print qq|Content-type: text/html\n\n|; my $EW5NS5=TEST.gif; ##this is the string I need to build. print qq|TABLE\n|; for ($row=0; $row10; $row++) { print qq|TR\n|; for ($col=0; $col 10; $col++) { ##build variable $Building=join(.EW.$row.NS.$col); with warnings on it would have told you about the bare word's so you could try say: $Building=EW${row}NS${col}; or say $Building = sprintf(EW%sNS%s, $row, $col); or say $Building= 'EW' . $row . 'NS' . $col ; print qq|TD bgcolor=black$Building/TDTD/TD\n|; } print qq|/TR\n|; } print qq|/TABLE\n|; print qq|x $EW5NS5 x br\n|; print qq|x $Building x\n|; and the last lines look like: TD bgcolor=blackEW9NS8/TDTD/TD TD bgcolor=blackEW9NS9/TDTD/TD /TR /TABLE x TEST.gif x br x EW9NS9 x ciao drieux --- -- 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 initialize an array of unknown size to 0?
Hello, Can anyone tell me how I can do the following - all the elements in my array of unkown size should be initialised to the value 0 ? thanks, vaish. -- ___ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Join strings problem
On Jan 21, 2004, at 6:46 PM, Luinrandir Hernsen wrote: I thanks you very much for reply and all 3 ways do work. unfortunately I did not state the situation completely. $Building is to = the variable $EW0NS0 thru $EW10NS10 This is so I can set certain variables like my $EW5NS5=TEST.gif; to show a certain pictures, while other squares of the table remain empty. Ah! I think I see a bit more where you are going, sounds like what you really want is an array of arrays so as not to need to worry about the problem of trying to create 'variables'. As it now works $Building does = EW0NS0 etc, but I need $Building to equal the string/value that $EW0NS0 represents early in the program. (a rread/write file will soon be built in here.) Right what you want to do is the majik variable trick. This is highly not recommended. Do I express it better this time? I apollogize for my lack or explination and Thank you for your efforts and furture help. [..] My mistake for misreading the first time, allow me to illustrate the idea. #!/usr/bin/perl use strict; use warnings; my ($Building, $row, $col); my $max=4; my @array = (); foreach $row (0..$max){ foreach $col (0..$max){ $array[$row][$col] = bob at ${row} said $col; } } $array[3][3] = The Majik word is 3 by 3; print qq|Content-type: text/html\n\n|; my $EW5NS5=TEST.gif; ##this is the string I need to build. print qq|TABLE\n|; foreach my $row (0..$max) { print qq|TR\n|; foreach my $col (0..$max) { $Building = $array[$row][$col]; print qq|TD bgcolor=black$Building/TDTD/TD\n|; } print qq|/TR\n|; } print qq|/TABLE\n|; print qq|x $EW5NS5 x br\n|; print qq|x $Building x\n|; print the Majik Word is: $array[3][3]\n; HTH... ciao drieux -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Upload files and directories
I am in dire need of a script that will upload everything from one server to another one that I can cron. Right now I have to do it by hand and with more and more updates being done to the site, I need a way to do it seamlessly. One that checks dates against each other would be cool too. i.e.: if the web server date is the same as the design server, no uploading that file. Does anyone have one or know where I can find one? Even multiple ones that I have to piece-meal or get the logic from and rewrite myself would be good to. I have googled and am starting to go through the first page of results but I was hoping someone here might already have one or might have come across one somewhere. Thanks!! Robert -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Upload files and directories
On Wed, Jan 21, 2004 at 11:49:53PM -0500, Lone Wolf wrote: I am in dire need of a script that will upload everything from one server to another one that I can cron. Right now I have to do it by hand and with more and more updates being done to the site, I need a way While not a Perl solution, you have just described rsync, which is one of the most handy programs around for updating things remotely. http://rsync.samba.org - will come with virtually all Linux distros, and is probably avaliable for windows also. -- Robin [EMAIL PROTECTED] JabberID: [EMAIL PROTECTED] Hostes alienigeni me abduxerunt. Qui annus est? PGP Key 0x776DB663 Fingerprint=DD10 5C62 1E29 A385 9866 0853 CD38 E07A 776D B663 pgp0.pgp Description: PGP signature
RE: how to initialize an array of unknown size to 0?
Hi Vaish, The size of your unknown sized array can be found using the function scalar. Here is one way to do it. #! /usr/bin/perl -w my @arrUnknownSize = (1,3,4); for(my $i=0; $i scalar(@arrUnknownSize); $i++) #try using the condition $i = scalar(@arrUnknownSize) and watch da fun! {$arrUnknownSize[$i] = 0}; print @arrUnknownSize; __END__ Chetak -Original Message- From: vaishnavi krishnamurthy [mailto:[EMAIL PROTECTED] Sent: Thursday, January 22, 2004 6:42 AM To: [EMAIL PROTECTED] Subject: how to initialize an array of unknown size to 0? Hello, Can anyone tell me how I can do the following - all the elements in my array of unkown size should be initialised to the value 0 ? thanks, vaish. -- ___ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Upload files and directories
Robin Sheat wrote: On Wed, Jan 21, 2004 at 11:49:53PM -0500, Lone Wolf wrote: I am in dire need of a script that will upload everything from one server to another one that I can cron. Right now I have to do it by hand and with more and more updates being done to the site, I need a way While not a Perl solution, you have just described rsync, which is one of the most handy programs around for updating things remotely. http://rsync.samba.org - will come with virtually all Linux distros, and is probably avaliable for windows also. I second the nomination for rsync. I use it to backup my production Linux server nightly to another machine. -- Andrew Gaffney System Administrator Skyline Aeronautics, LLC. 776 North Bell Avenue Chesterfield, MO 63005 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
Getting data from hashes
I have a method 'getNetwork' that returns a hash. I can quite happily go: %reply = $network-getNetworkError('net','data','data2'); my $baseErr = $reply{error}; however, I can't go: my $baseErr = $network-getNetworkError('net','data','data2')-{error}; nor: my $baseErr = ${$network-getNetworkError('net','data','data2')}{error}; why not? And is there any way to do this in one line? (If you're wondering, I've written a Perl module that effectivly provides an API to access a Java program that I wrote to do neural networks, with the communication between Perl and Java done via XML - so I get the nice development abilities of Java, and the report generation and quick editing of Perl). -- Robin [EMAIL PROTECTED] JabberID: [EMAIL PROTECTED] Hostes alienigeni me abduxerunt. Qui annus est? PGP Key 0x776DB663 Fingerprint=DD10 5C62 1E29 A385 9866 0853 CD38 E07A 776D B663 pgp0.pgp Description: PGP signature
RE: threads in perl
Hi, Thanks for your help, 1 more question related to your advice Ok, How can I kill exec after it was started in different thread? Igor -Original Message- From: david [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 8:10 PM To: [EMAIL PROTECTED] Subject: RE: threads in perl Igor Ryaboy wrote: I have no problem to alarm when timeout occurs in specific thread, I have a difficulty to abort a system command in that thread. in that case, fork a different process in your thread, replace system with exec and use the pid of the newly created process to abort itself when you need to. because exec replaces the running image, whatever you exec becomes the running process and because you have the pid to it, you can easily abort it without affecting the thread or your main process. david -- sub'_{print@_ ;* \ = * __ ,\ \} sub'__{print@_ ;* \ = * ___ ,\ \} sub'___{print@_ ;* \ = * ,\ \} sub'{print@_,\n}{_+Just}(another)-(Perl)-(Hacker) -- 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: how to initialize an array of unknown size to 0?
vaishnavi krishnamurthy [EMAIL PROTECTED] wrote: : Can anyone tell me how I can do the following - all the : elements in my array of unknown size should be initialized : to the value 0? Assuming your array has only one dimension: @array = (0) x @array; HTH, Charles K. Clarkson -- Head Bottle Washer, Clarkson Energy Homes, Inc. Mobile Home Specialists 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: how to initialize an array of unknown size to 0?
Vaishnavi Krishnamurthy wrote: Hello, Hello, Can anyone tell me how I can do the following - all the elements in my array of unkown size should be initialised to the value 0 ? @array = (0) x @array; 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
Re: Getting data from hashes
Robin Sheat wrote: I have a method 'getNetwork' that returns a hash. Actually, subroutines in perl return lists. I can quite happily go: %reply = $network-getNetworkError('net','data','data2'); my $baseErr = $reply{error}; however, I can't go: my $baseErr = $network-getNetworkError('net','data','data2')-{error}; nor: my $baseErr = ${$network-getNetworkError('net','data','data2')}{error}; why not? And is there any way to do this in one line? You have to convert the list so that the hash key can be extracted. my $baseErr = { $network-getNetworkError('net','data','data2') }-{error}; 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