RE: Use of uninitialized value
what do you mean I cant? It is logically working! Is this is recommedation for more readibility and thats it? Or is this Perl best practice thingy? thank you! Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams Charles K. Clarkson [EMAIL PROTECTED] To .net beginners-cgi@perl.org cc 09/13/2005 02:02 PMSubject RE: Use of uninitialized value [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] wrote: : I'd rather send the whole thing b/c I also would like a critique : as well. Here she is! First glaring item: you cannot nest subroutines. To perl, the following are equivalent. === print blah; if ( $which_radio_button eq 'All-Clients' ) { viewall(); sub viewall { # do something; } } elsif ( $which_radio_button eq 'Backup-Tapes' ) { viewbkups(); sub viewbkups { # do something else; } } === print blah; if ( $which_radio_button eq 'All-Clients' ) { viewall(); } elsif ( $which_radio_button eq 'Backup-Tapes' ) { viewbkups(); } sub viewall { # do something; } sub viewbkups { # do something else; } === So there's no advantage to placing the subs in line and taking them out makes your code more readable. 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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Perl DBI / SQL Question
Sorry if the cross-posting wasn't appropriate, but I need help with this and am not sure if it's more appropriate to post under CGI or DBI since it involves both...I want to be sure that I can get help from the best source. My question is probably a simple answer, but I am not sure what I have to do and the books I have here are either not answering the question, or I'm not finding the answer. I need to know how to retrieve through Perl DBI a listing of possible ENUM elements from a field for processing under a CGI script. If all I need for this is some form of SELECT statement, please provide a code snippet of this so I can do it. I want to make my code so I'm not having to edit hard-coded Perl CGI scripts if/when I add new elements to the ENUM field. Any help you can provide would be greatly appreciated. Thanks! Vance -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
File Modification Date
I'm trying to find out how to determine the date and/or time that a file was created in a simple procedure. I have heard about a few different libraries but the examples I have found haven't been very useful. The basic purpose I want to do is a simple footer provided by a package module through CGI to inform users of the latest update to the code based on the URL. Something simple saying Version x.xx, Last Modified MM/DD/. which would automatically get the file modified timestamp. I'd prefer to have, if possible, a simple scalar variable to store the date...for example: $modtime = filemoddate_func(filename.cgi); If anyone can help me with the libraries I need to use for this (if any special), and a code snippet if possible, I'd really appreciate it. Thanks! Vance -- 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 Modification Date
perldoc -q timestamp 12:42am, Vance M. Allen wrote: I'm trying to find out how to determine the date and/or time that a file was created in a simple procedure. I have heard about a few different libraries but the examples I have found haven't been very useful. The basic purpose I want to do is a simple footer provided by a package module through CGI to inform users of the latest update to the code based on the URL. Something simple saying Version x.xx, Last Modified MM/DD/. which would automatically get the file modified timestamp. I'd prefer to have, if possible, a simple scalar variable to store the date...for example: $modtime = filemoddate_func(filename.cgi); If anyone can help me with the libraries I need to use for this (if any special), and a code snippet if possible, I'd really appreciate it. Thanks! Vance -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response --- --In 1555, Nostradamus wrote:-- -- Come the millennium, month 12, -- -- In the home of greatest power, -- -- The village idiot will come forth -- -- To be acclaimed the leader. -- --- -- 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 Modification Date
Vance M. Allen wrote: I'm trying to find out how to determine the date and/or time that a file was created in a simple procedure. I have heard about a few different libraries but the examples I have found haven't been very useful. The basic purpose I want to do is a simple footer provided by a package module through CGI to inform users of the latest update to the code based on the URL. Something simple saying Version x.xx, Last Modified MM/DD/. which would automatically get the file modified timestamp. I'd prefer to have, if possible, a simple scalar variable to store the date...for example: $modtime = filemoddate_func(filename.cgi); If anyone can help me with the libraries I need to use for this (if any special), and a code snippet if possible, I'd really appreciate it. Thanks! Vance Generally this type of information is provided by Cstat, see, perldoc -f stat For the details. To get the modification time for example you could use something like, my $mod_time = (stat 'filename.cgi')[9]; File creation time is rarely if ever available. Obviously you could wrap the above in a sub, but I suspect there isn't a lot of reason to since it is so short anyways. 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: Perl DBI / SQL Question
Vance M. Allen wrote: I need to know how to retrieve through Perl DBI a listing of possible ENUM elements from a field for processing under a CGI script. Need to know what database you're talking about. This will probably involve querying data dictionary views or tables. Some DBI drivers also have specific methods for this kind of thing. -- 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 of uninitialized value
--- [EMAIL PROTECTED] wrote: what do you mean I cant? It is logically working! Is this is recommedation for more readibility and thats it? Or is this Perl best practice thingy? Because Perl subroutines are not lexically scoped. sub foo { sub bar { return 'bar'; } print bar(); } print bar(); If you really need lexically scoped subroutines, assign an anonymous subroutine to a scalar: sub foo { my $bar = sub { return 'bar'; }; print $bar-(); } # no access to $bar from here Cheers, Ovid -- If this message is a response to a question on a mailing list, please send follow up questions to the list. Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/ -- 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 of uninitialized value
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: : it is on line 207...thx! : Use of uninitialized value in string eq at line 207 : (See attached file: ASM_monitor.pl) Are you certain the version you sent is the version on the server? This does not produce an error. (It is from the version you sent.) #!/usr/bin/perl use strict; use warnings; use CGI qw(:standard), (-unique_headers); my $q = CGI-new(); my $which_import = $q-param('action') || ''; if ($which_import eq 'Import STKvol') { print foo\n; } __END__ This *does* produce an error. #!/usr/bin/perl use strict; use warnings; use CGI qw(:standard), (-unique_headers); my $q = CGI-new(); my $which_import = $q-param('action'); if ($which_import eq 'Import STKvol') { print foo\n; } __END__ 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