problem with passing variables

2011-12-30 Thread Mark Haney
I'm not sure if this is the right list for this, so bear with me. If it isn't I'll be glad to post it on the correct one. I've got a problem with passing variables to a SQL server inside a CGI script. My code is like this: my $begin_time = 2011-11-16 11:00:00; my $end_time = 2011-11-16

Re: problem with passing variables

2011-12-30 Thread nat
Mark, I'm kind of new with perl, but from what I see, you're using a single quote when defining $sql, and it should be qq for the interpolated string. With the single quote (q) it is a literal. Hope this helps. On Friday, December 30, 2011 11:17:30 AM Mark Haney wrote: I'm not sure

Re: File Size Script Help - Working Version

2011-12-30 Thread Igor Dovgiy
Hi Jonathan, Argh, really stupid mistake by me. ) But let's use it to explain some points a bit further, shall we? A skilled craftsman knows his tools well, and Perl programmer (with CPAN as THE collection of tools of all sizes and meanings) has an advantage here: even if documentation is a bit

Re: File Size Script Help - Working Version

2011-12-30 Thread Igor Dovgiy
Hi John, yes, good point! Totally forgot this. ) Adding new files to a directory as you browse it is just not right, of course. Possible, but not right. ) I'd solve this by using hash with filenames as keys and collected 'result' strings (with md5 and filesizes) as values, filled by File::Find

Re: File Size Script Help - Working Version

2011-12-30 Thread Jonathan Harris
On Fri, Dec 30, 2011 at 11:58 AM, Igor Dovgiy ivd.pri...@gmail.com wrote: Hi John, yes, good point! Totally forgot this. ) Adding new files to a directory as you browse it is just not right, of course. Possible, but not right. ) I'd solve this by using hash with filenames as keys and

Re: What does = means?

2011-12-30 Thread Xi Chen
Yes, I agree the code looks strange. Do you have any idea to do this with a clear code? I mean to find two same letters, p in @a? Xi On Thu, Dec 29, 2011 at 10:17 PM, John W. Krahn jwkr...@shaw.ca wrote: Xi Chen wrote: Hello everyone, I saw a code below to get two same letters p in @a. @a

Re: What does = means?

2011-12-30 Thread Igor Dovgiy
Hi Xi, You're looking only for 'p' letters, not D and O? Why? Anyway, generic solution will be something like... my %seen; my @repeated = grep { /some regex here/ $seen{$_} N } @source_array; ... where N is how many times the symbols should appear in the source array to be counted as

Re: What does = means?

2011-12-30 Thread Igor Dovgiy
Oh my, of course it should be... my @repeated = grep { /some regex here/ ++$seen{$_} N } @source_array; ... to work properly. -- iD 2011/12/30 Igor Dovgiy ivd.pri...@gmail.com Hi Xi, You're looking only for 'p' letters, not D and O? Why? Anyway, generic solution will be something

Re: What does = means?

2011-12-30 Thread John Riselvato
in this code what is the $n =~ /$b/i; On Fri, Dec 30, 2011 at 11:53 AM, John Riselvato jdriselv...@gmail.comwrote: in this code what is the $n =~ /$b/i; On Fri, Dec 30, 2011 at 10:51 AM, Igor Dovgiy ivd.pri...@gmail.comwrote: Oh my, of course it should be... my @repeated = grep { /some

problem with passing variables

2011-12-30 Thread Mark Haney
I'm not sure if this is the right list for this, so bear with me. If it isn't I'll be glad to post it on the correct one. I've got a problem with passing variables to a SQL server inside a CGI script. My code is like this: my $begin_time = 2011-11-16 11:00:00; my $end_time = 2011-11-16

Review: Perl for Perl Newbies Part 5 - Good Programming Practices

2011-12-30 Thread Shlomi Fish
Hi all, I've finally finished writing the 5th part of Perl for Perl Newbies: http://www.shlomifish.org/lecture/Perl/Newbies/lecture5/ I'd like people on this list to review it, and comment. Note that the series of presentations was also directed at absolute beginners (though I may not have been

Re: problem with passing variables

2011-12-30 Thread Igor Dovgiy
Hi Mark, If your variables are strictly internal and by no means might be ever tainted (read: user input), what you're doing is mostly ok. But you need to quote the dates passed within query itself, like this: my $sql = qq/SELECT * FROM `events` WHERE `date` BETWEEN '$begin_time' AND

Re: problem with passing variables

2011-12-30 Thread Shlomi Fish
On Fri, 30 Dec 2011 12:08:50 -0500 Mark Haney ma...@abemblem.com wrote: I'm not sure if this is the right list for this, so bear with me. If it isn't I'll be glad to post it on the correct one. I've got a problem with passing variables to a SQL server inside a CGI script. My code is

Re: problem with passing variables

2011-12-30 Thread Mark Haney
On 12/30/2011 12:30 PM, Igor Dovgiy wrote: Hi Mark, If your variables are strictly internal and by no means might be ever tainted (read: user input), what you're doing is mostly ok. But you need to quote the dates passed within query itself, like this: my $sql = qq/SELECT * FROM `events`

Re: problem with passing variables

2011-12-30 Thread Shlomi Fish
Hi Mark, On Fri, 30 Dec 2011 12:39:04 -0500 Mark Haney ma...@abemblem.com wrote: On 12/30/2011 12:30 PM, Igor Dovgiy wrote: Hi Mark, If your variables are strictly internal and by no means might be ever tainted (read: user input), what you're doing is mostly ok. But you need to quote

Re: problem with passing variables

2011-12-30 Thread Igor Dovgiy
If you pass into SQL query something assigned by user, use placeholders by all means. ) It's not that hard, but it'll save you a lot of headaches, believe me. ) 2011/12/30 Mark Haney ma...@abemblem.com But there's another (and in my opinion, usually better) way: using prepared sql statement:

What is the $_ variable?

2011-12-30 Thread Harry
I am confused what this variable does: $_ If someone could give an example or explanation of what this variable $_ does in perl, that would be great! Thanx. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org

Re: File Size Script Help - Working Version

2011-12-30 Thread Brandon McCaig
On Thu, Dec 29, 2011 at 03:43:19PM +, Jonathan Harris wrote: Hi All Hello Jonathan: (Disclaimer: I stayed up all night playing Skyrim and am running on about 4.5 hours of sleep.. ^_^) I think most things have already been addressed, but I think Igor might have had a bit of trouble making

Re: What is the $_ variable?

2011-12-30 Thread Shlomi Fish
Hello Harry, On Fri, 30 Dec 2011 10:03:30 -0800 (PST) Harry kaichow...@gmail.com wrote: I am confused what this variable does: $_ If someone could give an example or explanation of what this variable $_ does in perl, that would be great! $_ is the default variable, which gets assigned to

Re: problem with passing variables

2011-12-30 Thread Mark Haney
On 12/30/2011 12:50 PM, Igor Dovgiy wrote: If you pass into SQL query something assigned by user, use placeholders by all means. ) It's not that hard, but it'll save you a lot of headaches, believe me. ) 2011/12/30 Mark Haney ma...@abemblem.com mailto:ma...@abemblem.com But there's

Re: problem with passing variables

2011-12-30 Thread Shlomi Fish
Hi Mark, On Fri, 30 Dec 2011 14:19:04 -0500 Mark Haney ma...@abemblem.com wrote: On 12/30/2011 12:50 PM, Igor Dovgiy wrote: If you pass into SQL query something assigned by user, use placeholders by all means. ) It's not that hard, but it'll save you a lot of headaches, believe me. )

Re: File Size Script Help - Working Version

2011-12-30 Thread Jonathan Harris
On Fri, Dec 30, 2011 at 7:11 PM, Brandon McCaig bamcc...@gmail.com wrote: On Thu, Dec 29, 2011 at 03:43:19PM +, Jonathan Harris wrote: Hi All Hello Jonathan: (Disclaimer: I stayed up all night playing Skyrim and am running on about 4.5 hours of sleep.. ^_^) I think most things have

Re: File Size Script Help - Working Version

2011-12-30 Thread Igor Dovgiy
Great work, Jonathan! Notice how simple your script has become - and that's a good sign as well in Perl. :) We can make it even simpler, however. As you probably know, Perl has two fundamental types of collections: arrays (where data is stored as a sequence of elements, data chunks) and hashes

Re: File Size Script Help - Working Version

2011-12-30 Thread John W. Krahn
Igor Dovgiy wrote: Great work, Jonathan! Notice how simple your script has become - and that's a good sign as well in Perl. :) We can make it even simpler, however. As you probably know, Perl has two fundamental types of collections: arrays (where data is stored as a sequence of elements, data