On Jun 28, 11:18 am, [EMAIL PROTECTED] (Luca Villa) wrote:
> I have a long text file like this:
>
> 324yellow
> 34house
> black
> 54532
> 15m21red56
> 44dfdsf8sfd23
>
> How can I obtain (Perl - Windows/commandline/singleline) the
> following?
>
> 1) only the numbers at the beginning before some alp
Luca Villa wrote:
> I have a long text file like this:
>
> 324yellow
> 34house
> black
> 54532
> 15m21red56
> 44dfdsf8sfd23
>
> How can I obtain (Perl - Windows/commandline/singleline) the
> following?
>
> 1) only the numbers at the beginning before some alpha text, like
> this:
>
> 324
> 34
>
Luca Villa schreef:
> I have a long text file like this:
>
> 324yellow
> 34house
> black
> 54532
> 15m21red56
> 44dfdsf8sfd23
>
> How can I obtain (Perl - Windows/commandline/singleline) the
> following?
>
> 1) only the numbers at the beginning before some alpha text, like
> this:
>
> 324
> 34
> 15
sisyphus wrote:
> On Jun 29, 1:18 am, [EMAIL PROTECTED] (Luca Villa) wrote:
>> I have a long text file like this:
>>
>> 324yellow
>> 34house
>> black
>> 54532
>> 15m21red56
>> 44dfdsf8sfd23
>>
>> How can I obtain (Perl - Windows/commandline/singleline) the
>> following?
>>
>> 1) only the numbers at
sisyphus wrote:
> On Jun 29, 1:18 am, [EMAIL PROTECTED] (Luca Villa) wrote:
>> I have a long text file like this:
>>
>> 324yellow
>> 34house
>> black
>> 54532
>> 15m21red56
>> 44dfdsf8sfd23
>>
>> How can I obtain (Perl - Windows/commandline/singleline) the
>> following?
>>
>> 1) only the numbers at
On Jun 29, 1:18 am, [EMAIL PROTECTED] (Luca Villa) wrote:
> I have a long text file like this:
>
> 324yellow
> 34house
> black
> 54532
> 15m21red56
> 44dfdsf8sfd23
>
> How can I obtain (Perl - Windows/commandline/singleline) the
> following?
>
> 1) only the numbers at the beginning before some alph
Luca Villa wrote:
I have a long text file like this:
324yellow
34house
black
54532
15m21red56
44dfdsf8sfd23
How can I obtain (Perl - Windows/commandline/singleline) the
following?
1) only the numbers at the beginning before some alpha text, like
this:
324
34
15
44
2) only the numbers within
Luca Villa wrote:
I have a long text file like this:
324yellow
34house
black
54532
15m21red56
44dfdsf8sfd23
How can I obtain (Perl - Windows/commandline/singleline) the
following?
1) only the numbers at the beginning before some alpha text, like
this:
324
34
15
44
2) only the numbers within
I have a long text file like this:
324yellow
34house
black
54532
15m21red56
44dfdsf8sfd23
How can I obtain (Perl - Windows/commandline/singleline) the
following?
1) only the numbers at the beginning before some alpha text, like
this:
324
34
15
44
2) only the numbers within the alpha text, like
this is an interesting question in that its not about syntax or a specific
problem in perl.
here's the algorithm:
while there are lines to read from the input
read a line
split the line into two seperate strings around the colon
if both strings are numbers
You are correct. I did not properly look at the regex you passed to split.
"Gunnar Hjalmarsson" <[EMAIL PROTECTED]> wrote
> > The data as posted had white space trailing some of the digits
> > after the colons.
>
> Yes, but how would that matter? Please read the second sentence in
> "perldoc -f sp
Zeus Odin wrote:
Gunnar Hjalmarsson wrote:
while () {
my ($tag, $result) = split /[ :]+/;
if ($result =~ /^\d+$/ and $result > 0) {
...
The data as posted had white space trailing some of the digits
after the colons.
Yes, but how would that matter? Please read the se
I think a hash is more apt for this problem, but changing to (an) array(s)
is not difficult at all.
The data as posted had white space trailing some of the digits after the
colons. I found this worked better for me. Your results may vary.
;-)
#!/usr/bin/perl
use warnings;
use strict;
my %tag;
w
One way would be to split each line using : as the delimiter..
I am sure there are others, but I think split would be the easiest... IMHO
From: sudhindra k s
Sent: Wed 8/4/2004 5:48 AM
To: [EMAIL PROTECTED]
Subject: Choosing only numbers from the output
Hi
I have an output which looks
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
sudhindra k s wrote:
|
| Hi
Hello,
| I have an output which looks like this:
|
| Tag : Result
| 146603:
| 147020:
| 147155: NONE
| 147160:
| 147232:
| 147243:
| 147254: none
| 147318:
| 147341: NONE
| 147430
Sudhindra K S wrote:
I have an output which looks like this:
Do you possibly mean input? ;-)
Tag : Result
148200:
148312: 38160
148329: 44139
148444: NONE
148514:
148573:
148697:
Now i want to gather all the "Tags" for which the "Result" is a
number (but shou
Hi
I have an output which looks like this:
Tag : Result
146603:
147020:
147155: NONE
147160:
147232:
147243:
147254: none
147318:
147341: NONE
147430: N/A
147708:
147710:
147729:
147768:
147851:
147921:
147
dan wrote:
> I want to be able to check if a string contains only a number, no letters,
> etc. I have this procedure:
Try;
if (!($numess =~ /\D/)) {
which will reject anything containing a non-digit.
Joseph
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL
dan wrote:
> I want to be able to check if a string contains only a number, no
> letters, etc. I have this procedure:
>
> if ($numexs =~ /[0-9]/{
> # do something
> }
>
> which doesn't do what I want it to do, I want it to do more or less
> this: if ($numexs contains anything other than numbe
dan wrote:
> Hey again,
>
> I want to be able to check if a string contains only a number, no
> letters, etc. I have this procedure:
>
> if ($numexs =~ /[0-9]/{
> # do something
> }
>
> which doesn't do what I want it to do, I want it to do more or less
> this: if ($numexs contains anything
if ($numexs=~/^\d+$/) {
# do this if $numexs contains 1 or more numbers, nothing else
} else {
}
Your regex just checks to make sure there's one number in your entire
string. Anchor it at the beginning and the end, and then use a + to say
"one or more occurances of" ...
if ($numexs=~/^[0-9]+$
> Hey again,
>
> I want to be able to check if a string contains only a
> number, no letters, etc. I have this procedure:
>
> if ($numexs =~ /[0-9]/{
> # do something
> }
>
> which doesn't do what I want it to do, I want it to do more
> or less this: if ($numexs contains anything other
Hey again,
I want to be able to check if a string contains only a number, no letters,
etc. I have this procedure:
if ($numexs =~ /[0-9]/{
# do something
}
which doesn't do what I want it to do, I want it to do more or less this:
if ($numexs contains anything other than numbers) {
# do so
23 matches
Mail list logo