Re: perlbrew and modules
> On Dec 7, 2017, at 3:39 PM, Andy Bachwrote: > > meaning, you added: > use lib q{/home/user/.cpanm/}; Well, no. That one didn't work. I had to be specific about where CGI::Carp was installed to get it to work: use lib '/home/user/.cpanm/work/1512448551.26554/CGI-4.38/lib'; > Right, so that's your 500 error. But you added the same line in the original > (before the use Carp line?) and it *didn't* fix the problem? Can you sym > link the .cpanm dir under one of those @INC dirs. Hm, there's also an > PERL5LIB env var you can set to add libraries (maybe in the webserver config). I've read about those, but I'd rather not jerry rig this install just to get it to work. I've been using perlbrew on my Mac (with 5 different perls) for years without incident, so that's why I'm at a loss as to what's happening on this VPS. Maybe I should just cut my losses, delete everything, and start over. I just hate doing that after spending so much time on something. It's like admitting defeat and giving up. ;) I just thought to compare the install on my Mac with the one on the VPS and the binaries of perlbrew are exactly the same, but the binaries for patchperl and cpanm are wildly different from each other. Are these customized during installation for the platform that running? If not, would it be safe to copy my known good copies over to the server (Mac vs Linux)? Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: perlbrew and modules
> On Dec 7, 2017, at 3:09 PM, Andy Bachwrote: > > Can you not look a the web server's error_log? A 500 error would put the > perl error msg in there. Have you tried just "use" a different module? Those errors aren't appearing in the errors log in cPanel. I couldn't find another error log in WHM. > Hmm, can you try... I ran your script and, when I manually include the .cpanm directory, it returns: /home/user/cgi-bin/test.pl syntax OK otherwise, it returns: Can't locate CGI/Carp.pm in @INC (you may need to install the CGI::Carp module) (@INC contains: /home/user/perl5/perlbrew/perls/perl-5.26.1/lib/site_perl/5.26.1/x86_64-linux /home/user/perl5/perlbrew/perls/perl-5.26.1/lib/site_perl/5.26.1 /home/user/perl5/perlbrew/perls/perl-5.26.1/lib/5.26.1/x86_64-linux /home/user/perl5/perlbrew/perls/perl-5.26.1/lib/5.26.1) at /home/user/cgi-bin/test.pl line 9. BEGIN failed--compilation aborted at /home/user/cgi-bin/test.pl line 9. Here's more info. I ran the following command, which produced an error: > perlbrew exec perl -e 'print $]' Use of uninitialized value in list assignment at /home/user/perl5/perlbrew/bin/perlbrew line 2220. perl-5.26.1 == 5.026001 Looks like this has been reported for a few years without a solution: https://rt.cpan.org/Public/Bug/Display.html?id=111978 Could this be part of the problem? I'm running perlbrew 0.80. Frank P.S. Re-installing cpanm didn't solve the problem. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: perlbrew and modules
> On Dec 7, 2017, at 1:40 PM, Shlomi Fishwrote: > > you should make sure that the modules you wish to use are in one of the > dirs in @INC. cpanm should install to the global directories. Another question. How can I check to make sure cpanm was installed properly under perlbrew? Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: perlbrew and modules
> On Dec 7, 2017, at 1:40 PM, Shlomi Fishwrote: > > you should make sure that the modules you wish to use are in one of the > dirs in @INC. cpanm should install to the global directories. That's what I thought. Shouldn't "cpanm install Module::Name" do that on it's own? There's only one perl install and one alias, and the alias is selected. Running "perl -v" returns version 5.26.1 so how can I get perlbrew set to install in the current installation? Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: perlbrew and modules
> On Dec 7, 2017, at 12:04 PM, Shlomi Fishwrote: > > What does: > > say "@INC"; > > say if you add it to the script? I get: /home/user/perl5/perlbrew/perls/perl-5.26.1/lib/site_perl/5.26.1/x86_64-linux /home/user/perl5/perlbrew/perls/perl-5.26.1/lib/site_perl/5.26.1 /home/user/perl5/perlbrew/perls/perl-5.26.1/lib/5.26.1/x86_64-linux /home/user/perl5/perlbrew/perls/perl-5.26.1/lib/5.26.1 I found a .cpanm directory in /home/user where all the modules are being installed. Could that have anything to do with it? I tried adding that directory with "use lib" but I still get the 500 error. Thanks, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
perlbrew and modules
I've run into another strange problem that I don't understand. Running the script below produces the output "Perl v5.26.1". However, if I add the line: use CGI::Carp qw(fatalsToBrowser); it produces a 500 error. On the shared server, this worked as it should, with 'fatalsToBrowser' showing any errors. But the VPS is just backwards - adding it crashes the script! This actually happens with any module and, yes, they are installed: > cpanm install CGI::Carp install is up to date. (0.01) CGI::Carp is up to date. (4.38) I have been fighting with this VPS setup for almost 2 weeks now just to get a functioning modern Perl environment and I'm about at my wits end. It shouldn't be this hard. I'd appreciate any help. Thanks, Frank #!/home/user/perl5/perlbrew/perls/latest/bin/perl use v5.26; use warnings; use diagnostics; print "Content-type: text/html\n\n"; say 'Perl '. $^V; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
perlbrew and cron
After moving to a VPS, I'm finally able to use perlbrew to use the latest perl, but it's not working the same as it does on my Mac. In terminal, I can call a perl script with either the full path to perl or with an alias I've set up in .bashrc. So far, so good. However, to run a script with cron, I can't seem to get it to run with the perlbrew version. I've even tried it with just the path to the script, as mentioned by ikegami here: https://stackoverflow.com/questions/47457834/running-a-perl-script-from-crontab-when-you-use-perlbrew Unfortunately, I don't have anymore to go on than this as, literally, nothing happens - the script doesn't get run and I don't get an error email from cron, so I don't know where to look. Thanks, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Problem with perlbrew and LiteSpeed
> On Dec 5, 2017, at 10:23 AM, Chas. Owenswrote: > > Test one: does the file actually exist. Thanks for the tests. It turns out there was a typo in the shebang line. It was a tough one to diagnose as the error said the file wasn't there. Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Problem with perlbrew and LiteSpeed
I'm hoping someone has seen this before and can point me in the right direction. I'm moving my site to a VPS to be able to use a more modern version of Perl, but I've run into a problem. I installed perlbrew along with Perl 5.26.1. That went smoothly. However, when I try to run even a small test script in a browser, the server returns this: lscgid: execve():/home/user/www/cgi-bin/test.pl: No such file or directory The perlbrew installation on my Mac works perfectly, but on this *nix server, it doesn't**. The VPS is using LiteSpeed, but I've been told it's a drop-in replacement for Apache, so everything *should* work the same as before. Do I need to do something more than just putting the perlbrew perl path in the shebang line? Has anyone seen anything like this before? I'm working with my web host on this, but so far they don't seem to know what's going on, so I thought I'd ask here just in case. Thanks, Frank ** Running the script in terminal works properly, just not in the browser. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Getting the results of a remote script
> On Nov 9, 2017, at 2:06 PM, David Preciouswrote: > > you'll get whatever the script output to STDOUT. Thanks a million, Dave! STDOUT was what I was missing. I've never used that before, so this was news to me. The remote script now returns a string that I can manipulate and use in the local script. Thanks again, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Getting the results of a remote script
> On Nov 8, 2017, at 5:16 PM, thelip siawrote: > > you can use backtick to store the output. > $list = `ssh usern...@domain.com '/usr/bin/perl /path/to/dir-list.pl'`; Thanks, Heince. I had mistakenly thought those were synonymous with each other. And, of course, this morning, doing a new search produced the backtick solution. However, every example I found was for a unix command, not a perl script. Using the backticks returns nothing, so perhaps my remote script may not be set up properly to "export" it's result? Sorry - I've never dealt with WAN solutions like this before so I don't even know how to put it. 5 hours later... I've since decided to offload a portion of my local script to the remote script to avoid the back-and-forth. However, I'm still curious if this can even be done. As I mentioned, my remote script produces an array of directory names that I need to use in my local script. The array is populated correctly, but I can't see it in my local script. Can the result of a remote script be used in a local script by calling it via SSH or some other means? If so, how do you get the result back? This is not a CGI script - that was only an example path I used. Thanks, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Getting the results of a remote script
I have a script on a remote server that creates a list of all directories on the server that end in a dash. I need that list on my laptop. Is it possible to get the result into a variable in my local script by triggering the remote script via ssh? I've tried this: $list = system('ssh usern...@domain.com '/usr/bin/perl /cgi-bin/dir-list.pl'"); but it just returns '0'. The system call is working fine - I just can't get the result returned in $list. Searching hasn't returned an answer. Is there another way to get what I'm after? Thanks, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Astro::Sunrise vs DateTime::Event::Sunrise
Does anyone here use either the Astro::Sunrise or the DateTime::Event::Sunrise module? I'm curious as to what the major differences are. From what I can see, Astro::Sunrise uses DateTime behind the scenes (if at all), so you don't need to enter that info yourself, making your script a little cleaner. However, DateTime::Event::Sunrise seems to offer more functions, e.g.: # Is it day or night? my $day_set = DateTime::SpanSet->from_sets( start_set => $sunrise, end_set => $sunset ); print $day_set->contains( $dt ) ? 'day' : 'night'; which seems handy, but that can be mimicked. The accuracy of both is only one minute apart, and they're both maintained by the same person, so I'm not really sure if there is a noticeable difference between the two. These are the only sunrise/sunset modules I found on CPAN. Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: "Information station" using Perl and Raspberry Pi
There was some good information in this thread. Thank you! > On Jul 26, 2017, at 2:38 AM, David Preciouswrote: > > FWIW, it might be sensible to not fully discount the HTML option - > seting an RPi up to start a browser on boot in full-screen "kiosk mode" > is easy, and you could have it load either a page served by the RPi > itself, or hosted elsewhere, whichever you prefer. Thanks for this, Dave. I forgot about kiosk mode, so you were right - HTML was the easiest. Just to get this up and running for my mother, I settled on JavaScript embedded in HTML to change the messages for her. It's pretty clunky at this point, but at least it's usable - and I can make changes remotely. That's nice! Now I can take my time and work on this at my convenience to make it a lot more powerful. Thanks again, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: "Information station" using Perl and Raspberry Pi
> On Jul 25, 2017, at 2:08 PM, Andrew Solomonwrote: > > In case you want to see what's already out there, the search engine term for > you is "assistive technology". Thanks, Andrew! I appreciate it. However, I think that's more than what I need. I'm really only looking to display formatted text on a TV screen. --- I finally found a project that looks similar to what I want to do: https://www.cnet.com/how-to/turn-an-old-monitor-into-a-wall-display-with-a-raspberry-pi/ It's a lot more elaborate than what I need and it uses a web service to display the information. I'd prefer to use Perl, if at all possible, and use my own server for the files. Frank
"Information station" using Perl and Raspberry Pi
I'm looking to get some ideas on how to make an "information station" for my mother who has the beginning stages of dementia. I want to display information on her TV, like when her next meal is, time of day, date, etc., which of course would change daily and throughout the day. I was thinking that I'd get a Raspberry Pi and program that to retrieve text files from a server depending on the time of day. I don't know how well the RPi handles Perl - it seems to be geared for Python. I would need to be able to display text in any size and style. My first though was to use HTML, but I don't want to use a browser to display the text onscreen. Would this require a GUI, such as Tk? Has anyone done anything like this before? Am I on the right track with my ideas or is there a better way of doing this? Thanks, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Using __DATA__ with XML::LibXML
I think I'm losing it. I'm trying to do something simple here but I can't get it to work. I'm using XML::LibXML to verify XML sitemaps and it's working fine with an external XSD file. However, I'd like to add the schema to a __DATA__ section so that I only need a single file. However, no matter what I do, I get error messages***. I've tried the following: my @data = ; my $data = join ('', @data); my $schema = XML::LibXML::Schema->new(string => $data); - my $schema = XML::LibXML::Schema->new(string => *DATA); - my $schema = XML::LibXML::Schema->new(string => \*DATA); but the only thing that works is: my $schema_file = '/home/user/cron/sitemaps/xsd-schema.xsd'; my $schema = XML::LibXML::Schema->new(location => $schema_file); Why can't I get the DATA solution to work? Thanks, Frank *** Some of the error messages I've seen: Schemas parser error : Failed to parse the XML resource 'in_memory_buffer'. Entity: line 1: parser error : Start tag expected, '<' not found --- The full script is as follows: package XML_Check; use XML::LibXML; use FindBin qw($Bin); use lib "$Bin/../../perl/Modules"; require EmailSender; # ## Load YAML Config File # use YAML qw(LoadFile); my $config = LoadFile('/home/user/conf/config.yaml'); my $to_address = $config->{'email'}{'report_to'}; my $from_address = $config->{'email'}{'report_from'}; ## sub verify_xml { my $document = shift; my $schema_file = '/home/user/cron/sitemaps/xsd-schema.xsd'; my $schema = XML::LibXML::Schema->new(location => $schema_file); my $parser = XML::LibXML->new; my $doc= $parser->parse_file($document); eval { $schema->validate($doc) }; if ($@) { my $subject = 'XML Sitemap Error'; my $message = "There was an error in the $document sitemap."; EmailSender::send_mail($subject, $message, $to_address, $from_address, 'text/plain'); } return $@; } 1; __DATA__ http://www.w3.org/2001/XMLSchema; xmlns="http://www.sitemaps.org/schemas/sitemap/0.9; targetNamespace="http://www.sitemaps.org/schemas/sitemap/0.9; elementFormDefault="qualified"> XML Schema for Sitemap files. Last Modifed 2008-03-26 Container for a set of up to 50,000 document elements. This is the root element of the XML file. Container for the data needed to describe a document to crawl. REQUIRED: The location URI of a document. The URI must conform to RFC 2396 (http://www.ietf.org/rfc/rfc2396.txt). OPTIONAL: The date the document was last modified. The date must conform to the W3C DATETIME format (http://www.w3.org/TR/NOTE-datetime). Example: 2005-05-10 Lastmod may also contain a timestamp. Example: 2005-05-10T17:33:30+08:00 OPTIONAL: Indicates how frequently the content at a particular URL is likely to change. The value "always" should be used to describe documents that change each time they are accessed. The value "never" should be used to describe archived URLs. Please note that web crawlers may not necessarily crawl pages marked "always" more often. Consider this element as a friendly suggestion and not a command. OPTIONAL: The priority of a particular URL relative to other pages on the same site. The value for this element is a number between 0.0 and 1.0 where 0.0 identifies the lowest priority page(s). The default priority of a page is 0.5. Priority is used to select between pages on your site. Setting a priority of 1.0 for all URLs will not help you, as the relative priority of pages on your site is what will be considered. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Time::HiRes output
> On May 24, 2017, at 7:17 PM, Chas. Owenswrote: > > Take a look at Devel::NYTProf... Thanks, Chas. I had made a mental note a while back to look into Devel::NYTProf, but it had slipped my mind, so your response was perfectly timed. Just within the first hour of using it, I found a few subs that were being called when they shouldn’t have been, so I blocked that from happening. Doing that alone has shaved off 132 ms, 6,333 statements, 956 subroutine calls, and 11 string evals - and I’m just getting started! However, my little “profiler” that I wrote is coming in handy, as well. It’s very simple - it only lists the subs in the order that they are called, the time they take, and a few key variables to see how/why they are being called. This shows me the sequence of events depending on which links were clicked, which is giving me a deeper insight into how the shopping cart actually works. I'm sure NYTProf does that as well, but I'm still learning it. This is going to make the script that much more efficient. Thanks again, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Time::HiRes output
I’m timing sub routines to get an idea of where my scripts spend the most of their time. This is an example of what I’m doing: use Time::HiRes qw( clock ); my $clock0 = clock(); ... # Do something. my $clock1 = clock(); my $clockd = $clock1 - $clock0; I’m getting values like $clock1 = 0.030259 and $clock0 = 0.030212. However, instead of $clockd being 0.47, it’s returning 4.700019e-05. I take it that’s exponential notation (?) but it’s actually more difficult to read than the regular number. Is there a way to get it to print out differently? Thanks, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
HTTP::Recorder problem [solutions?/alternatives?]
After automating test orders in my script with WWW::Mechanize, I ran across HTTP::Recorder and thought I’d give that a try: http://www.perl.com/pub/2004/06/04/recorder.html However, I feel like I’ve missed something in the setup. I’m on OS X 11.6.4 and I’ve chosen “Auto Proxy Discovery”* in the Proxies section of the Network control panel, and then I run the perl script on the command line. Is that all there is to it? When I surf, nothing gets written to the log file I have set up, and then after a few minutes, the process in Terminal quits with this message: (3724) PROCESS: Too many child process, serving the connection Does anyone have any experience setting up HTTP::Recorder? Or is there a different solution? I just noticed that HTTP::Recorder is deprecated. Thanks, Frank * I’ve also read to choose “Automatic Proxy Configuration” in the control panel, but I don’t know what to enter in the URL (.pac) box. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Getting a specific page using WWW::Mechanize [SOLVED]
I found my error. I ended up using $mech->save_content(‘result.html’) at the end of my script and, lo and behold, it produced the confirm.htm page with an error. I had forgotten to add the cardholder’s name field to the final form submission, so of course, SurfShop was returning the same page and asking for it to be filled in. Talk about embarrassing. :\ Oh, well, everything is working fine now and I have a super little script to place test orders automatically. It’s turned out to be a great tool for solving problems. Before this, I was manually placing test orders, filling in every field by hand, which gets old real fast when you have to do it repeatedly. If anyone is looking to automate tasks like this for testing or whatever else, I whole heartedly recommend WWW::Mechanize. It’s a real time saver. Thanks again to Chas for the reply. Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Getting a specific page using WWW::Mechanize
> On Apr 25, 2017, at 10:09 AM, Chas. Owenswrote: > > Are you using JavaScript to redirect the user to the sorry page? Nope. All navigation is handled by perl. Thanks for the link, though. Frank
Re: Getting a specific page using WWW::Mechanize
Here’s more information on this situation. SurfShop uses two main HTML templates, main.htm and secure.htm. Then there are sub-templates that get loaded as the content of those two main templates. During checkout, secure.htm is used. If the order is successful, receipt.htm is used as the sub-template, if not, then sorry.htm is shown with the error message. This, of course, works as expected when placing an order by hand. When placing a successful order with WWW::Mechanize, receipt.htm is shown correctly in $mech->content(). However, if the order was declined, that’s when Mech returns the same page it was on when the ‘processTransaction’ button was clicked, which is confirm.htm. Up until this point, Mech performs just like when I manually place an order, so what could be causing it to get mixed up at the end? I don’t think I'm doing anything special, but you never know. Here’s a snippet of the code where the process fails: $mech->submit_form( form_name => 'ccForm', fields=> { Ecom_Payment_Card_Type => 'VISA', Ecom_Payment_Card_Number=> ‘', Ecom_Payment_Card_Verification => '123', Ecom_Payment_Card_ExpDate_Month => '05', Ecom_Payment_Card_ExpDate_Year => '2024', }, button=> 'processTransaction', ); As you can see, it’s pretty standard stuff. Is there another method I can use besides $mech->content() to see what’s being returned? The more tests I can do on this, the more it will help me find where I went wrong. Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Getting a specific page using WWW::Mechanize
I’ve written a script using WWW::Mechanize to place test orders in SurfShop. I wish I had know it could do this before. :\ For some reason, I was under the impression that it was only good for scraping. The script works great, but I need to find a way to get the contents of the receipt page in the cart to test if a credit card order was accepted or denied. Using $mech->content at the end of the script gives me the penultimate page - not the last one. How can I get the contents of the final page of the checkout process? Thanks, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Perl reserved words
> On Apr 23, 2017, at 11:51 AM, Shlomi Fishwrote: > > It is not a reserved word of Perl. No idea about MySQL. Must be something in the code then. I’ll try it again and see if it still happens. If so, I’ll make sure to mention the error instead of just saying “it doesn’t work”. ;) That’s what I get for letting too much time pass before asking a question. Thanks, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Perl reserved words
Is ‘vendor’ a reserved word of some type in either Perl, MySQL, or DBM? I tried to add a ‘vendor’ field to SurfShop but it didn’t work. I don’t recall exactly what happened now (sorry), but I had to settle on another word to get it to work. Any ideas on what it could have been? Thanks, Frank It’s not listed here: http://learn.perl.org/docs/keywords.html -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: how to repeatedly execute a command on a remote machine via a shh login from within a perl program capturing the output?
> On Apr 18, 2017, at 6:19 PM, leewrote: > > The purpose is to get room temperature readings Hey Lee, I don’t have a solution for you, but I have an idea that might help. Have you tried the Misterhouse mailing list? It’s a Perl script that handles sensors like that so someone there may have done what you’re trying to do. https://sourceforge.net/p/misterhouse/mailman/misterhouse-users/ HTH, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Scalar References - oxymoron?
Thanks for all the replies. It’s been a very interesting thread. Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: WWW::Mechanize requires wget
> On Apr 4, 2017, at 12:01 PM, John SJ Andersonwrote: > > ¯\_(ツ)_/¯ It’s been awhile since ascii art made me laugh. That’s a good one! :) -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: WWW::Mechanize requires wget
> On Apr 4, 2017, at 10:59 AM, John SJ Andersonwrote: > > I’m not sure what was behind the resolution of your problem, but I can assure > you I’m typing this on a Macintosh without wget installed, and WWW::Mechanize > works just fine. Weird. Which OS are you running? I’m on 10.11.6. Perhaps something else got installed along with wget, but whatever it was, that install solved my problem. Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
WWW::Mechanize requires wget
This is a heads up for anyone wanting to use WWW::Mechanize on OS X. I’ve been fighting with WWW::Mechanize all morning, trying to get it to work with no success. There were no error messages telling me what was wrong. I checked my firewall to see if anything was being blocked, but it wasn’t. I finally ran across a post where someone was asked if they were able to access the target web site using wget, so I decided to try that myself. Terminal told me that wget wasn’t found. So… off to homebrew to install wget, and lo and behold, Mech now works! I went back to see if Mech had wget as a dependency, but nothing was mentioned on CPAN. So just in case someone else was having the same trouble, I thought I’d post this. Not sure why wget wasn’t installed with Xcode Developer Tools. Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Scalar References - oxymoron?
Reading http://perldoc.perl.org/perlreftut.html I see it’s possible to create a scalar reference. What situation would require someone to create a reference to a scalar? I thought refs were only useful for passing complex data structures. Is it just because Perl lets you, or is there a reason I’m not aware of? It seems like it would just be redundant. Thanks, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Perl Critic and subroutine signatures
> On Mar 29, 2017, at 3:47 PM, Kevin Phairwrote: > > Something like > > [-Subroutines::ProhibitSubroutinePrototypes] Thanks. I ran across that myself on perlmaven.com right before I went to lunch. I was hoping to find a page on CPAN or even the Perl Critic web site that would list all the exceptions, but unless I just don’t know where to look, it’s simply not available. Now watch - someone will find that list and prove me wrong. ;) —— O.K., if you install P::C on your own machine, you can run: perlcritic -list to get a list of them. Also, some good news. It looks like P::C is now under new management, so we’ll probably be seeing an update before too much longer. https://github.com/Perl-Critic/Perl-Critic/issues/713 Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Perl Critic and subroutine signatures
> On Mar 29, 2017, at 10:19 AM, Uri Guttmanwrote: > > i would ask why are you using prototypes? I’m not using prototypes. I’m using subroutine signatures. Perl Critic only thinks they are prototypes.
Perl Critic and subroutine signatures
Does anyone know how to keep Perl Critic from complaining about subroutine signatures? I’m getting a massive amount of these types of warnings: Subroutine prototypes used at line... It also thinks that postfix dereferencing is a magic variable. Is this because PC hasn’t been updated for a couple years, or is there an add-on that takes care of these situations? Thanks, Frank
Re: Equivalents statements using if and unless
> On Mar 28, 2017, at 1:58 PM, Uri Guttmanwrote: > > the only difference i see is using defined in the 2nd line. Thanks, Uri. Yeah, I got overly aggressive there. > also i would test $field ne 'categories' first as if that is true why even > test $out->{$field}? it is a slight optimization but may also clarify the > logic. And thanks for this, too. That makes sense. I’m looking at all lines of logic now to see if they can be optimized. Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Equivalents statements using if and unless
I could use another set of eyes on this. Could someone please double check these two sets of conditions and let me know if the first is equivalent to the second? I believe they are, but I don’t want to take any chances. # Both of these should be equivalent. $out->{$field} =~ s/``/\r/g unless (not $out->{$field} or $field eq 'categories'); $out->{$field} =~ s/``/\r/g if (defined $out->{$field} && $field ne 'categories'); # Both of these should be equivalent. … unless (not defined ($main::global->{form}->{$field}) || $field =~ m/\b(hide|date|lastmod)\b/); … if (defined $main::global->{form}->{$field} && $field !~ m/\b(hide|date|lastmod)\b/n); The first of each set is a double negative, so I’m wanting to rewrite them to be easier to read. Thanks, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Changing date format using carpout
> On Mar 26, 2017, at 1:15 PM, Shawn H Coreywrote: > > it would mean replacing the subroutine after the module was loaded. Thanks, Shawn, but I can’t get that to work. Reading perldoc Core gives me the impression that I’d need to call the new sub, not the module. If that’s true, I don’t see how it would work in this scenario. Here’s what I tried: BEGIN { use CGI::Carp qw(carpout fatalsToBrowser ); # noTimestamp { no warnings; use Time::Piece; local *CGI::Carp::stamp = sub { my $frame = 0; my ($id, $pack, $file, $dev, $dirs); if (defined($CGI::Carp::PROGNAME)) { $id = $CGI::Carp::PROGNAME; } else { do { $id = $file; ($pack, $file) = caller($frame++); } until !$file; } if (! $CGI::Carp::FULL_PATH) { ($dev, $dirs, $id) = File::Spec->splitpath($id); } return "$id: " if $CGI::Carp::NO_TIMESTAMP; my $time = scalar(localtime); my $dt = Time::Piece->strptime($time, '%a %b %d %H:%M:%S %Y'); my $datetime = $dt->strftime('%Y-%m-%d %H:%M'); return "[$datetime] $id: "; } } open (my $log, '>>', ‘/path/to/error.log'); carpout($log); close ($log); } -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Changing date format using carpout
> On Mar 26, 2017, at 1:20 AM, X Dungenesswrote: > > but you could post-process the logfile in an END {} block I wouldn't have thought of that. Thanks! This now gives me a cleaner log to scan — streamlining the timestamp and adding a blank line between entries. I also learned about $^I / $INPLACE_EDIT. Very nice! http://perldoc.perl.org/perlvar.html#SPECIAL-VARIABLES END { use Time::Piece; $^I = ''; @ARGV = '/path/to/error.log'; while (<>) { next if (m/^\s*$/); if (m/\[(.+)\](.+)/) { my ($timestamp, $message) = ($1, $2); ## [Wed Mar 22 12:43:20 2017] -- Original timestamp format. my $dt = Time::Piece->strptime($timestamp, '%a %b %d %H:%M:%S %Y'); my $datetime = $dt->strftime('%Y-%m-%d %H:%M'); say "[$datetime] $message\n"; } else { say; } } } -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Changing date format using carpout
> On Mar 25, 2017, at 8:58 PM, Jim Gibsonwrote: > > You could also try overriding the supplied function of the imported module > with your own version (not sure exactly how that is done). Hmm… me neither, but it’s a good idea. I’ll contact the maintainer of CGI::Carp to see if that could be added as a feature. > I usually write my own log files using normal file output functions. However, > that is harder, but not impossible, when you are writing CGI programs. I do that as well, but that BEGIN statement catches things I wouldn’t normally look for myself. Thanks, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Changing date format using carpout
I’ll sometimes use the following code at the beginning of a script to log errors while testing: BEGIN { use CGI::Carp qw(carpout); open(_STDERR,'>'); close STDERR; open (my $log, '>>', 'logs/error.log') or warn("Couldn't open error.log: $! \n"); carpout($log); close ($log); } However, I would like to change the date format. I’m not wild about seeing the the full timestamp on every line: [Sat Mar 25 08:05:58 2017] Is there a way I can format that to my liking? I see there's a ‘noTimestamp’ option to stop it from printing altogether, but I don’t see a way to change the output. Side question: is there a better way to accomplish what I’m doing above? I’m happy with what I already have (except for the date) but only because I don’t know anything else. I’d like to hear how others do this. Thanks, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Problem using Email::Mailer on laptop
> I've taken the liberty of raising this on Github for you, since I'd > already done the digging and found the code in question, so it was just > as easy to more or less copy & paste this reply into a ticket: > https://github.com/gryphonshafer/Email-Mailer/issues/1 Thank you for that, Dave. He fixed it in record time! The latest version works as it should. I had also installed it on my server where it worked fine, but it’s nice to be able to use it locally, too. Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Problem using Email::Mailer on laptop
> On Mar 20, 2017, at 12:04 PM, SSC_perl <p...@surfshopcart.com> wrote: > > Is anyone familiar with Gryphon Shafer’s work? After hitting the send button, my last question didn’t sit right with me. It kind of sounds like I was questioning his work, which I wasn’t. I did some digging and found that Gryphon has been a pretty prolific contributor to CPAN since 2015 - 30 modules in all. I like his pod writeup on Email::Mailer - it’s very comprehensive, straight forward, and easy to understand. And after browsing the source code, I like his coding style, too. He also lives in my neck of the woods, and he’s a pilot!!! How cool is that??? :) I wonder if he belongs to SPUG? ;) So my question goes back to the original - why wouldn’t this work from a local install? Could I be missing some component without knowing it? Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Problem using Email::Mailer on laptop
> On Mar 20, 2017, at 11:42 AM, Billwrote: > > Not available to me via AS PPM, suggest you try MIME::Lite instead. MIME::Lite is not recommended by its current maintainer. I don’t use ActivePerl, so I don’t know why PPM wouldn’t include it. Perhaps it’s too new? Is anyone familiar with Gryphon Shafer’s work? https://metacpan.org/pod/Email::Mailer Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Problem using Email::Mailer on laptop
Is anyone here successfully using Email::Mailer? I installed it using cpanm a couple of days ago on my Mac and I can’t get it to work. It just prints the following output and nothing more: postdrop: warning: mail_queue_enter: create file maildrop/352468.4276: No such file or directory It appears to be trying to send it directly from my laptop, but I have the SMTP transport variable set up correctly (which works just fine using Email::Stuffer, BTW). I really like what I’ve read about this new module - I just need to get past this hurdle. Everything installed correctly and there are no error messages, so I’m at a loss as to what to try next. Thanks, Frank #!/usr/bin/env perl use 5.024; use warnings; use Email::Mailer; use Email::Sender::Transport::SMTP; my $to = ‘xxx'; my $from = ‘xxx'; my $password = ‘xxx'; my $subject = 'Hello'; my $text = "This email was sent via Email::Mailer.\n\n"; my $transport = Email::Sender::Transport::SMTP->new( host => ‘my.mail.server.com', port => 587, sasl_username => $from, sasl_password => $password, debug => 1, ) or die "Error creating multipart container: $!\n"; Email::Mailer->send( to=> $to, from => $from, subject => $subject, text => $text, transport => $transport, ) or die "Couldn't send email."; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Installing Net::SFTP
> On Mar 15, 2017, at 6:44 AM, Shawn H Coreywrote: > > I don't know about Crypt::SSLeay but Net::SSLeay needs two > libraries: `zlib1g` and `libssl` > > I don't run RHEL but IIRC, the command is: > >yum install zlib1g libssl I don’t know if this will help the OP, but I too tried unsuccessfully to install Net::SSLeay on OS X. However, the log said I was missing ‘openssl'. So after I installed that using homebrew, the Net::SSLeay installation succeeded. At first I tried to install both zlib1g and libssl, but neither could be found by homebrew. This could just be a platform difference, but I thought I’d mention it just in case. Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Logging SQL Queries
I’m using DBI::Log to capture SQL queries but the log file gets huge exponentially. Is there a way to filter what gets logged? If I could eliminate the SELECT queries, that would help a lot. I’ve also install Log4perl and DBIx::Log4perl. This appears to be a very powerful solution, but again, I’m not seeing how to filter what gets logged. I’ve read this page: https://metacpan.org/pod/release/MJEVANS/DBIx-Log4perl-0.26/lib/DBIx/Log4perl.pm but it’s pretty terse so maybe I’m just not seeing it. Adding {dbix_l4p_logmask => DBIX_L4P_LOG_SQL|DBIX_L4P_LOG_DELAYBINDPARAM} helps some, but I still need more filtering. What can I use to capture only certain SQL statements? Thanks, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Strange HASH(0x2ced735) values
> On Feb 21, 2017, at 2:34 PM, Samwrote: > > One can also turn on the DBI trace log as well. Thanks, Sam! That helped a lot. Now I know which subs are involved in creating the SQL so I’m much closer to tracking this down. This is why they say that two heads are better than one. It didn’t even occur to me to turn that on. :\ Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Strange HASH(0x2ced735) values
> On Feb 21, 2017, at 8:34 AM, Uri Guttmanwrote: > > you can't trace it from the value. but you can write code where that value is > stuffed into the db and look for a reference vs 1 or a blank. then you can > dump the call stack (with caller()) or do other debugging. something is > putting a hash reference in there that shouldn't be doing it. Thanks Uri, but that’s the problem - so far I haven’t been able to tell where it’s being generated. That’s why I was hoping to decode that value. Looks like I’ll have to continue searching. :\ Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Strange HASH(0x2ced735) values
In a MySQL db I have a `customers` table with a field called `hide`. There are some strange values that I’d like to know where they’re coming from. In most records `hide` is blank, some others have the value ‘1’, but a handful have values like HASH(0x2ced735). I take it from what little information I could find, that those are %hash values stored in the db. Unfortunately, I can’t find where they are generated from in the script, so I was wondering if there was a way I could decipher what’s in those HASH() vales? Maybe that will help me find the source and fix it. I know this is not a lot to go on, but any pointers would be a big help. Thanks, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Declaring and conditionally assigning to a variable on the same line
> On Feb 15, 2017, at 11:08 AM, Uri Guttmanwrote: > > try the even simpler and cleaner use of || > my $show_ref = delete $log{'show_ref'} || 'no’; Uri, After I had sent in my question, I began wondering if exists was even necessary, so I experimented with the || solution and it worked. However I didn’t know that it was acceptable until I got your reply. I’m happier with this solution than with what I wanted to use anyway, so you just made my day. It’s the simple things in life… you know. :) Thanks, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Declaring and conditionally assigning to a variable on the same line
I’ve read where writing a one-liner like this is frowned upon: my $show_ref = delete $log{'show_ref'} if (exists $log{'show_ref'}); but what about this? my $show_ref = exists $log{'show_ref'} ? delete $log{'show_ref'} : 'no’; They both seem to work without a problem in my tests. I prefer the 2nd one anyway as you can assign a default value if that hash key doesn’t exist. Is this proper Perl or is it a problem waiting to happen? Thanks, Frank #!/usr/bin/perl use 5.022; use warnings; my %log = ( filename => 'trap-generic.log', show_uri => 'yes', # show_ref => 'yes', to_db => 'no', error_type => '', ); my $show_ref = exists $log{'show_ref'} ? delete $log{'show_ref'} : 'no'; my $log_line; foreach my $key (sort keys %log) { my $value = $log{$key}; $log_line .= "\n$key : " . $value; } say $log_line; say '-'; say "The deleted show_ref = $show_ref"; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Extra text printed by Data::Dumper
> On Feb 3, 2017, at 7:17 PM, Ken Slaterwrote: > > HTH Yes, it does. Thanks to both you and Chas for the help. Frank
Extra text printed by Data::Dumper
I have the following sub that creates a log file using Data::Dumper. It also lists the name of each of the variables that it’s fed. It works great except for one problem - every line is appended with “ = undef;” (minus the quotes). I’ve tried stripping it out of $var_value with regex but that doesn’t work, so it appears that Data::Dumper is adding that text during the print command. Does anyone know how I can eliminate that extra text from being printed? My searches have come up empty. Thanks, Frank datadump('log_name', '>>', "database $database", "matches $matches", "image $image", ); sub datadump { my $filename = shift; my $write= shift; my @var_info = @_; no strict; open(my $log, $write, "temp_logs/TESTS-$filename.log"); use Data::Dumper; foreach my $var (@var_info) { my @vars = split (/,/ => $var); my $var_name = '$'.$vars[0]; my $var_value = $vars[1]; print {$log} Data::Dumper->Dump( [$var_value], [$var_name] ); $count++; } close($log); use strict; } -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: This is one of the things ...
On May 12, 2016, at 7:10 PM, Shawn H Corey wrote: >> my $holders = join ',', ('?') x @cgi_params; > PBP recommends that you put short strings that are all punctuation in > q{}, so they will be easier to read. > >my $holders = join q{,}, (q{?}) x @cgi_params; I realize stuff like this is subjective, and coding styles can be very personal, but this looks cleaner to me: my $holders = join ',' => ('?') x @cgi_params; Since I found the fat comma, I use it all the time now - especially when two commas are so close together. I'm kind of surprised PBP would say that q{} is easier to read in this situation. IMHO, it seems to just adds noise. Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Regex to match "bad" characters in a parameter
On Jan 25, 2016, at 4:59 PM, Shawn H Corey wrote: > > Use the negative match operator !~ > > if( $QUERY_STRING !~ m{ itemid = [-0-9A-Za-z_]+? (?: \& | \z ) }msx ){ >print "bad: $QUERY_STRING\n"; > } Thanks for that, Shawn. It works perfectly except for one criteria that I inadvertently forgot to include. It's possible that the string will _not_ contain the itemid parameter at all. When that's missing, the regex matches and it shouldn't. I guess that's why I was trying to stay with the positive match operator. I tried inverting your regex: if ( $QUERY_STRING =~ m/ itemid= .*? [^-0-9A-Za-z_]+? .*? (?: \& | \z ) /sx ) { say "bad: $QUERY_STRING"; } but that doesn't work either. It catches even good item numbers. In the meantime, I got it to work by grabbing the itemid and working with that separately: my $item_id = $1 if ($QUERY_STRING =~ m/ itemid=([^&]*) /x); if ( $item_id =~ m/ [^a-zA-Z0-9_-] /x ) { ... however, I'd like to do that with a single line, if possible, so I don't have to create a new variable just for that. Thanks, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Regex to match "bad" characters in a parameter
On Jan 26, 2016, at 11:22 AM, Chris Charley wrote: > > You could do that in 1 line - See the following small program. Thanks, Chris. That'll do the trick. And the grep alternative is interesting, too. I hadn't thought of that. Regards, Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Regex to match "bad" characters in a parameter
I'm trying to find a way to trap bad item numbers. I want to parse the parameter "itemid=" and then everything up to either an "&" or end-of-string. A good item number will contain only ASCII letters, numbers, dashes, and underscores and may terminate with a "&" or it may not (see samples below). The following string should test negative in the regex below: my $QUERY_STRING = 'itemid=AT18C_AT18C=1'; but a string containing "itemid=AT18/C" should test positive, since it has a slash. I can catch a single bad character and get it to work, e.g. if ( $QUERY_STRING =~ m| itemid= .*? [/]+? .*? &? |x ) { but I'd like to do something like this instead to catch others: if ( $QUERY_STRING =~ m| itemid= (?: .*? [^a-zA-Z0_-]+ .*? ) &? |x ) { ... Unfortunately, I can't get it to work. I've read perlretut, but can't see the answer. What am I doing wrong? Thanks, Frank Here are a couple of test strings: 'itemid=AT18C_AT18C=1=main.htm=1=1=detail.htm=asc' 'c=detail.htm=AT18C' -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Prepending an equals sign to a numeric value returns empty result
On Sep 7, 2015, at 10:15 AM, Andrew Solomon wrote: > > If I were you I'd do something like > > print STDERR "UPTO 1\n"; > > in various places to see what's actually being executed. Thanks for the reply. I had done that with Data::Dumper and I couldn't see where the problem was coming from. So I manipulated $search->{$field} instead of the global and it works perfectly. I swear I had tried that before and it didn't work, but it does now. Even though I'm still curious as to what the problem was, it's working the way it's supposed to. What's nice is that if you just enter alphanumeric data, it's prepended with an equals sign to narrow the results, but it you add a wildcard in the search, it doesn't, so you can fine-tune the search to your liking. The best of both worlds. And just to let everyone know, SurfShop was recently added to the Softaculous collection. I'm pretty excited about this as it opens the door to expose a lot more people to a Perl shopping cart. http://www.softaculous.com/apps/perl/ecommerce/SurfShopCART Frank SurfShopCART 2 http://www.surfshopcart.com/u/demo -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Prepending an equals sign to a numeric value returns empty result
I've run across something that seems strange to me and I'm hoping someone has seen this before. In SurfShop, you can search the product database by either item #, product name, or full description. When searching by item id, let's say 'AM', the code will find any part # with the letters 'A' and 'M' in it, e.g. 'ATXM3'. If you add an equals sign to the start of the product #, i.e. '=AM', it will find all items with the letters 'AM', in that order. If you append two equals signs, i.e. '==AM', it will return that record only. Depending on the size of the products db, performing an item # search without prepending '=' can return a long list, so I'd like to have the code add that automatically. In the snippet below, I added the section with the <---. It works perfectly fine, until you try to search for only numbers. If you were to do a search for, say '1234', $main::global->{form}->{'searchtext'} will be blank on the search page, where it's displayed. The strange part is that if I remove the <--- code and just add the equals sign manually in the search field, everything works normally. So the code apparently doesn't like a number prepended with an equals sign. Why would that be, and how can I get it to work? When I ran a test script appending = to a number, it seemed to work just fine, so I'm at a loss. I hope this is enough to go on. If not, please let me know. Thanks, Frank foreach my $field (@fieldnames) { if ($main::global->{form}->{'setSearchBox'} eq $field || $main::global->{form}->{'setSearchBox'} eq 'both') { if ($field eq 'itemid' && $main::global->{form}->{'searchtext'} !~ m/^=|\*|\%/ && $main::global->{config}->{'useDBM'} eq 'sql') { $main::global->{form}->{'searchtext'} = "=$main::global->{form}->{'searchtext'}"; # <--- } $search->{$field} = $main::global->{form}->{'searchtext'}; $searchparams++; } } SurfShopCART 2 http://www.surfshopcart.com/u/demo -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Need explanation of code
Could someone please explain the difference between: %{$self-{'DATA'}} = () } and $self-{'DATA'} = {} I was told that they are equivalent, but they're not. One works and the other doesn't, so they must be different. Here's the context: sub empty_db { my $self = shift; if ($self-{'USEDBM'} eq 'sql') { $self-{'SQL'}-do(DELETE from $self-{'DB'}) or $self-{'ERRMSG'} .= $DBI::errstr and return; } else { %{$self-{'DATA'}} = () } # else { $self-{'DATA'} = {} } # This does nothing } Thanks, Frank SurfShopCART 2 http://www.surfshopcart.com/u/demo -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: How to handle null elements inside an array
On Apr 2, 2015, at 7:43 AM, Anirban Adhikary wrote: When I am trying to split the line based on whitespace @elements = split(/\s+/,$line); It will be interesting if someone can come up with a solution to this, but I don't see one. If your separator is whitespace, then the split has nothing to work with if some values are blank. You'd need to add some kind of separator between your values, like a tab, or a comma, or something else unique that you can split it on. What kind of a file is this information in? If it's in something like Excel, then, of course, you could just re-export it with another separator. However, if it's in a simple text file, you may have to add them by hand. I copied your data into a text file and it looks like you have an arbitrary number of spaces between your data (though that could just be the formatting from the email). I thought that if the spacing was consistent, then you could count the number of spaces, but it doesn't look like that will work, either. Am I missing something? Frank SurfShopCART 2 is here! http://www.surfshopcart.com/u/demo -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Use vs Require with version number
On Mar 4, 2015, at 8:15 PM, Brandon McCaig wrote: That could matter in rare, silly cases. In most cases, it wouldn't really matter (usually we require modules and assert versions at the beginning of a program or module before anything else is actually done). That explains it. Thanks. I wasn't aware that the version requirement might be added later in the script. Frank SurfShopCART 2.0 Coming Soon... http://www.surfshopcart.com/store/demo/surfshop/shop.cgi -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Use vs Require with version number
Hi all, I'm just curious about something. What's the difference between using require 5.016; or use 5.016; The only thing I've seen is that if 5.16 isn't installed, 'use' outputs: Perl v5.16 required--this is only v5.10.1, stopped at shop.cgi line 26. BEGIN failed--compilation aborted at shop.cgi line 26. while 'require' outputs this: Perl v5.16 required--this is only v5.10.1, stopped at shop.cgi line 26. I know there's a difference when calling a module, but what about the version number? Is it just semantics or is there something more to it? My search hasn't revealed an answer. Thanks, Frank SurfShopCART 2.0 Coming Soon... https://www.surfshopcart.com/store/demo/surfshop/shop.cgi -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Use vs Require with version number
On Mar 4, 2015, at 6:14 PM, Uri Guttman wrote: it is more about when the check is done. use is done at compile time and require is done at run time. also use effectively calls require to load the module and then it may do importing as well. when a module is loaded it will run any use lines during its compile and require lines once the module is run. but from the point of view of the code that loaded that module both will cause failure if the version is not supported. So there's only really a difference for loading modules, not for setting the minimum version number? Thanks, Frank SurfShopCART 2.0 Coming Soon... http://www.surfshopcart.com/store/demo/surfshop/shop.cgi -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Finding my localtime
I'm trying to break out a timestamp into it's appropriate fields, like so: my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($my_time); but no matter if I use localtime or gmtime, $my_time gets analyzed as either in the server's timezone or in UTC. I need to break apart the timestamp in $my_time without it being changed. In other words, I'm trying to get $hour, $min, $sec, etc, in _my_ timezone, not the server's nor in UTC. I finally got it to work using: $ENV{'TZ'} = $main::global-{'config'}-{'timezone'}; ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(); but I read somewhere that this may cause problems depending on the platform (?) or something. I can't find it again. Is this solution O.K. to use, or is there a better way to do what I'm after? I know that I can use DateTime for this, but I'm trying to see what I can do without it. Thanks, Frank SurfShopCART https://github.com/surfshopcart/surfshop -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Finding my localtime
On Feb 4, 2015, at 1:55 PM, $Bill wrote: I had a similar situation where I'm in Pacific time and my server is in Eastern time. My solution was to just add this to my BEGIN { } : $ENV{TZ} = 'PST8PDT'; to force my time displays to Pacific time. I didn't think about adding it to a BEGIN block. I just added it to the get_date sub and it seems to work fine. I just didn't know if it was a proper way to do that. I'm using it to make sure that all orders added to the shopping cart are in the store owners timezone and not the server's, if it's different. I'm not sure what ( $main::global-{'config'}-{'timezone'}; ) gives you in terms of a timezone. Is that the compiled in timezone when Perl was built ? Or the dynamic timezone determined at runtime from the system ? Or ? I'm using standard timezone names, e.g. America/Los_Angeles. I've setup the configuration script with a drop down list of all timezone names and their offsets (-8) which then populates the config file. It's then pulled from there. Thanks, Frank SurfShopCART https://github.com/surfshopcart/surfshop -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Finding my localtime
On Feb 4, 2015, at 4:30 PM, Shawn H Corey wrote: Have you read `perldoc perllocale` especially the `setlocale` function? http://perldoc.perl.org/perllocale.html#The-setlocale-function Actually, I did, but unless I read it incorrectly, it doesn't appear to have anything to do with timezones. Did I miss it? I can see where it will come in real handy with month names and days of the week for different locales, though. Thanks, Frank SurfShopCART https://github.com/surfshopcart/surfshop -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Finding my localtime
On Feb 4, 2015, at 5:20 PM, Shawn H Corey wrote: I seems to me if you change locales, you would necessarily change timezones too. But I haven't done much playing around with locales. :( Me neither, but I'm learning more than I thought I would! ;) Looking at the locales for just the US: en_US en_US.ISO8859-1 en_US.ISO8859-15 en_US.US-ASCII en_US.UTF-8 there isn't anything that differentiates the timezone, so I don't think it does. But it might for countries that have only one timezone. Frank SurfShopCART https://github.com/surfshopcart/surfshop -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Multi-line `find` commands
Is it possible to wrap a `find` command on multiple lines in a script? This is what I'm using now: foreach $dir_to_search (@dirs_to_search) { $dir_count--; @files = map { s|/home/user/public_html ||; $_; } `find $dir_to_search -name cache -prune -o -name tmp -prune -o -name session -prune -o -print`; I'd like to be able to do something like this to make it more readable: foreach $dir_to_search (@dirs_to_search) { $dir_count--; @files = map { s|/home/user/public_html||; $_; } `find $dir_to_search -name cache -prune -o -name tmp -prune -o -name session -prune -o -print`; however my searches have turned up nothing. Using returns, commas, backslashes, or concatenation breaks the find. Does anyone know if this is doable? Thanks, Frank SurfShopCART -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Multi-line `find` commands
Thanks, guys. I appreciate the responses. I couldn't get either of those solutions to work so I'll switch over to using File::Find. I don't know why I didn't think of that before - I use it in other scripts. :\ I guess I was just trying to see if I could tweak the script and get it to work since it's super fast. Thanks again, Frank SurfShopCART -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Multi-line `find` commands
On Jan 1, 2015, at 4:08 PM, $Bill wrote: You can always separate the two, eg: my $find = find $dir_to_search . '-name cache -prune' . '-o -name tmp -prune' . '-o -name session -prune' . '-o -print'; @files = map { s|/home/user/public_html||; $_; } `$find`; We have ourselves a winner! :) Thanks, Bill. After I realized that you could put a variable between backticks, that's exactly what I did. Too much eggnog here this week, I guess! On Jan 1, 2015, at 4:04 PM, Shawn H Corey wrote: File::Find::Rule is easier to use. https://metacpan.org/pod/File::Find::Rule Thanks, Shawn. I'll check it out over the weekend. Happy New Year! Frank SurfShopCART -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: CGI::Application::Plugin::TT
On Nov 12, 2014, at 4:54 AM, Patton, Billy N wrote: I’ve , mistakenly, updated to Mac OS 10.10 Yosemite. That completely caused my app to fail in Apache 2.4. And that's one of the many reasons I'm not updating my MacBook. ;) You really have too try Perlbrew http://perlbrew.pl/. It's perfect for this. You can install any version of Perl that you want, and then install the modules you'll need. You can even install multiple versions of Perl and each version can have it's own set of modules! Best of all, it leaves your system version of Perl untouched, which helps prevent problems for other apps that rely on it. Perlbrew, along with cpanm, will make your Perl setup as painless as possible. However, I do remember the initial setup was somewhat confusing because of a lack of documentation at the time. Hopefully that's changed by now. I've been using it for years now and I'd never go back. Frank SurfShopCART https://github.com/surfshopcart/surfshop -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
map vs foreach
Is the output of these two lines equivalent? map { $hash-{$_} = shift @record } @{$self-{'FIELDNAMES'}}; $hash-{$_} = shift @record foreach @{$self-{'FIELDNAMES'}}; They appear to be in my testing, but I'd like to make sure. Is one more appropriate than the other in a situation like this, or is it simply a styling difference? Thanks, Frank SurfShop shopping cart is now open source... Follow us on GitHub! https://github.com/surfshopcart/surfshop -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: map vs foreach
On Sep 30, 2014, at 4:08 PM, Shawn H Corey wrote: code like you will have to read it after an all-night party (some day, you will). Those days are over, but point taken! ;) Thanks, Frank SurfShopCART https://github.com/surfshopcart/surfshop -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: map vs foreach
On Sep 30, 2014, at 4:19 PM, David Precious wrote: So, e.g.: my %fields = map { $_ = shift @record } @{$self-{'FIELDNAMES'}}; ... would make sense, because you're using map to produce the data you want, rather than using it instead of a for loop. Thanks, David. That was an excellent explanation! As usual, I stumbled across an old thread on PerlMonks after I posted my question. :\ It was a good read, however, and it's helped to clear up my understanding of map. If anyone else is interested, it's here: http://www.perlmonks.org/?node_id=296742 However, David's response was pretty much everything that was in the thread, but in a nutshell. Frank SurfShopCART https://github.com/surfshopcart/surfshop -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: [ANN] SurfShop 1.6.1 Shopping Cart Released
On Sep 21, 2014, at 5:07 PM, John W. Krahn wrote: If the unwanted elements are in the middle or left hand side of the list: ($null, $item) = join_cart_item('', '', '', $data); Then you could use undef as a place holder: (undef, $item) = join_cart_item('', '', '', $data); Thanks again for your help, John. I'm just about finished implementing your suggestions. Some of them have prompted a few technical and style questions, but I'll ask them separately so I can change the subject. Frank -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Argument isn't numeric warning in if statement
On Sep 16, 2014, at 6:58 PM, sisyph...@optusnet.com.au sisyph...@optusnet.com.au wrote: Are you sure you've quoted the code (that's producing the warning) correctly? Yes, I did. I double-checked it just to be certain. However, I ran the code by itself and it doesn't produce that warning, so it must be something upstream that's causing it. Thanks, Frank SurfShop shopping cart is now open source... Follow us on GitHub! https://github.com/surfshopcart/surfshop -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Argument isn't numeric warning in if statement
On Sep 17, 2014, at 3:32 PM, Rob Dixon wrote: As you have presented them, those code fragments are identical in meaning. That was my understanding as well, but the inline 'if' gave an error while the block didn't. Running the code by itself in TextWrangler does not produce the warning. However, inside of my script, it does. Strange. This probably doesn't have anything to do with it, but I'm logging during tests with this code: BEGIN { use CGI::Carp qw(carpout); open(my $log, '', 'temp_logs/error.log') or warn(Unable to open error.log: $! \n); carpout($log); } $item-{unitprice} += $item-{optionprice} if ($item-{optionprice}); Just so I'm clear on this, am I correct in thinking that Perl evaluates an inline 'if' from right to left - meaning that if $item-{optionprice} is NOT true, then the addition will not even be seen? Or does Perl look at the entire line before performing it? Thanks, Frank SurfShop shopping cart is now open source... Follow us on GitHub! https://github.com/surfshopcart/surfshop -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Argument isn't numeric warning in if statement
I just ran across something puzzling. Why are these two statements not equivalent when it comes to warnings? if ($item-{'optionprice'}) { $item-{'unitprice'} += $item-{'optionprice'}; } and $item-{'unitprice'} += $item-{'optionprice'} if ($item-{'optionprice'}); Given the following values: $item-{'unitprice'} = '12.16'; $item-{'optionprice'} = ''; the 2nd statement returns an Argument '' isn't numeric in addition (+) warning, while the 1st one doesn't. I thought I read where Peal reads a statement like the 2nd one from right to left. It looks like it doesn't, since $item-{'optionprice'} is evaluated in spite of the 'if'. Am I mistaken? Perl 5.10.1 Thanks, Frank SurfShop shopping cart is now open source... http://www.surfshopcart.com/ Setting up shop has never been easier! Follow us on GitHub! https://github.com/surfshopcart/surfshop -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
[ANN] SurfShop 1.6.1 Shopping Cart Released
Sorry for a repost so soon, but if you downloaded SurfShop 1.6.0, you were greeted with a 500 error upon installation. Somehow, during the upload, GitHub for Mac corrupted some of the files with extraneous text which rendered SurfShop unusable. Unfortunately, it wasn't caught for a few days. I apologize profusely if you were bitten by this. I have found and cleaned all the miscreant files, and version 1.6.1 was uploaded to GitHub on Friday. After that fiasco, I wanted to sit on the fix awhile and run more tests before letting everyone know that it was fixed. I'm pleased to say that version 1.6.1 fixes those problems. So, if you're interested in an open source Perl/MySQL shopping cart, check out our forum for more information: http://www.surfshopcart.com/forrumm/viewtopic.php?f=2 Again, let us know what you think! Your feedback, as always, is appreciated. Regards, Frank Jance http://www.surfshopcart.com/ Setting up shop has never been easier! Follow us on GitHub! https://github.com/surfshopcart/surfshop -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
[ANN] SurfShop 1.6.0 Released
Just a short note to let everyone know that a new version of SurfShop was released to GitHub today. We've added some requested features and made some fixes, as well. http://www.surfshopcart.com/forrumm/viewtopic.php?f=2t=300 Let us know what you think! Your feedback is always appreciated. Thanks, Frank Jance http://www.surfshopcart.com/ Setting up shop has never been easier! Follow us on GitHub! https://github.com/surfshopcart/surfshop -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Creating a hash of arrays from DATA
On Jul 10, 2014, at 7:14 AM, Nathan Hilterbrand wrote: $entries{$state} = [ (split /,/ = $zipcodes) ]; Thanks, Nathan. The line above caught my eye. It's interesting to see that you don't need both 'push' and 'split' to populate the hash. Could you explain a little about what the square brackets are for here? Does that have something to do with array ref's? Sorry... hashes are a weak spot of mine. I also noticed that you wrote the split as (split /,/ = $zipcodes) instead of split (/,/ = $zipcodes) Is that just a stylistic difference or is there something more to it? Both work for me. Frank http://www.surfshopcart.com/ Setting up shop has never been easier! Now on GitHub https://github.com/surfshopcart/surfshop -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Creating a hash of arrays from DATA
On Jul 10, 2014, at 9:00 AM, Ron Bergin wrote: my($state, @zipcodes) = split /[=,]/, $line; Interesting concept, the multiple split. I'd be interested in knowing how Perl knows to give the singular value on the left of the = to $state and all other values split on the , to @zipcodes. Is it because $state is a scalar and @zipcodes is an array, or is it more complex than that? Thanks, Frank http://www.surfshopcart.com/ Setting up shop has never been easier! Now on GitHub https://github.com/surfshopcart/surfshop -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: script to match a valid email id
On Jul 10, 2014, at 11:30 AM, Sunita Pradhan wrote: I want to write a script which will verify a valid email address . Could anybody give some ideas , how to write a pattern for this ? Sunita, I've used Email::Valid for this and it works nicely. And the code to use it is pretty easy, too. use Email::Valid; if (!Email::Valid-address( -address = $email_address_to_test, -mxcheck = 1 )) { ... process error here ... } https://metacpan.org/pod/Email::Valid Frank http://www.surfshopcart.com/ Setting up shop has never been easier! Now on GitHub https://github.com/surfshopcart/surfshop -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Creating a hash of arrays from DATA
I'm having a problem creating a hash of arrays. The while loop below works, but it's working too well. ;) Instead of giving me 5 values (from the example data below), it's giving me 25. I don't understand why it seems to be looping through the push statement. If someone could explain what I'm doing wrong, I'd appreciate it. I just can't see it. Thanks, Frank -- use strict; use warnings; use 5.010; use Data::Dumper; my %entries; while (my $line = DATA) { chomp $line; my($state, $zipcodes) = split (/=/, $line); push( @{ $entries{$state} }, split( /,/ = $zipcodes) ) } foreach my $state (sort keys %entries) { say The Zip Codes of $state are; foreach (@{$entries{$state}}) { print Dumper (@{$entries{$state}}); } } __DATA__ AK=995,996,997,998,999 --OUTPUT-- The Zip Codes of AK are $VAR1 = '995'; $VAR2 = '996'; $VAR3 = '997'; $VAR4 = '998'; $VAR5 = '999'; $VAR1 = '995'; $VAR2 = '996'; $VAR3 = '997'; $VAR4 = '998'; $VAR5 = '999'; $VAR1 = '995'; $VAR2 = '996'; $VAR3 = '997'; $VAR4 = '998'; $VAR5 = '999'; $VAR1 = '995'; $VAR2 = '996'; $VAR3 = '997'; $VAR4 = '998'; $VAR5 = '999'; $VAR1 = '995'; $VAR2 = '996'; $VAR3 = '997'; $VAR4 = '998'; $VAR5 = '999'; http://www.surfshopcart.com/ Setting up shop has never been easier! Now on GitHub https://github.com/surfshopcart/surfshop -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Creating a hash of arrays from DATA
On Jul 9, 2014, at 7:56 PM, John SJ Anderson wrote: This foreach loop is looping over the five zip codes in the array... print Dumper (@{$entries{$state}}); And printing out the same array each time. Thanks, John. I wasn't even looking at the printout loop. :\ For some reason, I was thinking my problem was in creating the hash. I see what I did wrong now. Thanks again, Frank http://www.surfshopcart.com/ Setting up shop has never been easier! Now on GitHub https://github.com/surfshopcart/surfshop -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: CGI script produces blank screen
Perhaps some module on which the script depends is not available/installed on that server. But yes.. looking into the web server error log should help. On 28 June 2014 08:35, John SJ Anderson geneh...@genehack.org wrote: On Fri, Jun 27, 2014 at 7:34 PM, SSC_perl p...@surfshopcart.com wrote: Any input would be greatly appreciated! Look in the web server error log. Thanks for the pointers, guys. It turned out to be an errant line in the .htaccess file on that domain. It would have paid to take that out of the equation first. Frank http://www.surfshopcart.com/ Setting up shop has never been easier!
CGI script produces blank screen
I don't have a lot of info to go on just yet, so please bear with me. I'm experiencing a problem with a blank screen on a certain install of SurfShop. When on a product detail page that has options, if I try to add that item to the cart w/o selecting any of the options, it should return the current page with a warning that I need to select the options. However, I'm getting a completely blank screen. Even when viewing the source, there's no HTML being output. The odd part is that I copied this same installation to another server -- so it's an exact duplicate -- and it functions normally there! As far as I can tell, the code seems O.K. The only difference that I can see, so far, are the different servers. One's running Perl 5.8.8 and the other has 5.10.1. The latter is the one that's working correctly. What kind of tests can I do to see why it's acting up on one server and not another? I'm already running with warnings and CGI::Carp, but without any output, I'm at a loss as what to try next. Any input would be greatly appreciated! Thanks, Frank http://www.surfshopcart.com/ Setting up shop has never been easier! -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Stopping undefined warnings
On Jun 17, 2014, at 1:27 PM, Jim Gibson wrote: I would split your one, long line into several lines and use a temporary variable to hold the possibly undefined value and assigning '' to it if it is undefined: I like that idea. Thanks, Jim. However, that's going to be a lot of extra work. Does anyone know of a way to suppress all uninitialized warnings to the log? That way, I wouldn't have to add extra code throughout the script just to stop those. CGI::Carp allows you to send 'fatalsToBrowser' but I can't find an equivalent 'fatalsToLog' or 'justImportantErrorsToLog' feature. Am I missing it, or is it just not there? Is there another module that allows this? I'd like to find a replacement for the following, as it allows the code to be added to the script only once, which makes it easy to use it or comment it out as desired: BEGIN { use CGI::Carp qw(carpout); open(my $log, '', '/usr/local/cgi-logs/mycgi-log') or die(Unable to open mycgi-log: $!\n); carpout($log); } SurfShop does have an error subroutine, but I like to use the above to catch things that may not be flagged by the sub. Thanks again, Frank http://www.surfshopcart.com/ Setting up shop has never been easier! -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Stopping undefined warnings
I just realized that I can add no warnings 'uninitialized'; to the entire script, which probably makes my last question moot. Unless there's an answer that someone likes better, just disregard that question. I can't think straight with this cold. Not that I need an excuse. ;) Frank http://www.surfshopcart.com/ Setting up shop has never been easier! -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Stopping undefined warnings
What's the best way to stop undefined warnings for code like this: $data-{'image'} = CopyTempFile('image') if ($main::global-{'admin'} $main::global-{'form'}-{'image_upload'} ne ''); CGI::Carp gives the following: [Tue Jun 17 14:54:36 2014] admin.cgi: Use of uninitialized value in string ne at admin.cgi line 219. I know that I can surround the section with { no warnings 'uninitialized'; ... } or I could add a check for defined-ness as follows: $data-{'image'} = CopyTempFile('image') if ($main::global-{'admin'} defined $main::global-{'form'}-{'image_upload'} $main::global-{'form'}-{'image_upload'} ne ''); Is there a better way to stop this warning in situations like this? I'd like to keep these warnings from filling up the log. Thanks, Frank http://www.surfshopcart.com/ Setting up shop has never been easier! -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Passing multiple select statements to MySQL
On Feb 19, 2014, at 4:20 AM, Dr.Ruud wrote: my $sth_4; ... (untested) Thanks for the code but I still get the same error: DBD::mysql::st execute failed: You have an error in your SQL syntax; - Long pause for trial and error -- Well with the help of the author, I was able to get it to work. This is the code I used before, based on the CPAN page: use SQL::SplitStatement; my @statements = $sql_splitter-split($query_4); my $sql_string = join ' ', @statements; my $sth_4 = $dbh-prepare($sql_string); $sth_4-execute(); and this is the working code that he sent me: use SQL::SplitStatement; my @statements = $splitter-split( $query_4 ); foreach my $statement (@statements) { $sth_4 = $dbh-prepare($statement); $sth_4-execute(); } I know I had tried something similar, but it didn't work before and now it does. :\ Thanks, Frank http://www.surfshopcart.com/ Setting up shop has never been easier! -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Passing multiple select statements to MySQL
I'm helping someone retrieve some info from a MySQL db and I'm having trouble sending multiple select statements with Perl. Here's a portion of the code: use SQL::SplitStatement; my $query_4 = CREATE TEMPORARY TABLE `temp_ip` AS (SELECT `ip` FROM `ip_addresses` .$daily. AND TRIM(`referrer`) LIKE '' GROUP BY `ip` HAVING COUNT(*) 1); SELECT `ip`, `page`, `url`, `time_stamp` FROM `ip_addresses` .$daily. AND TRIM(`referrer`) LIKE '' AND `ip` IN (SELECT `ip` FROM `temp_ip`); my $sql_splitter = SQL::SplitStatement-new( keep_terminators = 1, keep_extra_spaces = 1, keep_comments = 0, keep_empty_statements = 1 ); my @statements = $sql_splitter-split($query_4); my $sql_string = join ' ', @statements; my $sth_4 = $dbh-prepare($sql_string); $sth_4-execute(); I believe what's throwing a wrench in it is the ; separating the 2 select statements. That's why I'm using SQL::SplitStatement, but that doesn't seem to help, so I'm sure I'm doing something wrong. The SQL works fine, so my problem must be with my Perl code. I've read everything I can get my hands on but no luck. Any help would be greatly appreciated. Thanks, Frank http://www.surfshopcart.com/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Replacing the first line of a text file
Thanks everyone. Both Tie::File and File::Slurp work nicely for this purpose. Now comes the hard part - picking which one I want to use. ;) Frank http://www.surfshopcart.com/ Setting up shop has never been easier! -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Replacing the first line of a text file
I'm having a problem with the script below. I want to alter just the first line of a CSV file, removing the prefix tag_ from each value in that line. However, because the new line is shorter than the original, the script is only over-writing part of the original line (exactly the number of characters of the new line). Is there a way to replace the entire line with the new, shorter one? Thanks, Frank use strict; use warnings; my $filename = 'products.csv'; open (my $fh, '+', $filename) || die can't open $filename: $!; my $line = $fh; $line =~ s/tag_//gi; seek $fh, 0, 0; printf {$fh} $line; close $fh; http://www.surfshopcart.com/ Setting up shop has never been easier! -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: baby perl to get the right date
On Jan 28, 2014, at 8:59 PM, Rob Dixon wrote: It is probably best to use the Time::Piece module, which has been part of core Perl 5 since version 10 Side question: does anyone know why the Perl team chose Time::Piece over Date::Time to be bundled with Perl? I've known about Date::Time for awhile now, but this is the first I've heard of Time::Piece. Just curious. Frank http://www.surfshopcart.com/ Setting up shop has never been easier!
Package version numbers
I'm trying to number packages the way it's written about on page 406 of Programming Perl, 4th ed., e.g. package Emailer 1.01; However, when I do that, I get the following error: syntax error at ss_files/Emailer.pm line 1, near package Emailer 1.01 Compilation failed in require at admin.cgi line 38. BEGIN failed--compilation aborted at admin.cgi line 38. I'm running Perl 5.10.1 on my laptop so that should be new enough to handle this. What am I doing wrong? Thanks, Frank http://www.surfshopcart.com/ Setting up shop has never been easier! -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Package version numbers
On Jan 14, 2014, at 4:04 PM, John SJ Anderson wrote: I'm not sure exactly when that syntax was added, but for what it's worth, it fails with 5.10.1 here too. Perl 5.12.5, on the other hand, works. You may just need to upgrade. Thanks for the test, John. In the book's example, they have: use v5.10; so I thought I was new enough, but maybe not. I've resorted to adding: use vars '$VERSION'; $VERSION = '1.01'; after the package declaration. That works, but it's just not as clean looking. Not a big deal, though. Thanks again, Frank http://www.surfshopcart.com/ Setting up shop has never been easier! -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Locating files in sub-directories
Octavian, Thanks for the reply. So I tried the following: use lib ss_files; This also works, but iirc, I read that it won't work across all platforms. Is that correct? This method also works, but to be equivalent with the first method it should have been: use lib ../ss_files; Actually, that doesn't work. Adding ../ breaks the script. If you change the current directory to be another directory, like /home/user for example, it won't work, because it will search for modules in /home/ss_files. The directory won't change once the script is installed. Both shop.cgi and the ss_files directory are in the surfshop directory and will always remain there. The surfshop directory could, in theory, be placed anywhere, but that shouldn't have any effect on shop.cgi calling the other files, no? If that's the case, I like use lib ss_files; simply because it's short and sweet. If no one knows of a problem with portability, then I'll stick with it. I just don't want someone to download our cart and then have a problem with it simply because I wasn't able to test it properly. Thanks again, Frank SurfShop v1.5.2 Released http://www.surfshopcart.com/forrumm/viewtopic.php?f=2t=298 - For the sake of completeness, I ran across another way to locate files in a sub-directory here: http://learn.perl.org/faq/perlfaq8.html#How-do-I-add-the-directory-my-program-lives-in-to-the-module-library-search-path- BEGIN { use Cwd; our $cur_directory = cwd; } use lib $cur_directory/ss_files; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/