This function deletes the files specified by LIST, or the file specified by $_ otherwise. Be careful while using this function because there is no recovering once a file gets deleted.
Following is the simple syntax for this function −
unlink LIST unlink
This function returns the number of files deleted.
Following is the example code showing its basic usage, create two files t1.txt and t2.txt in /tmp directory and then use the following program to delete these two files −
#!/usr/bin/perl -w unlink( "/tmp/t1.txt", "/tmp/t2.txt" );
When above code is executed, it produces the following result −
Both the files t1.txt and t2.txt will be deleted from /tmp.