Wednesday, November 6, 2019

How to Use the Perl Array join() Function

How to Use the Perl Array join() Function The Perl programming language  join() function is used to connect all the elements of a specific list or array into a single string using a specified joining expression. The list is concatenated into one string with the specified joining element contained between each item. The syntax for the join() function is: join EXPR, LIST. Join() Function at Work In the following example code, EXPR uses three different values.  In one, it is a hyphen. In one, it is nothing, and in one, it is a comma and a space. #!/usr/bin/perl$string join( -, red, green, blue );printJoined String is $string\n;$string join( , red,  green,  blue  ); printJoined String is $string\n;$string  Ã‚  join(  , ,  red,  green,  blue  );printJoined String is $string\n; When the code is executed, it returns the following: Joined String is red-green-blueJoined String is redgreenblueJoined String is red, green, blue The EXPR is only placed between pairs of elements in LIST. It is not placed before the first element or after the last element in the string.   About Perl Perl,  which is an interpreted programming language, not a compiled language, was a mature programming language long before the web, but it became popular with website developers because most of the content on the web happens with text, and Perl is designed for text processing. Also, Perl is friendly and offers more than one way to do most things with the language.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.