>>>>>>>>>>>>>>>>>> Code >>>>>>>>>>>>>
user File::Path;
mkpath('Level1/Level2/Level3'); # Create all directories tree Level1-->Level2-->Level3
rmtree('Level1/Level2/Level3'); # Delete all directory tree
Search for Tips & Tricks
Showing posts with label Tips. Show all posts
Showing posts with label Tips. Show all posts
Friday, January 18, 2008
Thursday, January 10, 2008
How to return reference to a File Handle from Subroutine
>>>>>>>>>>>>>>> Code >>>>>>>>>>>
my $FH = returnFileHandle();
print $FH "Hello, World";
sub returnFileHandle {
my $fileName = "file.txt";
open (FILEHANDLE, ">$fileName") or die $!;
return \*FILEHANDLE;
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
The subroutine returnFileHandle() returns file handle (in overwrite mode) of file "file.txt".
my $FH = returnFileHandle();
print $FH "Hello, World";
sub returnFileHandle {
my $fileName = "file.txt";
open (FILEHANDLE, ">$fileName") or die $!;
return \*FILEHANDLE;
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
The subroutine returnFileHandle() returns file handle (in overwrite mode) of file "file.txt".
Thursday, January 3, 2008
How to delete files in Perl ?
>>> Code >>>>>>
@fileList = (”file1.txt”,”file2.pl”,”file3.java”);
unlink @filelist;
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
The above code will delete files in fileList arry from current directory. If you want to remove files from a specific directory first use “chdir
Subscribe to:
Posts (Atom)