Re: 'rmm' (or 'trash') script

2003-10-26 Thread Steve Grazzini
On Sat, Oct 25, 2003 at 12:17:37PM +0200, Kevin Pfeiffer wrote: > In article <[EMAIL PROTECTED]>, David wrote: >> 4. you have: >> >> unless (-e $path) { >> print "Creating trash directory: $path\n"; >> mkdir $path or die "Couldn't create $path: $!\n"; >> } >> >> don't do this for a gene

RE: Array Reference Practice Help

2003-10-26 Thread Charles K. Clarkson
Jakob Lell <[EMAIL PROTECTED]> wrote: : : you can use prototypes to pass array references. : see perldoc perlsub for more details. : : sub showIt([EMAIL PROTECTED]@); : my @alpha=("a","b","c"); : my @numer=(1,2,3); : showIt(@alpha,@numer); : sub showIt([EMAIL PROTECTED]@) : { : my($a,$b) = @

Re: how to pass multi array as args

2003-10-26 Thread Rob Dixon
<[EMAIL PROTECTED]> wrote: > > > sub mysub { > > my( $x, $y, $z ) = @_; > > Can I have three arrays instead? > > I know I can use $x->[0], $x->[1], etc. But can I make it a @x, @y, @z? If you prototype your subroutine as sub mysub ([EMAIL PROTECTED]@\@) then you can subsequently ca

Re: Array Reference Practice Help

2003-10-26 Thread Jakob Lell
On Sunday 26 October 2003 10:35, [EMAIL PROTECTED] wrote: > Is this a standard/normal/ok way to pass and use array by reference? > > @alpha=("a","b","c"); > @numer=(1,2,3); > > #calling by reference > showIt([EMAIL PROTECTED], [EMAIL PROTECTED]); > > sub showIt > { my $a = $_[0]; #assinging by ref

Re: RE : SQL Syntax quickie

2003-10-26 Thread dan
The MAX(id) didn't return anything, i eventually settled for an idea posted to SELECT id FROM memodata ORDER BY id DESC then take the first line value and ignore the rest. Ideally though i want the last line with the highest id number. I know for a fact that another INSERT won't happen before the S

RE: how to pass multi array as args

2003-10-26 Thread Charles K. Clarkson
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: : : > sub mysub { : > my( $x, $y, $z ) = @_; : : Can I have three arrays instead? : : I know I can use $x->[0], $x->[1], etc. But can I make : it a @x, @y, @z? Question: If this is all that is relevant to your question, why continu

Re: initializing a closure variable

2003-10-26 Thread Rob Dixon
Kevin Pfeiffer wrote: > > In article <[EMAIL PROTECTED]>, Rob Dixon wrote: > > > Kevin Pfeiffer wrote: > >> > >> I would have thought that this would initialize my $indent variable to 2 > >> (like setting an initial state for an object), but if I call "indent()" I > >> get nothing back. :-( > [...]

RE: how to pass multi array as args

2003-10-26 Thread Charles K. Clarkson
Max <[EMAIL PROTECTED]> wrote: : : I test this and it works, there must be some other : way, but i am only a newbie on perl, : : mysub("@a", "@b", "@c"); : : sub mysub { : my @a = shift; : my @b = shift; : my @c = shift; : } Let's try a little test: #!/usr/bin/perl use strict; use

initializing a closure variable

2003-10-26 Thread Kevin Pfeiffer
Hi Perlers, I would have thought that this would initialize my $indent variable to 2 (like setting an initial state for an object), but if I call "indent()" I get nothing back. :-( { # static local variable my $indent = 2; sub indent { my $increment = shift; $indent += $incre

Re: initializing a closure variable

2003-10-26 Thread Rob Dixon
Kevin Pfeiffer wrote: > > I would have thought that this would initialize my $indent variable to 2 > (like setting an initial state for an object), but if I call "indent()" I > get nothing back. :-( > > > { # static local variable >my $indent = 2; > >sub indent { > my $increment = sh

Re: initializing a closure variable

2003-10-26 Thread Kevin Pfeiffer
In article <[EMAIL PROTECTED]>, Rob Dixon wrote: > Kevin Pfeiffer wrote: >> >> I would have thought that this would initialize my $indent variable to 2 >> (like setting an initial state for an object), but if I call "indent()" I >> get nothing back. :-( [...] > Well yes, it will, but only when you

Re: RE : SQL Syntax quickie

2003-10-26 Thread Tore Aursand
On Sun, 26 Oct 2003 13:40:20 +, dan wrote: > The MAX(id) didn't return anything [...] Are you sure about that? Generally, MAX(id) _always_ returns something, ie: SELECT MAX(user_id) FROM user This one will return the highest 'user_id' value, _or_ 0 if there are no records in the 'user' ta

Re: Array Reference Practice Help

2003-10-26 Thread Tore Aursand
On Sun, 26 Oct 2003 01:35:47 -0800, perl wrote: > Is this a standard/normal/ok way to pass and use array by reference? Almost, I would say. > #calling by reference > showIt([EMAIL PROTECTED], [EMAIL PROTECTED]); > > sub showIt > { my $a = $_[0]; #assinging by reference > my $b = $_[1]; > > p

Re: finding syntax errors

2003-10-26 Thread Kevin Pfeiffer
In article <[EMAIL PROTECTED]>, Kevin Pfeiffer wrote: > I've painted myself into a corner I can't get out of... > > Missing right curly or square bracket at /home/pfeiffer/bin/trash line > 341, at end of line > syntax error at /home/pfeiffer/bin/trash line 341, at EOF > Execution of /home/pfeiffe

finding syntax errors

2003-10-26 Thread Kevin Pfeiffer
I've painted myself into a corner I can't get out of... Missing right curly or square bracket at /home/pfeiffer/bin/trash line 341, at end of line syntax error at /home/pfeiffer/bin/trash line 341, at EOF Execution of /home/pfeiffer/bin/trash aborted due to compilation errors. Line 341 is, of cou

Re: initializing a closure variable

2003-10-26 Thread Jeff 'japhy' Pinyan
On Oct 26, Kevin Pfeiffer said: >> { >> my $indent = 2; >> >> sub indent { >> my $increment = shift; >> $indent += $increment if $increment; >> return $indent; >> } >> } > >Hmmm, I guess I would have to move it up or add a "BEGIN" label. Using a BEGIN block isn't a bad idea; jus

Re: 'rmm' (or 'trash') script

2003-10-26 Thread David T-G
Kevin, et al -- ...and then Kevin Pfeiffer said... % % Hi all, Hi! % % I just took another look at an exercise I wrote a couple months ago and % fleshed it out a bit. It is a commandline "trashcan" program which I % actually use. Instead of typing 'rm' I almost always use 'rmm' now. I like t

Re: how to pass multi array as args

2003-10-26 Thread Max
I test this and it works, there must be some other way, but i am only a newbie on perl, > mysub(@a, @b, @c); mysub("@a", "@b", "@c"); > sub mysub > { my @a = ? #arg1 an array $_[0] is not working > my @b = ? arg2 another array $_[1] is not working > my @c = ? arg3 another array $_[2] is n

RE: how to pass multi array as args

2003-10-26 Thread perl
> sub mysub { > my( $x, $y, $z ) = @_; Can I have three arrays instead? I know I can use $x->[0], $x->[1], etc. But can I make it a @x, @y, @z? -thanks > [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] wrote: > : > : Can someone show me how to pass multiple arrays argument? > : > : ie -

Array Reference Practice Help

2003-10-26 Thread perl
Is this a standard/normal/ok way to pass and use array by reference? @alpha=("a","b","c"); @numer=(1,2,3); #calling by reference showIt([EMAIL PROTECTED], [EMAIL PROTECTED]); sub showIt { my $a = $_[0]; #assinging by reference my $b = $_[1]; print "a[0]:" . $$a[0] . "\n"; #accessing by refer

RE: how to pass multi array as args

2003-10-26 Thread Tore Aursand
On Sun, 26 Oct 2003 01:52:21 -0700, perl wrote: >> sub mysub { >> my( $x, $y, $z ) = @_; > Can I have three arrays instead? Why would you have that? There are a lot of advantages by using references. -- Tore Aursand <[EMAIL PROTECTED]> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For a

Re: RE : SQL Syntax quickie

2003-10-26 Thread Tore Aursand
On Sun, 26 Oct 2003 06:30:11 +0100, SIMON Cedric wrote: > For your query, try "SELECT MAX(id) FROM table" > That works with mysql. That should "work" with most databases, but what happens if there's a new insert between the original insert and the SELECT statement above? This _could_ be solved b

Re: lowercase

2003-10-26 Thread David Storrs
Or you can even do it without the parens: $stri = lc $stri; --Dks On Fri, Oct 24, 2003 at 09:26:40PM -0700, [EMAIL PROTECTED] wrote: > or you can do $stri=lc($stri); > > -rkl > > > try this: > > $stri =~ tr/A-Z/a-z/; > > > > yi > > > > --- Andre Chaves Mascarenhas <[EMAIL PROTECTED]> wrote:

Re: Passing and returning values from another script?

2003-10-26 Thread David Storrs
On Fri, Oct 24, 2003 at 09:47:14AM -0800, Mark Weisman wrote: > I'm not sure, however I put the script mods in that you suggested, and > my $output is the word "SCRIPT", I would like clarification on line 2 if > you would please? > >my $output = join("", SCRIPT); > From: [EMAIL PROTECTED] [mailto: