Hello - I have a script that reads in a file. Each line in the file is a directory path and a filename.
I'd like to be able to loop through the directories and replace the backslash with a pipe so that each directory would be delimited.
Here's a snippet :
use File::Spec::Win32;
while (<INPUT>) {
#split the on pipe
($Name,$Size,$LastChangeDate,$LastAccessDate,$CreatedDate,$Exte
+nsion,$Path) = split(/\|/, $_);
(my $volume, my $directories, my $file ) = File::Spec::Win32->s
+plitpath( $Path );
my @dirs = File::Spec::Win32->splitdir($directories);
print "@dirs|$Name";
print "\n";
The input looks like this :
AR2007-37.doc|49152|6/28/2007 3:50:28 PM|4/23/2015 3:52:23 AM|5/30/2007 2:48:25 PM|.doc|h:\shares\ca\ACTION-REQUESTS\ACTION-REQUEST-ARCHIVES\ACTION-REQUEST-FILES-2007\
and the output from my script looks like this :
shares ca ACTION-REQUESTS ACTION-REQUEST-ARCHIVES ACTION-REQUEST-FILES-2007 |AR2007-65.doc
I would like to insert a character delimiting each directory in the output.
I'm not sure how to access each element in the @dirs to be aboe to do this.
Help appreciated!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.