cyberconte has asked for the wisdom of the Perl Monks concerning the following question:
Where @_ is just a line by line list of what smbclient returnssub parse{ my $path='\\'; my $computer = "LAIN"; foreach(@_) { # skip if it doesn't start with either a space or backslash next if (!/^[ \\]/); # check if path listing (starts with \) and if so, get the path if ($_=~/^(\\[\w|\s|\\]*\w+)/) { $path = $1.'\\'; } else { if (/^\s*(.*\S)\s{5,}([HDRSA]+)\s*(\d+)\s*(.*)/) { # dont include . or .. directories unless (($1 eq '.') or ($1 eq '..')) { my ($file,$att,$size,$date,$ext)=($1,$2,$3,$4); if ($file =~ /\.(.*)/) { $ext=$1; } else { $ext="DIR";} print "{$computer\:$path$file, $ext, $att, $size, $date }\ +n"; } } } } }
Edit kudra, 2002-04-19 Changed title per ntc request
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Meta aside
by Fletch (Bishop) on Apr 07, 2002 at 04:05 UTC | |
|
Re: Happy fun regexping
by graff (Chancellor) on Apr 07, 2002 at 06:38 UTC | |
by cyberconte (Scribe) on Apr 07, 2002 at 12:06 UTC | |
by grinder (Bishop) on Apr 08, 2002 at 12:06 UTC |