Join strings : join « String « Perl






Join strings

   

#!/usr/bin/perl
use warnings;
use strict;
my $passwd = "A:B:1:2::/dir:/bin/bash";
my @fields = split /:/, $passwd;
print "Login name : $fields[0]\n";
print "User ID : $fields[2]\n";
print "Home directory : $fields[5]\n";
my $passwd2 = join "#", @fields;
print "Original password : $passwd\n";
print "New password : $passwd2\n";

   
    
    
  








Related examples in the same category

1.Takes its input and joins it into a single string.
2.Join the mapped value
3.Join the result of the split function
4.Join variables
5.Join with
6.Join with 'map chr'
7.Join with 'map lc'
8.Joining string with empty string