
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Backstick Operator in Perl
This simplest way of executing any Unix command in Perl Program is by using backstick operator. You simply put your command inside the backstick operator, which will result in execution of the command and returns its result which can be stored as follows −
#!/usr/bin/perl @files = `ls -l`; foreach $file (@files) { print $file; } 1;
When the above code is executed, it lists down all the files and directories available in the current directory −
drwxr-xr-x 3 root root 4096 Sep 14 06:46 9-14 drwxr-xr-x 4 root root 4096 Sep 13 07:54 android -rw-r--r-- 1 root root 574 Sep 17 15:16 index.htm drwxr-xr-x 3 544 401 4096 Jul 6 16:49 MIME-Lite-3.01 -rw-r--r-- 1 root root 71 Sep 17 15:16 test.pl drwx------ 2 root root 4096 Sep 17 15:11 vAtrJdy
- Related Questions & Answers
- The ? : Operator in Perl
- The Match Operator in Perl
- The Substitution Operator in Perl
- The Translation Operator in Perl
- Comments in Perl
- Whitespaces in Perl
- Dereferencing in Perl
- Sorting Arrays in Perl
- Merging Arrays in Perl
- Creating Hashes in Perl
- Escaping Characters in Perl
- Creating Variables in Perl
- Multiline Strings in Perl
- V-Strings in Perl
- Array Size in Perl
Advertisements