For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > February 2006 > whitespace beginning and end









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author whitespace beginning and end
DBSMITH@OhioHealth.com

2006-02-22, 6:56 pm

Perlers

I need to remove any line that begins with \d+ yet end with \s*
Here is the data

_BEGIN_DATA_

0 2005/09/23 17:25 221 100% -il-o-b---U- sf F02043
1 2005/06/03 04:11 524 100% -il-o-b---U- sf F02017
2 2005/06/10 00:12 592 100% -il-o-b---U- sf F02018
3 2005/06/12 12:36 513 100% -il-o-b---U- sf H02001
4 2005/03/05 05:11 766 100% -il-o-b---U- sf F02000
5 2005/02/16 07:07 696 100% -il-o-b---U- sf F02003
6 2005/02/26 02:02 604 100% -il-o-b---U- sf F02004
7 2005/03/15 02:56 166 100% -il-o-b---U- sf H02003
8 2005/03/12 05:30 750 100% -il-o-b---U- sf F02002
9 2005/03/19 23:27 645 100% -il-o-b---U- sf F02005
10 2005/03/20 16:46 432 100% -il-o-b---Uf sf F02006
11 2005/03/24 03:59 121 100% -il-o-b---U- sf H02004
12 2006/01/22 18:21 204 100% -il-o-b---U- sf F02060
13 2006/01/25 13:55 400 100% -il-o-b---U- sf H02056
14 2005/06/17 06:45 484 100% -il-o-b---U- sf F02019
15 2005/03/24 04:03 119 100% -il-o-b---U- sf H02008
16 2005/03/24 04:05 139 100% -il-o-b---U- sf H02009
17 2005/03/24 04:02 125 100% -il-o-b---U- sf H02007
18 2005/08/14 16:54 101 100% -il-o-b---U- sf H02043
19 2005/06/23 04:53 487 100% -il-o-b---U- sf F02020
20 2005/09/29 07:43 281 100% -il-o-b---U- sf F02041
21 2005/04/02 22:48 592 100% -il-o-b---U- sf F02013
22 2005/04/06 07:17 352 100% -il-o-b---U- sf H02019
23 2005/04/10 01:38 631 100% -il-o-b---U- sf F02014
24 2005/04/18 06:56 665 100% -il-o-b---U- sf F02015
25 2005/04/21 07:28 251 100% -il-o-b---U- sf H02020
26 2005/04/24 09:42 282 100% -il-o-b---U- sf H02022
27 2005/04/27 04:36 603 100% -il-o-b---U- sf F02016
28 2005/04/29 01:50 576 100% -il-o-b---U- sf F02007
29 2005/05/04 04:41 569 100% -il-o-b---U- sf F02008
30 2005/06/30 05:17 428 100% -il-o-b---U- sf F02022
31 2005/05/09 17:43 421 100% -il-o-b---U- sf H02023
32 2005/05/12 04:09 498 100% -il-o-b---U- sf F02009
33 2005/06/25 08:35 100 100% -il-o-b---U- sf H02002
34 2005/08/22 15:38 152 100% -il-o-b---U- sf H02044
35 2005/06/30 19:32 224 100% -il-o-b---U- sf H02024
36 2005/08/24 19:01 354 100% -il-o-b---U- sf F02037
37 2005/07/06 12:57 476 100% -il-o-b---U- sf F02023
38 2005/07/06 21:32 153 100% -il-o-b---U- sf H02025
39 2005/05/25 09:03 191 100% -il-o-b---U- sf H02026
40 2005/06/02 18:17 183 100% -il-o-b---U- sf H02027
41 2005/06/14 14:13 97 100% -il-o-b---U- sf H02029
42 2005/06/09 14:20 208 100% -il-o-b---U- sf H02030
43 2005/06/22 08:04 212 100% -il-o-b---U- sf H02031
44 2005/05/19 02:47 407 100% -il-o-b---U- sf F02010
45 2005/06/27 20:56 114 100% -il-o-b---U- sf H02032
46 2005/07/01 10:07 111 100% -il-o-b---U- sf H02033
47 2005/07/08 11:49 196 100% -il-o-b---U- sf H02021
48 2005/07/10 09:26 26 100% -il-o-b---U- sf H02028
49 2005/07/13 05:06 421 100% -il-o-b---U- sf F02024
50 2005/07/18 09:17 403 100% -il-o-b---U- sf F02025
51 2005/07/20 17:28 179 100% -il-o-b---U- sf H02034
52 2005/07/23 15:09 333 100% -il-o-b---U- sf F02026
53 2005/07/29 10:24 379 100% -il-o-b---U- sf F02027
54 2005/07/29 11:58 509 100% -il-o-b---U- sf F02011
55 2005/08/04 05:00 68 100% -il-o-b---U- sf H02042
56 2005/08/15 16:53 93 100% -il-o-b---U- sf H02038
57 2005/08/05 11:12 335 100% -il-o-b---U- sf H02035
58 2005/08/05 18:06 61 100% -il-o-b---U- sf H02036
59 2005/08/08 20:55 435 100% -il-o-b---U- sf F02029
60 2005/08/17 20:42 351 100% -il-o-b---U- sf F02028
61 2005/08/11 16:10 199 100% -il-o-b---U- sf H02037
62 2005/09/04 18:04 78 100% -il-o-b---U- sf H02049
63 2005/09/07 01:35 339 100% -il-o-b---U- sf F02039
64 2005/09/07 11:10 323 100% -il-o-b---U- sf F02030
65 2005/08/31 13:06 267 100% -il-o-b---U- sf F02038
66 2005/09/01 20:16 228 100% -il-o-b---U- sf H02045
67 2005/09/11 13:02 202 100% -il-o-b---U- sf H02050
68 2005/09/12 10:30 82 100% -il-o-b---U- sf H02046
69 2005/09/13 08:44 340 100% -il-o-b---U- sf F02040
70 2005/09/19 09:03 310 100% -il-o-b---U- sf F02042
71 2005/10/04 12:42 286 100% -il-o-b---U- sf F02031
72 2005/10/07 17:12 524 100% -il-o-b---U- sf H02053
73 2005/10/10 13:23 288 100% -il-o-b---U- sf F02044
74 none 0 0% -il-o------- sf H02005
75 2005/10/14 15:26 234 100% -il-o-b---U- sf F02032
76 2005/10/19 20:12 256 100% -il-o-b---U- sf F02033
77 2005/10/25 11:46 273 100% -il-o-b---U- sf F02034
78 2005/10/30 18:15 260 100% -il-o-b---U- sf F02035
79 2005/11/02 14:28 521 100% -il-o-b---U- sf H02047
80 2005/11/04 01:57 56 100% -il-o-b---U- sf H02048
81 none 0 0% -il-o------- sf H02006
82 2005/11/05 13:08 206 100% -il-o-b---U- sf F02045
83 2005/11/08 04:27 80 100% -il-o-b---U- sf H02051
84 2005/11/11 10:46 195 100% -il-o-b---U- sf F02046
85 2005/11/18 13:58 225 100% -il-o-b---U- sf F02047
86 2005/11/25 12:02 284 100% -il-o-b---U- sf F02036
87 2005/11/26 12:05 202 100% -il-o-b---U- sf F02048
88 2005/12/02 13:00 212 100% -il-o-b---U- sf F02049
89 2005/12/07 13:40 214 100% -il-o-b---U- sf F02050
90 2005/12/16 14:57 208 100% -il-o-b---U- sf F02052
91 2005/12/18 07:11 236 100% -il-o-b---U- sf F02051
92 2005/12/23 18:49 225 100% -il-o-b---U- sf F02054
93 2005/12/29 14:00 466 100% -il-o-b---U- sf H02055
94 2005/12/30 14:54 277 100% -il-o-b---U- sf F02055
95 2005/12/30 18:04 15 100% -il-o-b---U- sf F02056
96 2005/12/30 18:18 379 100% -il-o-b---U- sf H02054
97
98 2006/01/09 23:15 220 100% -il-o-b---U- sf F02058
99
100 2006/01/16 10:14 215 100% -il-o-b---U- sf F02059
101
103 2006/01/28 02:27 156 100% -il-o-b---U- sf F02061
104 2006/01/28 03:45 248 100% -il-o-b---U- sf F02057
105 2006/01/29 21:53 260 100% -il-o-b---U- sf H02052
106 2006/02/03 13:26 201 100% -il-o-b---U- sf F02062
107 2006/02/09 14:50 194 100% -il-o-b---U- sf F02063
108 2006/02/17 09:48 171 100% -il-o-b---U- sf F02064
109
110 2006/02/18 00:26 273 100% -il-o-b---U- sf H02000
111 2006/02/20 06:15 204 100% -il-o-b---U- sf F02021

_END_DATA_


Here is what I came up with and it works but any other ideas b/c I am
unsure for every line with "2006/01/16 10:14 215 100% -il-o-b---U- sf
F02059"
for example will have a length of 62 or more.
thank you!



use strict;
use warnings;

open (L999, "samcmd v4 999 |" ) or die "unable to open pipe... Broken? $!";
for (;<L999>;) {
if ($lc > 7) {
if (length $_ >= 62) {
print $_;
}
#y{-,%,[ilbodsgfER]}//d;
#$ns=substr($_,30);
#$fa[$O++] = $ns if (substr($ns, 1,3) == 100);
}
$lc++;
}


Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams


Timothy Johnson

2006-02-22, 6:56 pm


Do you mean like


unless($_ =3D~ /^\s*\d+\s*$/){
print $_;
}
=09
?


-----Original Message-----
From: DBSMITH@OhioHealth.com [mailto:DBSMITH@OhioHealth.com]=20
Sent: Wednesday, February 22, 2006 2:36 PM
To: beginners@perl.org
Subject: whitespace beginning and end

Perlers

I need to remove any line that begins with \d+ yet end with \s*
Here is the data

_BEGIN_DATA_

<snip>

_END_DATA_


Here is what I came up with and it works but any other ideas b/c I am
unsure for every line with "2006/01/16 10:14 215 100% -il-o-b---U-
sf
F02059"
for example will have a length of 62 or more.
thank you!



<snip code>


DBSMITH@OhioHealth.com

2006-02-22, 6:56 pm







Do you mean like


unless($_ =~ /^\s*\d+\s*$/){
print $_;
}

?


-----Original Message-----
From: DBSMITH@OhioHealth.com [mailto:DBSMITH@OhioHealth.com]
Sent: Wednesday, February 22, 2006 2:36 PM
To: beginners@perl.org
Subject: whitespace beginning and end

Perlers

I need to remove any line that begins with \d+ yet end with \s*
Here is the data

_BEGIN_DATA_

<snip>

_END_DATA_


Here is what I came up with and it works but any other ideas b/c I am
unsure for every line with "2006/01/16 10:14 215 100% -il-o-b---U-
sf
F02059"
for example will have a length of 62 or more.
thank you!



<snip code>


BEGIN NEW RESPONSE
*******************
yes that will do it!


thank you



Wagner, David --- Senior Programmer Analyst --- WG

2006-02-22, 6:56 pm

DBSMITH@OhioHealth.com wrote:
> Perlers
>=20
> I need to remove any line that begins with \d+ yet end with \s*
> Here is the data
>=20
> _BEGIN_DATA_
>=20
> 0 2005/09/23 17:25 221 100% -il-o-b---U- sf F02043
> 72 2005/10/07 17:12 524 100% -il-o-b---U- sf H02053
> 73 2005/10/10 13:23 288 100% -il-o-b---U- sf F02044
> 74 none 0 0% -il-o------- sf H02005
> 75 2005/10/14 15:26 234 100% -il-o-b---U- sf F02032
> 76 2005/10/19 20:12 256 100% -il-o-b---U- sf F02033
> 77 2005/10/25 11:46 273 100% -il-o-b---U- sf F02034
> 96 2005/12/30 18:18 379 100% -il-o-b---U- sf H02054
> 97
> 98 2006/01/09 23:15 220 100% -il-o-b---U- sf F02058
> 99
> 100 2006/01/16 10:14 215 100% -il-o-b---U- sf F02059
> 101
> 103 2006/01/28 02:27 156 100% -il-o-b---U- sf F02061
> 104 2006/01/28 03:45 248 100% -il-o-b---U- sf F02057
> 105 2006/01/29 21:53 260 100% -il-o-b---U- sf H02052
> 106 2006/02/03 13:26 201 100% -il-o-b---U- sf F02062
> 107 2006/02/09 14:50 194 100% -il-o-b---U- sf F02063
> 108 2006/02/17 09:48 171 100% -il-o-b---U- sf F02064
> 109
> 110 2006/02/18 00:26 273 100% -il-o-b---U- sf H02000
> 111 2006/02/20 06:15 204 100% -il-o-b---U- sf F02021
>=20
> _END_DATA_
>=20
>=20
> Here is what I came up with and it works but any other ideas b/c I am
> unsure for every line with "2006/01/16 10:14 215 100% -il-o-b---U-
> sf F02059"
> for example will have a length of 62 or more.
> thank you!
>=20
>=20
>=20
> use strict;
> use warnings;
>=20
> open (L999, "samcmd v4 999 |" ) or die "unable to open pipe...
> Broken? $!"; for (;<L999>;) {
> if ($lc > 7) {

is the format for the end of line constant? That is annnnn like F020021, e=
te.=20
Then could do=20
1) /\b[a-z]\d{5}$/i or=20
2) ! /^\s+\d+\s*$/=20
Either of the regex would replace the two ifs to be one.

Wags ;)

> if (length $_ >=3D 62) {
> print $_;
> }
> #y{-,%,[ilbodsgfER]}//d;
> #$ns=3Dsubstr($_,30);
> #$fa[$O++] =3D $ns if (substr($ns, 1,3) =3D=3D 100);
> }
> $lc++;
> }
>=20
>=20
> Derek B. Smith
> OhioHealth IT
> UNIX / TSM / EDM Teams




****************************************
***************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************
***************

usenet@DavidFilmer.com

2006-02-22, 6:56 pm

DBSMITH@OhioHealth.com wrote:
> I need to remove any line that begins with \d+ yet end with \s*


Then why are you using length()?

if ($line !~ /^\d+.*\s*/$) {
# whatever...
}

FWIW, the \s* will always succeed, since that says to match zero or
more times. So, in effect, the regexp only matches lines beginning with
digits. If you want to force whitespace match at the end of the line,
use \s+ instead of \s*.

--
http://DavidFilmer.com

John W. Krahn

2006-02-23, 3:55 am

DBSMITH@OhioHealth.com wrote:
> Perlers


Hello,

> I need to remove any line that begins with \d+ yet end with \s*


EVERY line ends with \s* so you want to remove every line?


John
--
use Perl;
program
fulfillment
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com