Is Perl Compatible with Unix Shell Scripting

twinbaby

Supremacy Member
Joined
Jul 8, 2014
Messages
5,418
Reaction score
1,499
Hi there,

Is perl compatible with Unix shell script. Is it possible to pipe the output of unix to perl and perl to unix? How similar are Perl and Unix syntax. If I am familiar with Unix awk, sed, grep is there any alternative in Perl?
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
Hi there,

Is perl compatible with Unix shell script. Is it possible to pipe the output of unix to perl and perl to unix? How similar are Perl and Unix syntax. If I am familiar with Unix awk, sed, grep is there any alternative in Perl?

Shell script and Perl are 2 different things. Where each are running in separate processes, in the realm of unix, you can communicate between these processes via IPC(e.g.: files, sockets, pipes signal, etc), Standard I/O streams (STDIN,STDOUT,STDERR).

You can have perl invoking the shell using exec, system, open, etc, or using shell script to invoke perl by calling "perl script.pl" or just invoking the script.pl if there is a shebang interpreter directive in the executable script.

Perl is a complete and very capable programming language, there is no direct dependencies with the unix, but it has features that are borrowed from many unix tools and concepts.

In Unix, you can pipe just about any programming languages, utilities or tools that can interact with standard streams.

You can effectively rewrite awk, sed, grep with Perl. Perl is far more comprehensive having it is a general purpose programming language. But you probably can't do the same inversely since Perl has a lot of features like closures, multiple scoping concepts and data typing which are not found in awk, sed or grep.

But you will find working with these tools having similar features found across one another since their development are in many ways influenced by each other.
 
Last edited:
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ Forums. Forum members and moderators are responsible for their own posts. Please refer to our Community Guidelines and Standards and Terms and Conditions for more information.
Top