Re: Split question

2007-10-12 Thread Matthew Whipple
There's a comma in the example data provided. Most of the CSV's I've dealt with also quote values which were strings. If this is the case, an ugly solution would be to use something along the lines of '","' as the delimiter, take into account any possible fields which aren't quoted (it should be

Re: Split question

2007-10-12 Thread yitzle
On 10/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > One of the column in csv file is Fri, Oct 12 10:32 AM. I am trying ti split > the csv file for checking a column value. when spliting I wanted to take Fri, > Oct 12 10:32 AM as a single value. How can I use split? > > Thanks > Manoj If

Re: Split question

2007-10-12 Thread Tom Phoenix
On 10/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > One of the column in csv file is Fri, Oct 12 10:32 AM. I am trying ti split > the csv file for checking a column value. when spliting I wanted to take > Fri, Oct 12 10:32 AM as a single value. How can I use split? You don't want split fo

Re: Split question

2003-12-16 Thread Rob Dixon
John wrote: > > Here is a little quiz for you beginners out there. split() treats its > first argument as a regular expression. There are TWO exceptions where > the first argument does not behave the same as a normal regular > expression. What are they? I know! Please sir! Actually this 'backw

RE: Split question

2003-12-15 Thread Charles K. Clarkson
Wiggins d Anconia <[EMAIL PROTECTED]> wrote: : : > On Monday, December 15, 2003 03:05, John W. Krahn wrote: : > : > > Here is a little quiz for you *BEGINNERS* out there. [emphasis added] : : But parentheses are normal in a regex, though granted the : return is odd. I would guess as the second

RE: Split question

2003-12-15 Thread Wiggins d Anconia
> On Monday, December 15, 2003 03:05, John W. Krahn wrote: > > >Here is a little quiz for you beginners out there. split() treats its > >first argument as a regular expression. There are TWO exceptions where > >the first argument does not behave the same as a normal regular > >expression. Wha

RE: Split question

2003-12-15 Thread Perry, Alan
On Monday, December 15, 2003 03:05, John W. Krahn wrote: >Here is a little quiz for you beginners out there. split() treats its >first argument as a regular expression. There are TWO exceptions where >the first argument does not behave the same as a normal regular >expression. What are they? T

Re: Split question

2003-12-15 Thread R. Joseph Newton
"John W. Krahn" wrote: > "R. Joseph Newton" wrote: > > > > Joel Newkirk wrote: > > > > > Well, actually they don't, since the 'bare' # will be interpreted as > > > starting a comment, while the one in quotes won't... ;^) > > > > > > The op's assignment was assigning 'split(/' to @temp... > > > >

Re: Split question

2003-12-15 Thread Joel Newkirk
On Sun, 2003-12-14 at 18:11, Joel Newkirk wrote: > > > > The first argument to split is converted to a regular expression and the > > '#' character is not special in a regular expression so split/#/ and > > split'\#' do exactly the same thing. > > Well, actually they don't, since the 'bare' # wi

Re: Split question

2003-12-15 Thread John W. Krahn
"R. Joseph Newton" wrote: > > Joel Newkirk wrote: > > > Well, actually they don't, since the 'bare' # will be interpreted as > > starting a comment, while the one in quotes won't... ;^) > > > > The op's assignment was assigning 'split(/' to @temp... > > Did you test. Did YOU test? > The only

Re: Split question

2003-12-14 Thread James Edward Gray II
On Dec 14, 2003, at 6:42 PM, R. Joseph Newton wrote: The only problem I see with John's code is that it addumes that the print statement will print a newline, which it doesn't [at least on my installation of V5.8]. Na, John's smarter than you give him credit for here. Here was the code: On Dec

Re: Split question

2003-12-14 Thread John W. Krahn
Joel Newkirk wrote: > > On Sun, 2003-12-14 at 14:52, John W. Krahn wrote: > > Josimar Nunes De Oliveira wrote: > > > > > > From: "Perl" <[EMAIL PROTECTED]> > > > > > > > > @temp = split(/#/, "abc#def#ghi#jkl") ; > > > > > > @temp = split('\#', "abc#def#ghi#jkl") ; > > > > The first argument to s

Re: Split question

2003-12-14 Thread R. Joseph Newton
Joel Newkirk wrote: > > The first argument to split is converted to a regular expression and the > > '#' character is not special in a regular expression so split/#/ and > > split'\#' do exactly the same thing. > > Well, actually they don't, since the 'bare' # will be interpreted as > starting a c

Re: Split question

2003-12-14 Thread Joel Newkirk
On Sun, 2003-12-14 at 14:52, John W. Krahn wrote: > Josimar Nunes De Oliveira wrote: > > > > From: "Perl" <[EMAIL PROTECTED]> > > > > > > @temp = split(/#/, "abc#def#ghi#jkl") ; > > > > > > doesn't seem to work. > > > > > > am i doing anything wrong here ? > > > > Try this: > > > > @temp = spl

Re: Split question

2003-12-14 Thread John W. Krahn
Josimar Nunes De Oliveira wrote: > > From: "Perl" <[EMAIL PROTECTED]> > > > > @temp = split(/#/, "abc#def#ghi#jkl") ; > > > > doesn't seem to work. > > > > am i doing anything wrong here ? > > Try this: > > @temp = split('\#', "abc#def#ghi#jkl") ; > foreach (@temp){ > print "\n", $_; > } The

Re: Split question

2003-12-14 Thread Josimar Nunes de Oliveira
Try this: @temp = split('\#', "abc#def#ghi#jkl") ; foreach (@temp){ print "\n", $_; } Josimar - Original Message - From: "Perl" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, December 14, 2003 3:16 AM Subject: Split question > Hi, >i am new to Perl. >here is my que

Re: Split question

2003-12-13 Thread Kenton Brede
On Sat, Dec 13, 2003 at 09:16:35PM -0800, Perl wrote: > Hi, >i am new to Perl. >here is my question > > i have a character string like abc#def#ghi#jkl > > i want to split the string based on the delimiter # so that i get > something like this : > > abc def ghi jkl > > Bu

Re: Split question

2003-12-13 Thread John W. Krahn
Perl wrote: > > Hi, Hello, >i am new to Perl. >here is my question > > i have a character string like abc#def#ghi#jkl > > i want to split the string based on the delimiter # so that i get > something like this : > > abc def ghi jkl > > But > > @temp = split(/#/, "ab

Re: split// question

2002-03-10 Thread Jonathan E. Paton
> The reason your code breaks is because you are > misunderstanding split(); it does NOT return what > the regex matched. > > split /=/, "a=b" > > does not return ("a", "=", "b"). It returns ("a", "b"). Unless of course you write split as: split /(=)/, "a=b"; But you rarely, if ever, need

Re: split// question

2002-03-10 Thread Jeff 'japhy' Pinyan
On Mar 10, Karsten Borgwaldt said: >key=value >key2=value2 > > >This is the sourcecode: I can assure you it isn't; your code assigns to $1, $2, and $3 -- you can't do that. >open(file, "< foo.bar"); If you had warnings on, you'd be told that filehandles should be written in uppercase for s

Re: Split question

2001-08-13 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 13, Scott and Kristin Seitz said: >$CharSep="\|"; The double quoted string "\|" is still just "|". Use single quotes or the quotemeta() function. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http:/

Re: Split question

2001-08-13 Thread Shane Laffin
Scott, The problem is that | is a pattern metacharacter, and still needs to be escaped. try: my @arr = split(/\Q$CharSep/, $_); # I have a delimited text file with a vertical bar (|) as the column delimiter. When I execute the following statement

Re: SPLIT QUESTION

2001-05-31 Thread Piers Cawley
Jeff Pinyan <[EMAIL PROTECTED]> writes: > On May 31, Pedro A Reche Gallardo said: > > >How can I split a string of caracters -any but blank spaces- into > >the individual caracters? > > So you want to split "what's up, doc?" into > > @chars = qw( w h a t ' s u p , d o c ? ); > > That is

Re: SPLIT QUESTION

2001-05-31 Thread Paul
--- Jeff Pinyan <[EMAIL PROTECTED]> wrote: > On May 31, Paul said: > > >Still, though, won't that return all the *strings* as elements, > rather > >than the individual characters? and wouldn't \S* solve that > difference? > > We're only matching ONE character at a time: > > @all_chars = $st

Re: SPLIT QUESTION

2001-05-31 Thread Jeff Pinyan
On May 31, Paul said: >Still, though, won't that return all the *strings* as elements, rather >than the individual characters? and wouldn't \S* solve that difference? We're only matching ONE character at a time: @all_chars = $str =~ /./sg; @all_ws = $str =~ /\s/g; @all_non_ws = $str

Re: SPLIT QUESTION

2001-05-31 Thread Paul
--- Jeff Pinyan <[EMAIL PROTECTED]> wrote: > On May 31, Paul said: > > >> my @chars = $string =~ /\S/g; > > > >I've seen a couple of people doing this, and maybe I'm just > confused, > >but > > > >Isn't the point of the original request to split into the original > >characters, but leave *ou

Re: SPLIT QUESTION

2001-05-31 Thread Jeff Pinyan
On May 31, Paul said: >> my @chars = $string =~ /\S/g; > >I've seen a couple of people doing this, and maybe I'm just confused, >but > >Isn't the point of the original request to split into the original >characters, but leave *out* the spaces? > >and isn't \S any nonspace? > >So, if you split

Re: SPLIT QUESTION

2001-05-31 Thread Paul
--- "Randal L. Schwartz" <[EMAIL PROTECTED]> wrote: > > "Pedro" == Pedro A Reche Gallardo > <[EMAIL PROTECTED]> writes: > > Pedro> How can I split a string of caracters -any but blank spaces- > into > Pedro> the individual caracters? > > my @chars = $string =~ /\S/g; I've seen a couple

Re: SPLIT QUESTION

2001-05-31 Thread Paul
--- Pedro A Reche Gallardo <[EMAIL PROTECTED]> wrote: > Hi all, > How can I split a string of caracters -any but blank spaces- into > the individual caracters? > Cheers I'd say @chars = split /\s*/, $string; That will split between characters that have any number of spaces between them -

Re: SPLIT QUESTION

2001-05-31 Thread Randal L. Schwartz
> "Pedro" == Pedro A Reche Gallardo <[EMAIL PROTECTED]> writes: Pedro> How can I split a string of caracters -any but blank spaces- into Pedro> the individual caracters? my @chars = $string =~ /\S/g; -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[EMAIL

Re: SPLIT QUESTION

2001-05-31 Thread Brett W. McCoy
> How can I split a string of caracters -any but blank spaces- into > the individual caracters? Try something like this: my @arr = split //, "sometext"; foreach $i (@arr) { print "$i\n"; } -- Brett Brett W. McCoy Software Engineer Broadsoft, Inc. 240-364-5225 [EMAIL PROTECTED]

Re: SPLIT QUESTION

2001-05-31 Thread Jeff Pinyan
On May 31, Pedro A Reche Gallardo said: >How can I split a string of caracters -any but blank spaces- into >the individual caracters? So you want to split "what's up, doc?" into @chars = qw( w h a t ' s u p , d o c ? ); That is, every character except spaces? First, remove spaces from t