- Perl Basics
- Perl - Home
- Perl - Introduction
- Perl - Environment
- Perl - Syntax Overview
- Perl - Data Types
- Perl - Variables
- Perl - Scalars
- Perl - Arrays
- Perl - Hashes
- Perl - IF...ELSE
- Perl - Loops
- Perl - Operators
- Perl - Date & Time
- Perl - Subroutines
- Perl - References
- Perl - Formats
- Perl - File I/O
- Perl - Directories
- Perl - Error Handling
- Perl - Special Variables
- Perl - Coding Standard
- Perl - Regular Expressions
- Perl - Sending Email
- Perl Advanced
- Perl - Socket Programming
- Perl - Object Oriented
- Perl - Database Access
- Perl - CGI Programming
- Perl - Packages & Modules
- Perl - Process Management
- Perl - Embedded Documentation
- Perl - Functions References
- Perl Useful Resources
- Perl - Questions and Answers
- Perl - Quick Guide
- Perl - Useful Resources
- Perl - Discussion
Perl link Function
Description
This function creates a new file name, NEWFILE, linked to the file OLDFILE. The function creates a hard link; if you want a symbolic link, use the symlink function.
Syntax
Following is the simple syntax for this function −
link OLDFILE,NEWFILE
Return Value
This function returns 0 on failure and 1 on success.
Example
Following is the example code showing its basic usage, this will create new file using existing file −
#!/usr/bin/perl $existing_file = "/usr/home/test1"; $new_file = "/usr/home/test2"; $retval = link $existing_file, $new_file ; if( $retval == 1 ) { print"Link created successfully\n"; } else { print"Error in creating link $!\n"; }
When above code is executed, it produces the following result −
Error in creating link No such file or directory
perl_function_references.htm
Advertisements