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 c

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 (wh

Re: File Size Script Help - Working Version

2011-12-30 Thread Jonathan Harris
On Fri, Dec 30, 2011 at 7:11 PM, Brandon McCaig 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 already b

Re: problem with passing variables

2011-12-30 Thread Shlomi Fish
Hi Mark, On Fri, 30 Dec 2011 14:19:04 -0500 Mark Haney 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. ) > > > > 2011/1

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 mailto:ma...@abemblem.com>> But there's another (and in my opi

Re: What is the $_ variable?

2011-12-30 Thread Shlomi Fish
Hello Harry, On Fri, 30 Dec 2011 10:03:30 -0800 (PST) Harry 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 and used in vario

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 i

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 http://learn.perl.org

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 > But there's another (and in my opinion, usually better) way: using > prepared sql statement: > my $sth = $dbh->

Re: problem with passing variables

2011-12-30 Thread Shlomi Fish
Hi Mark, On Fri, 30 Dec 2011 12:39:04 -0500 Mark Haney 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 the dat

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` WHER

Re: problem with passing variables

2011-12-30 Thread Shlomi Fish
On Fri, 30 Dec 2011 12:08:50 -0500 Mark Haney 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 like this: > > m

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 '$end_time'/

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 bee

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 1

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 wrote: > in this code what is the > $n =~ /$b/i; > > > On Fri, Dec 30, 2011 at 10:51 AM, Igor Dovgiy wrote: > >> Oh my, of course it should be... >> my @repeated = grep { /some regex here/ && ++$seen{$_} > N }

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 > Hi Xi, > > You're looking only for 'p' letters, not D and O? Why? > > Anyway, generic solution will be something like... > > my %see

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 dupl

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 wrote: > Xi Chen wrote: >> >> Hello everyone, >> >> I saw a code below to get two same letters "p" in @a. >> >> @

Re: File Size Script Help - Working Version

2011-12-30 Thread Jonathan Harris
On Fri, Dec 30, 2011 at 11:58 AM, Igor Dovgiy 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 collected 'result' > st

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 tar

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 va