Re: Passing arguments to subroutine

2007-06-05 Thread Chas Owens
On 6/5/07, Brad Baxter <[EMAIL PROTECTED]> wrote: snip Apparently, unlike with named subs, both &$anon() and $anon->() ignore prototypes. However, like named subs &$anon gets the caller's @_. But that is almost never mentioned afaict at the places in the docs where the &$anon style call is used

Re: Passing arguments to subroutine

2007-06-05 Thread Brad Baxter
On Jun 1, 9:58 am, [EMAIL PROTECTED] (Chas Owens) wrote: > On 31 May 2007 10:58:54 -0700, Paul Lalli <[EMAIL PROTECTED]> wrote: > > > On May 31, 10:15 am, [EMAIL PROTECTED] (Yitzle) wrote: > > > I suspect one of the tutorials that Google or Perl.org points to has > > > something in it that needs co

Re: Passing arguments to subroutine

2007-06-01 Thread Chas Owens
On 31 May 2007 10:58:54 -0700, Paul Lalli <[EMAIL PROTECTED]> wrote: On May 31, 10:15 am, [EMAIL PROTECTED] (Yitzle) wrote: > I suspect one of the tutorials that Google or Perl.org points to has > something in it that needs correcting. Actually, it's an unfortunate truth that up until Edition 3,

Re: Passing arguments to subroutine

2007-06-01 Thread Rob Dixon
Paul Lalli wrote: On May 31, 9:35 am, [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote: On May 31, 9:27 am, [EMAIL PROTECTED] (Alma) wrote: # extract the file name # my @parts = split('\/',$file_path); Your split statement seems to be wrong. split uses a regex to match so it should be: s

Re: Passing arguments to subroutine

2007-06-01 Thread Paul Lalli
On May 31, 9:35 am, [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote: > On May 31, 9:27 am, [EMAIL PROTECTED] (Alma) wrote: > > > # extract the file name > > # my @parts = split('\/',$file_path); > Your split statement seems to be wrong. split uses a regex to match so > it should be: > > split /\

Re: Passing arguments to subroutine

2007-05-31 Thread [EMAIL PROTECTED]
On May 31, 9:27 am, [EMAIL PROTECTED] (Alma) wrote: > Hi All, > > I need to pass the result of prepare statement as an argument to the > subroutine. > > sub abc() > { > my $self= shift; > my($id,$title) = @_; > my $sth1= $databasehandle->prepare("select file_path from xyz >

Re: Passing arguments to subroutine

2007-05-31 Thread [EMAIL PROTECTED]
On May 31, 9:27 am, [EMAIL PROTECTED] (Alma) wrote: > sub delete_file() > { > my $self = shift; > my $file_path = @_; That sets $file_path to the number of arguments in the call to the method delete_file(). To set $file_path to the first of the arguments in the call to the method

Re: Passing arguments to subroutine

2007-05-31 Thread Paul Lalli
On May 31, 10:15 am, [EMAIL PROTECTED] (Yitzle) wrote: > I suspect one of the tutorials that Google or Perl.org points to has > something in it that needs correcting. Actually, it's an unfortunate truth that up until Edition 3, the Llama itself recommended that you use the & to call subroutines...

Re: Passing arguments to subroutine

2007-05-31 Thread Chas Owens
On 5/31/07, yitzle <[EMAIL PROTECTED]> wrote: snip I suspect one of the tutorials that Google or Perl.org points to has something in it that needs correcting. snip Probably more than one thing. I would suggest reading the following books to learn Perl and to only use random tutorials on the In

Re: Passing arguments to subroutine

2007-05-31 Thread yitzle
On 31 May 2007 01:27:26 -0700, Alma <[EMAIL PROTECTED]> wrote: -- snip -- unlink($file_path); -- snip -- I'm aware that the question was already answered, but a generic tip for the future. You could try adding a statement like: print "Deleting $file_path\n"; to help debug and ensure t

Re: Passing arguments to subroutine

2007-05-31 Thread Chas Owens
On 31 May 2007 01:27:26 -0700, Alma <[EMAIL PROTECTED]> wrote: snip &deleteposter_file(@row); snip sub delete_file() snip This would seem to be the problem, also where did you learn that you should put & on the front of your subroutine calls? I am curious because I keep seeing people

Re: Passing arguments to subroutine

2007-05-31 Thread Paul Lalli
On May 31, 4:27 am, [EMAIL PROTECTED] (Alma) wrote: > I need to pass the result of prepare statement as an argument to the > subroutine. > > sub abc() The () there very specifically say "This subroutine takes no arguments". > { > my $self= shift; > my($id,$title) = @_; ... and y

Re: Passing arguments to subroutine

2007-05-31 Thread Jonathan Lang
Alma wrote: Hi All, I need to pass the result of prepare statement as an argument to the subroutine. -snip- abc is calling delete_file() . where it need to delete the file stored at the location mentioned in file_path. Its not giving me an error but its not deleting the files from the locatio

Passing arguments to subroutine

2007-05-31 Thread Alma
Hi All, I need to pass the result of prepare statement as an argument to the subroutine. sub abc() { my $self= shift; my($id,$title) = @_; my $sth1= $databasehandle->prepare("select file_path from xyz where id='$id' and title like '$title'"); my $res = $sth1->exec