greatshots has asked for the wisdom of the Perl Monks concerning the following question:
but I want the out put as ":a_b_c:", I changed the join as#!/usr/bin/perl my $string = "///a/b////c"; my @arr = split("\/*",$string); print ":" , join("_",@arr) , ":\n"; Output :- :_a_b_c:
But in the above join explicitly I am removing the 0 index from the array to avoid. Is there a standard way to chop this null string in split function itself.print ":" , join("_",@arr[1..$#arr]) , ":\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: question on perl's split function
by GrandFather (Saint) on Oct 22, 2007 at 09:31 UTC | |
|
Re: question on perl's split function
by moritz (Cardinal) on Oct 22, 2007 at 09:23 UTC | |
|
Re: question on perl's split function
by rminner (Chaplain) on Oct 22, 2007 at 09:27 UTC | |
|
Re: question on perl's split function
by Prof Vince (Friar) on Oct 22, 2007 at 10:00 UTC |