develooper Front page | perl.beginners | Postings from May 2007

Passing arguments to subroutine

Thread Next
From:
Alma
Date:
May 31, 2007 04:15
Subject:
Passing arguments to subroutine
Message ID:
1180600046.701654.45930@j4g2000prf.googlegroups.com
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->execute();

        my @row = $sth1->fetchrow_array;
        print @row;


        &deleteposter_file(@row);

}

#-----------------Deletes from the File system

sub delete_file()
{
        my $self = shift;
        my $file_path = @_;

# extract the file name
#       my @parts = split('\/',$file_path);
#       my $file =$parts[$#parts];
#       #unlink($file);
#       if( -e "file" ) {
#       system("rm $file_path");

        unlink($file_path);
}


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
location.

Any help.....

Thanks in advance.
Alma


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About