home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!news.univie.ac.at!blekul11!frmop11!barilvm!vms.huji.ac.il!wisipc.weizmann.ac.il!menora.weizmann.ac.il
- dov
- Newsgroups: comp.lang.perl
- Subject: Re: stupid questions : deleted ing leading spaces
- Message-ID: <1992Sep7.092151.13593@wisipc.weizmann.ac.il>
- From: dov@menora.weizmann.ac.il (Dov Grobgeld)
- Date: Mon, 7 Sep 1992 09:21:51 GMT
- Sender: news@wisipc.weizmann.ac.il
- References: <1992Sep7.022351.1137@unilabs.uucp>
- Organization: Weizmann Institute of Science, Computation Center.
- Lines: 40
-
- chare@unilabs.uucp (Chris Hare) writes:
-
- You will probably be swamped with replies, but never mind...
-
- : This is stupid.
- :
- That's a perpetual truth of mankind.
-
- : I am running 4.035 and I need to delete a single leading space at the
- : beginning of a line.
- :
- : I would have thought that
- :
- : tr/^ //;
- :
- : would have worked since the line is in $_.
- :
- You want to use s/'source'/'target'/ which (s)ubstitutes the source to the
- target. tr/'list1'/'list2'/ (tr)anslates on a character to character basis
- the characters in list1 to the corresponding character in list2. What you
- want is
-
- s/^ //;
-
- : As a matter of ofact, if you can suggest a way to remove the leading
- : spaces, and compact multiple spaces any where else on the line to be one
- : space I'd appreciate it.
- :
- s/^\s+//; # Delete leading spaces (including tabs)
- s/ +/ /g; # Change all (that's the 'g') multiple spaces
- # to one space
-
- --
- ___ ___
- / o \ o \
- Dov Grobgeld ( o o ) o |
- The Weizmann Institute of Science, Israel \ o /o o /
- "Where the tree of wisdom carries oranges" | | | |
- _| |_ _| |_
-
-