PROBLEMS BELOW APPEAR SOLVED
I have one problem left to solve, appears straightforward, but my code is doing incomplete job of getting rid of bogus "current dir" characters -- i.e. changing "/./" to "/"
n00b perlmonk humbly requests grizzled old perlmonks if they can help. What the heck is the correct terminology for a n00b perlmonk anyway?
My comment and code follow
# D) Rid input files of all instances of the unix current directory symbol "/./"
# Example: /vobs/synergy_core_apps/code/./././personalize/src would be changed to
# /vobs/synergy_core_apps/code/personalize/src
$file_vep_cleaned =~ s/\/\.\//\//g;
=======================
I am getting started in adding sed to my Perl programs and would appreciate some help with these 2 sed problems.
I need to write a number of sed statements to clean up errors from input files consisting of clearcase directories and files of the form:
/vobs/dirname1/dirname2/dirname3/filename
or
/vobs/dirname1/dirname2/dirname3
I have completed all the needed sed statements except for two that are needed to clean up the following errors:
1) Convert duplicated front-slash markers to single front-slash markers, i.e.
/vobs/dirname1////dirname2//dirname3////filename
becomes
/vobs/dirname1/dirname2/dirname3/filename
I have tried to replace 2 or more "/"'s with a single "/" using
$filename =~ s/\/[\/]+/\//;
but the above statement does nothing.
What Perl sed syntax might be used to make this transformation?
2) Another error is to rid my input file of all instances of the unix parent directory symbol ".." - i.e.
/vobs/synergy_core_apps/code/../code/personalize/src
would be changed to
/vobs/synergy_core_apps/code/personalize/src
Does anyone know how this might be done using Perl sed syntax?
Thank You,
Amphaiaraus
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.