rrlobster has asked for the wisdom of the Perl Monks concerning the following question:
I want to modify this line:
# Erase the leading spaces and parenthetical values. #for (@t){s/^ +//;s/\(\)//g};
so that for each line in the array, it also truncates all text from " / " (space-slash-space) to the end of the line.
In other words the line:should becomeWindchill 17º F / -8º C
My stab in the dark was this:Windchill 17º F
But I obviously do not know what I'm doing -- I know some basic Regex and Unix but not Perl...for (@t){s/^ +//;s/\(\)//g;s/^\([^\ \/\ ]*\)\ \/\ .*/\1/p};
Thanks for your indulgence.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: truncate line starting with multi-char delimiter
by ikegami (Patriarch) on Jan 10, 2010 at 17:08 UTC | |
by rrlobster (Initiate) on Jan 10, 2010 at 17:20 UTC |