field. A split with no arguments
really does a split(' ', $_) internally.
> -Original Message-
> From: John W. Krahn [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, April 02, 2002 3:54 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Creating variables of a string
>
&g
Nikola Janceski wrote:
>
> That always confused me, by default split splits by /\s+/ so why confuse us
> more by making " " and ' ' magical.
No, the default is NOT /\s+/, the following are all equivalent:
@words = split;
@words = split ' ';
@words = split ' ', $_;
John
--
use Perl;
program
f
From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, April 02, 2002 3:34 PM
> To: Timothy Johnson
> Cc: David Gray; [EMAIL PROTECTED]
> Subject: RE: Creating variables of a string
>
>
> On Apr 2, Timothy Johnson said:
>
> >So if you wanted to s
On Apr 2, Timothy Johnson said:
>So if you wanted to split on just one space, would split / /,$variable be
>treated as magical as well?
No. As the split() documentation ALSO states, only split(' ') and
split(" ") are treated magically. split(/ /) splits on a single
space; the others split as i
So if you wanted to split on just one space, would split / /,$variable be
treated as magical as well?
-Original Message-
From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 02, 2002 11:50 AM
To: David Gray
Cc: [EMAIL PROTECTED]
Subject: RE: Creating vari
On Apr 2, David Gray said:
>> Michael Stearman wrote:
>>
>> my ($target, $count, $num) = split ' ', $word;
>
>I think that needs to be:
>
>my ($target,$count,$num) = split /\s+/, $word;
>
>to handle multiple spaces between the values.
No. As the split() documentation states, split(' ') is magic
> Michael Stearman wrote:
> >
> > Right now it is not working and I was wondering if I sent the code
> > maybe someone with more experience with this will see the
> problem. I
> > am very new to this. The line I am trying to create the variables
> > from is
> >
> > C6xxxSimulator(TI)
[Please don't top-post]
Michael Stearman wrote:
>
> Right now it is not working and I was wondering if I sent the code maybe
> someone with more experience with this will see the problem. I am very new
> to this. The line I am trying to create the variables from is
>
> C6xxxSimulator(TI)
> -Original Message-
> From: Michael Stearman [mailto:[EMAIL PROTECTED]]
> Subject: Re: Creating variables of a string
>
> Right now it is not working and I was wondering if I sent the
> code maybe
> someone with more experience with this will see the problem.
On Apr 2, Michael Stearman said:
>Michael 57 3
>
>I want to assign each of these three to different variables. My only
>problem is that the word and the numbers are always different and the space
>between the words and numbers is always different as well. Does anyone know
>how I would
nt "Target = $target \n";
print "Count = $count \n";
-Original Message-
From: Michael Stearman [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 02, 2002 9:28 AM
To: [EMAIL PROTECTED]
Subject: Re: Creating variables of a string
Right now it is not working and I was wondering if
es anyone have any ideas? I'm lost.
>From: "Tanton Gibbs" <[EMAIL PROTECTED]>
>To: "Tanton Gibbs" <[EMAIL PROTECTED]>, "Michael Stearman"
><[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>
>Subject: Re: Creating variables of a string
Actually, since the others are numbers you could replace the last two \S+
with \d+
- Original Message -
From: "Tanton Gibbs" <[EMAIL PROTECTED]>
To: "Michael Stearman" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, April 02, 2002 12:06 P
my ($word, $num1, $num2) = $string =~ /^\s*(\S+)\s+(\S+)\s+(\S+)\s*$/;
This matches
^ - the start of the string
\s* - any number (including 0) of spaces
(\S+) - any number (not including 0) of NON spaces. It also saves the value
\s+ - any number (not including 0) of spaces
(\S+) - see above
\s+
14 matches
Mail list logo