Extracting text (Perl)
The split()
function gives
cut
functionality to Perl.
Usage: split('delimeter',input,max_no_of_fields);
Example
Cycle through the output of a find command and output the second dir and
put them into the array @dirnames
:
open(TIMELINE_PIPE,"find www/ -type f -name *.jp* -mtime 6|");
my $i=0;my @dirnames;
while (<TIMELINE_PIPE>) {
chomp;
my @dir1 = split('/',$_,3);
my $dir2 = $name1[1];
print "$dir2\
";
push @dirnames, $dir2
}