home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!bloom-beacon!eru.mt.luth.se!lunic!sunic!corax.udac.uu.se!irfu.se!jhd
- From: jhd@irfu.se (Jan D.)
- Newsgroups: comp.lang.perl
- Subject: Re: stupid questions : deleted ing leading spaces
- Message-ID: <1992Sep7.062649.20540@irfu.se>
- Date: 7 Sep 92 06:26:49 GMT
- References: <1992Sep7.022351.1137@unilabs.uucp>
- Organization: Swedish Institute of Space Physics, Uppsala, Sweden
- Lines: 33
-
- In article <1992Sep7.022351.1137@unilabs.uucp> chare@unilabs.uucp (Chris Hare) writes:
- >This is stupid.
- >
- >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 $_.
- >
- >But alas, it doesn't. There are other spaces in the line, but I don't want
- >them affected.
-
- I think you are confusing tr// and s// here. s/^ // works.
-
- >
- >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/ +/ /g;
-
- If you want to replace general white space (i.e. tabs and space) you should say
-
- s/^\s//;
- s/\s+/ /g;
-
-
- Jan D.
-