Re: split function

2011-12-17 Thread Brandon McCaig
On Fri, Dec 16, 2011 at 09:36:53PM -0600, Chris Stinemetz wrote: > This program does all I need it to do. I am having some difficulty > wrapping my head around it though. Mainly the for loop. Did Rob use > special varible? > > If any one can explain it to me so I can have a better understanding >

Re: split function

2011-12-16 Thread Chris Stinemetz
> > However I think it's more likely that you need /all/ of the data to be > output, so I suggest something like my program below. > > HTH, > > Rob > > > use strict; > use warnings; > > my @headers; > > while () { >  if (@headers) { >    my @data = split; >    for my $i (0 .. $#headers) { >      pr

Re: split function

2011-12-16 Thread thebarn...@gmail.com
split() splits on whitespace by default. so the "\s+/" is optional. $_ = "3 element array"; @words = split; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: split function

2011-12-16 Thread shawn wilson
On Thursday, December 15, 2011, Chris Stinemetz wrote: > > It isn't a company policy just circumstance. The unix box I'm using > doesn't support DNS nameserver lookup or a C compiler. > > I'm currently using Perl 5.6.1 which doesnt' support local::lib and I > can't install perlbrew to upgrade my

Re: split function

2011-12-16 Thread Shlomi Fish
Hi Chris, On Thu, 15 Dec 2011 15:29:08 -0600 Chris Stinemetz wrote: > > > > Is that your company's policy, or do you just lack root access? If it's the > > latter, then see the various resources at > > http://perl-begin.org/topics/cpan/ , > > so you can see how to install Perl modules from CPAN

Re: split function

2011-12-15 Thread Chris Stinemetz
> > Is that your company's policy, or do you just lack root access? If it's the > latter, then see the various resources at http://perl-begin.org/topics/cpan/ , > so you can see how to install Perl modules from CPAN under your home > directory. > It isn't a company policy just circumstance. The u

Re: split function

2011-12-15 Thread Shlomi Fish
Hi Chris, On Thu, 15 Dec 2011 11:58:00 -0600 Chris Stinemetz wrote: > On Thu, Dec 15, 2011 at 10:42 AM, Dr.Ruud wrote: > > On 2011-12-14 05:43, Chris Stinemetz wrote: > > > >> I am trying to split the first element of an array by white space then > >> continue reading the rest of the file. > >>

RE: split function

2011-12-15 Thread Ken Slater
> To: Perl Beginners > Cc: Ken Slater; Chris Stinemetz > Subject: Re: split function > > On 15/12/2011 16:09, Ken Slater wrote: > > > > I have not been following this too closely, but I don't understand > the > > algorithm used to get the above ou

Re: split function

2011-12-15 Thread Chris Stinemetz
> > Tool completed successfully > Thank you Rob! This is what I was trying to accomplish. I'm going to have to research to find out exactly what you did. Thanks agian, Chris -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http:

Re: split function

2011-12-15 Thread Rob Dixon
On 15/12/2011 16:09, Ken Slater wrote: I have not been following this too closely, but I don't understand the algorithm used to get the above output. What is that Ken? If you don't understand the question then ask some questions of your own! I would have named it @fieldValues since arrays

Re: split function

2011-12-15 Thread Rob Dixon
On 15/12/2011 15:47, Chris Stinemetz wrote: > > I'm getting a bit closer. There a couple roadblocks I am up against. > > I am able to split the lines by white space, but for some reason the > program isn't capturing the first lines to the @fieldValue array after > the @headerNames array. > > Once I

RE: split function

2011-12-15 Thread Ken Slater
> -Original Message- > From: Ken Slater [mailto:kl...@psu.edu] > Sent: Thursday, December 15, 2011 11:09 AM > To: 'Chris Stinemetz'; 'John W. Krahn' > Cc: 'Perl Beginners' > Subject: RE: split function > > > -Original M

Re: split function

2011-12-15 Thread Chris Stinemetz
On Thu, Dec 15, 2011 at 10:42 AM, Dr.Ruud wrote: > On 2011-12-14 05:43, Chris Stinemetz wrote: > >> I am trying to split the first element of an array by white space then >> continue reading the rest of the file. >> Thus far I am having trouble figuring out how to split the first line. > > > You h

Re: split function

2011-12-15 Thread Dr.Ruud
On 2011-12-14 05:43, Chris Stinemetz wrote: I am trying to split the first element of an array by white space then continue reading the rest of the file. Thus far I am having trouble figuring out how to split the first line. You have an XY problem, you are probably looking for http://search.c

RE: split function

2011-12-15 Thread Ken Slater
> -Original Message- > From: Chris Stinemetz [mailto:chrisstinem...@gmail.com] > Sent: Thursday, December 15, 2011 10:47 AM > To: John W. Krahn > Cc: Perl Beginners > Subject: Re: split function > > I'm getting a bit closer. There a couple roadblocks I am

Re: split function

2011-12-15 Thread Chris Stinemetz
I'm getting a bit closer. There a couple roadblocks I am up against. I am able to split the lines by white space, but for some reason the program isn't capturing the first lines to the @fieldValue array after the @headerNames array. Once I get all the lines to go into the array correctly I would l

Re: split function

2011-12-14 Thread John W. Krahn
timothy adigun wrote: Hi Chris, Please check added code to yours, in addition to what John wrote; I am trying to split the first element of an array by white space then continue reading the rest of the file. Thus far I am having trouble figuring out how to split the first line. I would like

Re: split function

2011-12-14 Thread timothy adigun
Hi Chris, Please check added code to yours, in addition to what John wrote; I am trying to split the first element of an array by white space then continue reading the rest of the file. Thus far I am having trouble figuring out how to split the first line. I would like the first line to be spli

Re: split function

2011-12-13 Thread John W. Krahn
Chris Stinemetz wrote: I am trying to split the first element of an array by white space then continue reading the rest of the file. Thus far I am having trouble figuring out how to split the first line. I would like the first line to be split so it looks like the following with the "=" sign add

Re: Split function

2010-11-29 Thread Kenneth Wolcott
Hi; >>   The reason one should use File::Basename and File::Spec is that you >> can become platform-independent instead of Windoze-worshipping :-) > > What does the operating system have to do with this? > > OP asked how to split a string, I gave an example how to do it character by > character.

Re: Split function

2010-11-29 Thread Dr.Ruud
On 2010-11-29 02:27, Kenneth Wolcott wrote: On Sun, Nov 28, 2010 at 12:31, Dr.Ruud wrote: On 2010-11-28 10:54, Chaitanya Yanamadala wrote: How do i split a value like this F:\test\test123\test1233 For example: ruud$ perl -wle 'print for split //, q{F:\test\test123\test1233}' F : -snip- 3

Re: Split function

2010-11-29 Thread Brian Fraser
> > For a Windows shop, the overhead of platform independence is redundant, > Premature optimization much? Brian.

Re: Split function

2010-11-29 Thread Uri Guttman
> "ES" == Erez Schatz writes: ES> On 11/29/2010 03:27 AM, Kenneth Wolcott wrote: >> >> The reason one should use File::Basename and File::Spec is that you >> can become platform-independent instead of Windoze-worshipping :-) >> >> Ken Wolcott >> ES> I worship whatever I'm

Re: Split function

2010-11-29 Thread Erez Schatz
On 11/29/2010 03:27 AM, Kenneth Wolcott wrote: > > The reason one should use File::Basename and File::Spec is that you > can become platform-independent instead of Windoze-worshipping :-) > > Ken Wolcott > I worship whatever I'm paid to work on. For a Windows shop, the overhead of platform in

Re: Split function

2010-11-28 Thread Kenneth Wolcott
Hi; On Sun, Nov 28, 2010 at 12:31, Dr.Ruud wrote: > On 2010-11-28 10:54, Chaitanya Yanamadala wrote: > >> How do i split a value like this >> F:\test\test123\test1233 > > For example: > > ruud$ perl -wle 'print for split //, q{F:\test\test123\test1233}' > F > : > \ > t > e > s > t > \ > t > e > s

Re: Split function

2010-11-28 Thread Dr.Ruud
On 2010-11-28 10:54, Chaitanya Yanamadala wrote: How do i split a value like this F:\test\test123\test1233 For example: ruud$ perl -wle 'print for split //, q{F:\test\test123\test1233}' F : \ t e s t \ t e s t 1 2 3 \ t e s t 1 2 3 3 -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@

Re: Split function

2010-11-28 Thread Téssio Fechine
Take extra caution with the backslash-scapes.. --- use 5.010; use strict; use warnings; my $str1 = "F:\test\test123\test1233"; #Wrong! Backslash being expanded! my $str2 = 'F:\test\test123\test1233'; my @array1 = split(/\\/, $str1); my @array2 = split(/\\/, $str2); my $n1 = @array1; my $n2 = @

Re: Split function

2010-11-28 Thread Parag Kalra
>>How do i split a value like this >>F:\test\test123\test1233 use strict; use warnings; my $str='F:\test\test123\test1233'; my @values = split /\\/, $str; print "@values"; Cheers, Parag On Sun, Nov 28, 2010 at 1:54 AM, Chaitanya Yanamadala < dr.virus.in...@gmail.com> wrote: > How do i split a

Re: Split function

2010-11-28 Thread Shlomi Fish
Hi Chaitanya, On Sunday 28 November 2010 11:54:14 Chaitanya Yanamadala wrote: > How do i split a value like this > F:\test\test123\test1233 > > please help me with this.. > You should use File::Spec (and related modules such as File::Basename) to manipulate path names, instead of using split.

Re: Split function

2007-10-30 Thread Dr.Ruud
Andrew Curry schreef: > split(/\s+/, ... Most of the times you think you need /\s+/ with split, you actually want q{ }. See `perldoc -f split`. -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://lear

Re: Split function

2007-10-30 Thread Paul Lalli
On Oct 30, 1:30 pm, [EMAIL PROTECTED] (Rob Dixon) wrote: > Paul Lalli wrote: > > Annoyingly, split / /, $foo; and split ' ', $foo; are not the same > > thing. split ' ', $foo is a special case that means to split on all > > sequences of whitespace. It means the same thing as split /\s+/, > > $foo

Re: Split function

2007-10-30 Thread Rob Dixon
Paul Lalli wrote: Annoyingly, split / /, $foo; and split ' ', $foo; are not the same thing. split ' ', $foo is a special case that means to split on all sequences of whitespace. It means the same thing as split /\s+/, $foo; Not quite Paul. From perldoc -f split: A "split" on "/\s+/" is li

Re: Split function

2007-10-30 Thread Paul Lalli
On Oct 30, 5:37 am, [EMAIL PROTECTED] (Irfan Sayed) wrote: > Hi All, > > I have one variable which stores the value as follows. > > "2007-09-07T12:50:26+05:30 aic_8.0_Integration ccvob01" Now my > requirement is that I want to store aic_8.0_Integration part of the > string in different variable.

RE: Split function

2007-10-30 Thread Andrew Curry
try chomp(my @strm = split(/\s+/, $IntegrationStream)); as your only splitting on 1 space where 2 are present in your string. -Original Message- From: Sayed, Irfan (Irfan) [mailto:[EMAIL PROTECTED] Sent: 30 October 2007 09:38 To: beginners @ perl. org Subject: Split function Hi All,

Re: split function help

2006-08-29 Thread Dr.Ruud
Ken Foskey schreef: > split( /\s+/, $vob_list ) There is a difference between that and split( ' ', $vob_list ) The latter skips whitespace at the start. perl -e ' $_ = qq{ abc def\tghi\njkl} ; @_ = split /\s+/ ; $" = qq{>\n<} ; print [EMAIL PROTECTED] ' [> \n<} ; print [EMAIL P

Re: split function help

2006-08-29 Thread Mumia W.
On 08/29/2006 08:23 AM, Sayed, Irfan (Irfan) wrote: Hi All, I need to use the split function in perl script. * /vobs/apache_log4j /usr/add-on/puccase_vob01/ccvob01/apache_log4j.vbs public (replicated) Above line i need to split in following order * /vobs/apache_log4j /usr/add-on/puccase

Re: split function help

2006-08-29 Thread Dr.Ruud
"Sayed, Irfan (Irfan)" schreef: > my @vob_path = split(/ /, $vob_list); Maybe you need split(' ', $vob_list) See perldoc -f split. -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: split function help

2006-08-29 Thread Ken Foskey
On Tue, 2006-08-29 at 21:23 +0800, Sayed, Irfan (Irfan) wrote: > my @vob_path = split(/ /, $vob_list); where $vob_list contains the I am not crash hot on the split yet, but try split( /\s+/, $vob_list ) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTEC

Re: split function

2006-07-19 Thread Prasad
econd: _cmvobsvr1mum Regards, Prasad ""Sayed, Irfan (Irfan)"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] .. -Original Message- From: Xavier Noria [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 19, 2006 1:33 PM To: Perl Beginners Subject: Re: split fu

Re: split function

2006-07-19 Thread Mumia W.
On 07/19/2006 02:57 AM, Sayed, Irfan (Irfan) wrote: Hi, I need to split following string cs_backup_restore_cmvobsvr1mum the output which i am looking for is cs_backup_restore and _cmvobsvr1mum can anybody plz help regards irfan. Sayed, Irfan; your questions are too basic. Any

Re: split function

2006-07-19 Thread Dr.Ruud
"Sayed, Irfan (Irfan)" schreef: > I need to split following string > > cs_backup_restore_cmvobsvr1mum > > the output which i am looking for is > > cs_backup_restore and _cmvobsvr1mum $ perl -Mstrict -wle ' $_ = "cs_backup_restore_cmvobsvr1mum" ; @_ = split /(_)/ ; # print for @_ ; $" = "\t"

RE: split function

2006-07-19 Thread Nagrale, Ajay
x27;cs_backup_restore_cmvobsvr1mum'; my @arr= ($str=~/(.+)_(.+)/); print join "\n",@arr,"\n";' cs_backup_restore cmvobsvr1mum Ajay> Thanks, Ajay -Original Message- From: Xavier Noria [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 19, 2006 1:33 PM To: Perl Begi

Re: split function

2006-07-19 Thread Xavier Noria
On Jul 19, 2006, at 10:05, Sayed, Irfan ((Irfan)) wrote: I think criteria shud be _ but I need output in following manner That criteria is ambiguous becasue there are several _s and you need to deal with them differently, that is, ignoring some and splitting on some. Can you be more specif

RE: split function

2006-07-19 Thread Sayed, Irfan \(Irfan\)
-Original Message- From: Xavier Noria [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 19, 2006 1:33 PM To: Perl Beginners Subject: Re: split function On Jul 19, 2006, at 9:57, Sayed, Irfan ((Irfan)) wrote: > I need to split following string > > cs_backup_restore_cmvobsvr1mu

Re: split function

2006-07-19 Thread Xavier Noria
On Jul 19, 2006, at 9:57, Sayed, Irfan ((Irfan)) wrote: I need to split following string cs_backup_restore_cmvobsvr1mum the output which i am looking for is cs_backup_restore and _cmvobsvr1mum Which is the criteria, everything up to the last underscore? -- fxn -- To unsubscribe, e-mail

Re: Split function help

2006-04-25 Thread JupiterHost.Net
Mazhar wrote: Dear Irfan, i think for the code you can try the below, ($some_thing1,$some_thing2,$something_3)=split($test,".") You have the split arguments reversed :) Also, don't use double quotes when there is nothing to interpolate. And space them out so its easier to read :) An

Re: Split function help

2006-04-25 Thread Mazhar
Dear Irfan, i think for the code you can try the below, ($some_thing1,$some_thing2,$something_3)=split($test,".") Regards Mazhar On 4/25/06, Tom Allison <[EMAIL PROTECTED]> wrote: > > Irfan J Sayed wrote: > > Hi, > > > > I have a following line/statement stored in variable $test > > > > de

Re: Split function help

2006-04-25 Thread Tom Allison
Irfan J Sayed wrote: Hi, I have a following line/statement stored in variable $test deliver.Admin_Irfan_Project.20060413.212355 i want to split this line in . and store in array. I am using following code my @name = Split(/./, $test); split uses regular expressions to identify where to spl

Re: split function in perl

2006-04-17 Thread Dr.Ruud
Xavier Noria schreef: > split /[\W_]/ Alternatives: split /\W|_/ split /[^[:alnum:]]/ -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: split function in perl

2006-04-17 Thread Xavier Noria
On Apr 17, 2006, at 10:30, Irfan J Sayed wrote: Hi, I have a following line stored in one variable $test. deliver.Admin_Irfan_Project.20060413.212355 . I need to split this line into the words and store the output in array. words should like this. deliver admin irfan project 20060413 21235

Re: Split function help

2006-04-17 Thread M Senthil Kumar
On Mon, 17 Apr 2006, M Senthil Kumar wrote: |On Mon, 17 Apr 2006, Irfan J Sayed wrote: | | ||i want to split this line in . and store in array. ||I am using following code ||my @name = Split(/./, $test); | | |Try escaping "." with a "\". | |HTH, | |Senthil | And oh I forgot: "Split" should have b

Re: Split function help

2006-04-17 Thread nishanth ev
Hello, In case of linux you have to escape the . and the function name should be split and not Split. Not quite sure about windows. Regards Nishanth --- M Senthil Kumar <[EMAIL PROTECTED]> wrote: > On Mon, 17 Apr 2006, Irfan J Sayed wrote: > > > |i want to split this line in . and store in ar

Re: Split function help

2006-04-17 Thread M Senthil Kumar
On Mon, 17 Apr 2006, Irfan J Sayed wrote: |i want to split this line in . and store in array. |I am using following code |my @name = Split(/./, $test); Try escaping "." with a "\". HTH, Senthil -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Split function

2006-04-16 Thread Wijaya Edward
> Hi, > > To run/use Split function in the perl script , is it necessary to > include/add any perl module ? No no need. It is a built in function. perldoc -f split -- Regards, Edward WIJAYAA Institute For Infocomm Research - Disclaimer - This email is confidenti

Re: split function

2004-09-14 Thread John W. Krahn
c r wrote: Hi! Hello, Can the perl split function split a random 40 character string into five 8 character strings? No. With random I mean that there is no special pattern in the 40 character string that can be used as split markers. You should probably use a match operator. my @strings = $string =

RE: split function

2004-09-14 Thread Jim
> Can the perl split function split a random 40 character > string into five 8 character strings? > > With random I mean that there is no special pattern in the 40 > character string that can be used as split markers. How about unpack? @eights = unpack("A8" x (length($string)/8), $string);

Re: split function

2004-09-14 Thread Chris Devers
On Tue, 14 Sep 2004, c r wrote: > Can the perl split function split a random 40 character string into > five 8 character strings? > > With random I mean that there is no special pattern in the 40 > character string that can be used as split markers. Wouldn't substr make more sense, or a regex?

Re: split function

2004-09-14 Thread Gunnar Hjalmarsson
C r wrote: Can the perl split function split a random 40 character string into five 8 character strings? With random I mean that there is no special pattern in the 40 character string that can be used as split markers. Don't know, but in any case the m// operator is a better way to do that: my

Re: split function

2004-09-14 Thread Wiggins d Anconia
> > Hi! > > Can the perl split function split a random 40 character string into five 8 character strings? > > With random I mean that there is no special pattern in the 40 character string that can be used as split markers. > This smells like homework? (just a reminder to the gurus, it is t

Re: split function - from

2004-03-11 Thread John W. Krahn
"John W. Krahn" wrote: > > A more perl-ish way to write that: > > while ( ) { Oops, forgot to chomp. chomp; > next if /^\s*(?:#|$)/; #if line begins with a # or line is blank > print MESS if /\w/; > print { /[A-Za-z]/ ? *TIDY : *MESS } $_; > > # split the string into

Re: split function - from

2004-03-11 Thread John W. Krahn
Stephen Kelly wrote: > > hi there Hello, > i'm trying to split a string from a line of text in a file - the split > delimiter is a tab character '\t' - i then need to compare the 2 bits on > either side of the tab to see if they are equal - if not eq - i write to > tidy else i write to mess > >

RE: split function using "." for the pattern

2002-10-30 Thread Kipp, James
escape the . with \ in your split statement > -Original Message- > From: [EMAIL PROTECTED] [mailto:bengleto@;calpoly.edu] > Sent: Wednesday, October 30, 2002 12:39 PM > To: [EMAIL PROTECTED] > Subject: split function using "." for the pattern > > > I have a string that I want to split

RE: split function using "." for the pattern

2002-10-30 Thread Timothy Johnson
Did you remember to represent '.' as '\.'? -Original Message- From: [EMAIL PROTECTED] [mailto:bengleto@;calpoly.edu] Sent: Wednesday, October 30, 2002 9:39 AM To: [EMAIL PROTECTED] Subject: split function using "." for the pattern I have a string that I want to split into an array 10.

Re: Split function

2002-02-12 Thread Jeff 'japhy' Pinyan
On Feb 12, Kevin Butters said: >my $date_time = localtime; >print "$date_time"; > >split $date_time,/ /; You've got that backwards. And where are you storing the results? @parts = split / /, $date_time; And you might want to use split / +/ or split ' ' instead. -- Jeff "japhy" Pinyan

RE: Split function

2002-02-12 Thread Timothy Johnson
localtime() actually returns an array, so if you do this: @date = localtime(); Then your array will be populated with the information you're looking for. Personally, I prefer to do it this way: ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); Just remember that you h