Re: perlbrew and modules

2017-12-07 Thread SSC_perl
> On Dec 7, 2017, at 3:39 PM, Andy Bach wrote: > > 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

Re: perlbrew and modules

2017-12-07 Thread SSC_perl
> On Dec 7, 2017, at 3:09 PM, Andy Bach wrote: > > 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 e

Re: perlbrew and modules

2017-12-07 Thread SSC_perl
> On Dec 7, 2017, at 1:40 PM, Shlomi Fish wrote: > > 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? Fra

Re: perlbrew and modules

2017-12-07 Thread SSC_perl
> On Dec 7, 2017, at 1:40 PM, Shlomi Fish wrote: > > 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

Re: perlbrew and modules

2017-12-07 Thread SSC_perl
> On Dec 7, 2017, at 12:04 PM, Shlomi Fish wrote: > > 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/

perlbrew and modules

2017-12-07 Thread SSC_perl
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 'fatalsToBro

perlbrew and cron

2017-12-07 Thread SSC_perl
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

Re: Problem with perlbrew and LiteSpeed

2017-12-07 Thread SSC_perl
> On Dec 5, 2017, at 10:23 AM, Chas. Owens wrote: > > 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-

Problem with perlbrew and LiteSpeed

2017-12-05 Thread SSC_perl
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 r

Re: Getting the results of a remote script

2017-11-09 Thread SSC_perl
> On Nov 9, 2017, at 2:06 PM, David Precious wrote: > > 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 i

Re: Getting the results of a remote script

2017-11-09 Thread SSC_perl
> On Nov 8, 2017, at 5:16 PM, thelip sia wrote: > > 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

Getting the results of a remote script

2017-11-08 Thread SSC_perl
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

Astro::Sunrise vs DateTime::Event::Sunrise

2017-08-19 Thread SSC_perl
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 s

Re: "Information station" using Perl and Raspberry Pi

2017-08-01 Thread SSC_perl
There was some good information in this thread. Thank you! > On Jul 26, 2017, at 2:38 AM, David Precious wrote: > > 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

Re: "Information station" using Perl and Raspberry Pi

2017-07-25 Thread SSC_perl
> On Jul 25, 2017, at 2:08 PM, Andrew Solomon wrote: > > 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 f

"Information station" using Perl and Raspberry Pi

2017-07-25 Thread SSC_perl
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.

Using __DATA__ with XML::LibXML

2017-06-22 Thread SSC_perl
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.

Re: Time::HiRes output

2017-05-27 Thread SSC_perl
> On May 24, 2017, at 7:17 PM, Chas. Owens wrote: > > 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,

Time::HiRes output

2017-05-24 Thread SSC_perl
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 $cl

HTTP::Recorder problem [solutions?/alternatives?]

2017-04-28 Thread SSC_perl
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 D

Re: Getting a specific page using WWW::Mechanize [SOLVED]

2017-04-25 Thread SSC_perl
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 sa

Re: Getting a specific page using WWW::Mechanize

2017-04-25 Thread SSC_perl
> On Apr 25, 2017, at 10:09 AM, Chas. Owens wrote: > > 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

2017-04-25 Thread SSC_perl
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

Getting a specific page using WWW::Mechanize

2017-04-25 Thread SSC_perl
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

Re: Perl reserved words

2017-04-24 Thread SSC_perl
> On Apr 23, 2017, at 11:51 AM, Shlomi Fish wrote: > > 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”. ;) T

Perl reserved words

2017-04-23 Thread SSC_perl
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

Re: how to repeatedly execute a command on a remote machine via a shh login from within a perl program capturing the output?

2017-04-18 Thread SSC_perl
> On Apr 18, 2017, at 6:19 PM, lee wrote: > > 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

Re: Scalar References - oxymoron?

2017-04-04 Thread SSC_perl
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

2017-04-04 Thread SSC_perl
> On Apr 4, 2017, at 12:01 PM, John SJ Anderson wrote: > > ¯\_(ツ)_/¯ 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

2017-04-04 Thread SSC_perl
> On Apr 4, 2017, at 10:59 AM, John SJ Anderson wrote: > > 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.

WWW::Mechanize requires wget

2017-04-04 Thread SSC_perl
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 blocke

Scalar References - oxymoron?

2017-04-03 Thread SSC_perl
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

Re: Perl Critic and subroutine signatures

2017-03-29 Thread SSC_perl
> On Mar 29, 2017, at 3:47 PM, Kevin Phair wrote: > > 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

Re: Perl Critic and subroutine signatures

2017-03-29 Thread SSC_perl
> On Mar 29, 2017, at 10:19 AM, Uri Guttman wrote: > > 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

2017-03-29 Thread SSC_perl
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 u

Re: Equivalents statements using if and unless

2017-03-29 Thread SSC_perl
> On Mar 28, 2017, at 1:58 PM, Uri Guttman wrote: > > 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 optimi

Equivalents statements using if and unless

2017-03-28 Thread SSC_perl
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

Re: Changing date format using carpout

2017-03-26 Thread SSC_perl
> On Mar 26, 2017, at 1:15 PM, Shawn H Corey wrote: > > 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 d

Re: Changing date format using carpout

2017-03-26 Thread SSC_perl
> On Mar 26, 2017, at 1:20 AM, X Dungeness wrote: > > 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 learne

Re: Changing date format using carpout

2017-03-26 Thread SSC_perl
> On Mar 25, 2017, at 8:58 PM, Jim Gibson wrote: > > 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 c

Changing date format using carpout

2017-03-25 Thread SSC_perl
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,'>&STDERR'); close STDERR; open (my $log, '>>', 'logs/error.log') or warn("Couldn't open error.log: $! \n"); car

Re: Problem using Email::Mailer on laptop

2017-03-20 Thread SSC_perl
> 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, Dav

Re: Problem using Email::Mailer on laptop

2017-03-20 Thread SSC_perl
> On Mar 20, 2017, at 12:04 PM, SSC_perl 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 f

Re: Problem using Email::Mailer on laptop

2017-03-20 Thread SSC_perl
> On Mar 20, 2017, at 11:42 AM, Bill wrote: > > 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 fa

Problem using Email::Mailer on laptop

2017-03-20 Thread SSC_perl
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

Re: Installing Net::SFTP

2017-03-20 Thread SSC_perl
> On Mar 15, 2017, at 6:44 AM, Shawn H Corey wrote: > > 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 u

Logging SQL Queries

2017-02-22 Thread SSC_perl
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 sol

Re: Strange HASH(0x2ced735) values

2017-02-21 Thread SSC_perl
> On Feb 21, 2017, at 2:34 PM, Sam wrote: > > 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 o

Re: Strange HASH(0x2ced735) values

2017-02-21 Thread SSC_perl
> On Feb 21, 2017, at 8:34 AM, Uri Guttman wrote: > > 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

Strange HASH(0x2ced735) values

2017-02-21 Thread SSC_perl
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 w

Re: Declaring and conditionally assigning to a variable on the same line

2017-02-15 Thread SSC_perl
> On Feb 15, 2017, at 11:08 AM, Uri Guttman wrote: > > 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

Declaring and conditionally assigning to a variable on the same line

2017-02-15 Thread SSC_perl
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.

Re: Extra text printed by Data::Dumper

2017-02-04 Thread SSC_perl
> On Feb 3, 2017, at 7:17 PM, Ken Slater wrote: > > HTH Yes, it does. Thanks to both you and Chas for the help. Frank

Extra text printed by Data::Dumper

2017-02-03 Thread SSC_perl
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 w

Re: This is one of the things ...

2016-05-12 Thread SSC_perl
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

Re: Regex to match "bad" characters in a parameter

2016-01-26 Thread SSC_perl
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-unsub

Re: Regex to match "bad" characters in a parameter

2016-01-26 Thread SSC_perl
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 inadver

Regex to match "bad" characters in a parameter

2016-01-25 Thread SSC_perl
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 samp

Re: Prepending an equals sign to a numeric value returns empty result

2015-09-08 Thread SSC_perl
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

Prepending an equals sign to a numeric value returns empty result

2015-09-05 Thread SSC_perl
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 letter

Need explanation of code

2015-04-11 Thread SSC_perl
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 {

Re: How to handle null elements inside an array

2015-04-02 Thread SSC_perl
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

Re: Use vs Require with version number

2015-03-05 Thread SSC_perl
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.

Re: Use vs Require with version number

2015-03-04 Thread SSC_perl
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

Use vs Require with version number

2015-03-04 Thread SSC_perl
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--compilatio

Re: Finding my localtime

2015-02-04 Thread SSC_perl
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 th

Re: Finding my localtime

2015-02-04 Thread SSC_perl
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 t

Re: Finding my localtime

2015-02-04 Thread SSC_perl
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 add

Finding my localtime

2015-02-04 Thread SSC_perl
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

Re: Multi-line `find` commands

2015-01-01 Thread SSC_perl
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'; > >

Re: Multi-line `find` commands

2015-01-01 Thread SSC_perl
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 t

Multi-line `find` commands

2015-01-01 Thread SSC_perl
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 -na

Re: CGI::Application::Plugin::TT

2014-11-12 Thread SSC_perl
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

Re: map vs foreach

2014-09-30 Thread SSC_perl
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

Re: map vs foreach

2014-09-30 Thread SSC_perl
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-uns

map vs foreach

2014-09-30 Thread SSC_perl
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

Re: [ANN] SurfShop 1.6.1 Shopping Cart Released

2014-09-25 Thread SSC_perl
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

Re: Argument isn't numeric warning in if statement

2014-09-17 Thread SSC_perl
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

Re: Argument isn't numeric warning in if statement

2014-09-17 Thread SSC_perl
On Sep 16, 2014, at 6:58 PM, 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 caus

Argument isn't numeric warning in if statement

2014-09-16 Thread SSC_perl
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'});

[ANN] SurfShop 1.6.1 Shopping Cart Released

2014-09-06 Thread SSC_perl
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

[ANN] SurfShop 1.6.0 Released

2014-09-02 Thread SSC_perl
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=2&t=300 Let us know what you think! Your feedback is always

Re: script to match a valid email id

2014-07-10 Thread SSC_perl
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

Re: Creating a hash of arrays from

2014-07-10 Thread SSC_perl
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 @zipcod

Re: Creating a hash of arrays from

2014-07-10 Thread SSC_perl
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 wh

Re: Creating a hash of arrays from

2014-07-09 Thread SSC_perl
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 so

Creating a hash of arrays from

2014-07-09 Thread SSC_perl
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 cou

Re: CGI script produces blank screen

2014-06-28 Thread SSC_perl
> 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 wrote: > On Fri, Jun 27, 2014 at 7:34 PM, SSC_perl wrote: > >

CGI script produces blank screen

2014-06-27 Thread SSC_perl
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 shoul

Re: Stopping undefined warnings

2014-06-23 Thread SSC_perl
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. ;)

Re: Stopping undefined warnings

2014-06-23 Thread SSC_perl
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 lo

Stopping undefined warnings

2014-06-17 Thread SSC_perl
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

Re: Passing multiple select statements to MySQL

2014-02-20 Thread SSC_perl
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 auth

Passing multiple select statements to MySQL

2014-02-17 Thread SSC_perl
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

Re: Replacing the first line of a text file

2014-02-04 Thread SSC_perl
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 additio

Replacing the first line of a text file

2014-02-03 Thread SSC_perl
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 num

Re: baby perl to get the right date

2014-01-29 Thread SSC_perl
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::Ti

Re: Package version numbers

2014-01-14 Thread SSC_perl
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, t

Package version numbers

2014-01-14 Thread SSC_perl
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 adm

Re: Locating files in sub-directories

2013-12-17 Thread SSC_perl
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

  1   2   >