Re: join each entries in a file

2012-08-14 Thread jet speed
Thanks Shawn, Appreciate your help !! On Tue, Aug 14, 2012 at 12:57 PM, Shawn H Corey wrote: > On Tue, 14 Aug 2012 11:50:14 +0100 > jet speed wrote: > > > i have an @newfa with 50:00:00:08:44:9a:fb:79:90 > > 50:00:00:90:44:9a:fb:30:90 50:00:00:55:44:9a:fb:79:66 and a file as > > below. now i wa

Re: join each entries in a file

2012-08-14 Thread Shlomi Fish
ׁHi jet speed, On Tue, 14 Aug 2012 11:50:14 +0100 jet speed wrote: > Hi Shlomi, > > Thanks for the quick response, appreciate it. > > I modified the code as below and it works. > > foreach $fa(@falist) { > my @parts = $fa =~m/(..)/g; > my $with_colons = join (':', @parts); > push @newfa,$wit

Re: join each entries in a file

2012-08-14 Thread Shawn H Corey
On Tue, 14 Aug 2012 11:50:14 +0100 jet speed wrote: > i have an @newfa with 50:00:00:08:44:9a:fb:79:90 > 50:00:00:90:44:9a:fb:30:90 50:00:00:55:44:9a:fb:79:66 and a file as > below. now i want check if the @newfa entry present in the file if it > exists then i need to print the matching zone: nam

Re: join each entries in a file

2012-08-14 Thread jet speed
Hi Shlomi, Thanks for the quick response, appreciate it. I modified the code as below and it works. foreach $fa(@falist) { my @parts = $fa =~m/(..)/g; my $with_colons = join (':', @parts); push @newfa,$with_colons; } print @newfa; I have one more query, please help i have an @newfa with 50:00

Re: join each entries in a file

2012-08-14 Thread Shlomi Fish
Hi Sj, On Tue, 14 Aug 2012 10:55:13 +0100 jet speed wrote: > Hi All, > > I have a file as below > > file.txt > 5008449AFB7494 > 5008449AFB749C > 5008449AFB779D > > now i want to introduce : inbetween as below for each of these > entries in the file > > 50:00:00:08:44:9A:FB:74:90

Re: join lines

2009-11-18 Thread Dr.Ruud
Jackie Jackie wrote: > Ruud: #!/usr/bin/perl -w use strict; local $/ = "\n\n"; my @data = map [ map [ split /\n/ ], split /\n&\n/ ], ; > > This time the code worked. Please explain it to me. Try this version, and find out yourself: #!/usr/bin/perl -w use strict; use Data::Dumper; local $/

RE: join lines

2009-11-18 Thread Hack, Gabi (ext)
oops. It must be of course: local $/ = ''; sorry, gabi -Original Message- From: Hack, Gabi (ext) Sent: Wednesday, November 18, 2009 8:57 AM To: Dr.Ruud; beginners@perl.org Subject: RE: join lines Dr.Ruud wrote: > local $/ = "\n\n"; shorter: local $\ = 

RE: join lines

2009-11-17 Thread Hack, Gabi (ext)
Dr.Ruud wrote: > local $/ = "\n\n"; shorter: local $\ = ''; # set record separator to blank line gabi -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: join lines

2009-11-17 Thread Jackie Jackie
Thanks This time the code worked. Please explain it to me. From: Dr.Ruud To: beginners@perl.org Sent: Sun, November 15, 2009 9:43:09 PM Subject: Re: join lines Jackie Jackie wrote: > Desired output: > name1&firstname1&adresse1 > name2&am

Re: join lines

2009-11-17 Thread Dr.Ruud
Jackie Jackie wrote: Desired output: name1&firstname1&adresse1 name2&firstname2&adresse2 name3&firstname3&adresse3 name4&firstname4&adresse4 name5&firstname5&adresse5 etc. #!/usr/bin/perl -w use strict; local $/ = "\n\n"; my @data = map [ map [ split /\n/ ], split /\n&\n/ ], ; for my $d

Re: join lines

2009-11-16 Thread Jim Gibson
On 11/16/09 Mon Nov 16, 2009 1:23 PM, "Jackie Jackie" scribbled: > What this means > > if( ! length() ) It means evaluate the expression '! length()' in a scalar context, interpret the value as a logical expression, and branch accordingly. ! is the not operator. length() is the length ope

Re: join lines

2009-11-16 Thread Jackie Jackie
! length() ) From: Shawn H Corey To: Jackie Jackie Cc: beginners@perl.org Sent: Sun, November 15, 2009 3:51:04 PM Subject: Re: join lines Jackie Jackie wrote: > I tried to adapt this code to obtain my desired output. I need help. My logic > is > &

Re: join lines

2009-11-15 Thread Shawn H Corey
Jackie Jackie wrote: > I tried to adapt this code to obtain my desired output. I need help. My logic > is > > While > if lines are not empty {do} > if lines are empty {do} > > While > if lines are not empty {do} > else for empty lines{do} > > I am new to programming. I have problem with logic

Re: join lines

2009-11-15 Thread John W. Krahn
Jackie Jackie wrote: I tried to adapt this code to obtain my desired output. I need help. My logic is While if lines are not empty {do} if lines are empty {do} While if lines are not empty {do} else for empty lines{do} I am new to programming. I have problem with logic and syntax. So please

Re: 'Join' query

2009-08-07 Thread jet speed
On Fri, Aug 7, 2009 at 4:46 PM, Shawn H. Corey wrote: > jet speed wrote: > >> Hi, >> >> I would like to join the $abc with ':' the final desired output 1:2:3:4:5 >> >> #!/usr/bin/perl >> >> use strict; >> use warnings; >> >> my $abc = "1 2 3 4 5"; >> my $out = join ':', $abc; >> print "$out"; >>

Re: 'Join' query

2009-08-07 Thread Shawn H. Corey
jet speed wrote: Hi, I would like to join the $abc with ':' the final desired output 1:2:3:4:5 #!/usr/bin/perl use strict; use warnings; my $abc = "1 2 3 4 5"; my $out = join ':', $abc; print "$out"; executing the above, i get the same output 1 2 3 4 5, not sure were am going wrong. Any he

Re: 'Join' query

2009-08-07 Thread John W. Krahn
jet speed wrote: Hi, Hello, I would like to join the $abc with ':' the final desired output 1:2:3:4:5 #!/usr/bin/perl use strict; use warnings; my $abc = "1 2 3 4 5"; my $out = join ':', $abc; print "$out"; executing the above, i get the same output 1 2 3 4 5, not sure were am going wron

Re: 'Join' query

2009-08-07 Thread Dermot
2009/8/7 jet speed : > Hi, > > I would like to join the $abc with ':'  the final desired output 1:2:3:4:5 > > #!/usr/bin/perl > > use strict; > use warnings; > > my $abc = "1 2 3 4 5"; > my $out = join ':', $abc; > print "$out"; > join works on arrays (LIST). You feeding it a scalar. @abc = qw/1

Re: 'Join' query

2009-08-07 Thread Telemachus
On Fri Aug 07 2009 @ 4:03, jet speed wrote: > Hi, > > I would like to join the $abc with ':' the final desired output 1:2:3:4:5 > > #!/usr/bin/perl > > use strict; > use warnings; > > my $abc = "1 2 3 4 5"; > my $out = join ':', $abc; > print "$out"; The function join works on lists not scala

Re: 'Join' query

2009-08-07 Thread Jim Gibson
On 8/7/09 Fri Aug 7, 2009 8:03 AM, "jet speed" scribbled: > Hi, > > I would like to join the $abc with ':' the final desired output 1:2:3:4:5 > > #!/usr/bin/perl > > use strict; > use warnings; > > my $abc = "1 2 3 4 5"; > my $out = join ':', $abc; > print "$out"; > > executing the above,

Re: join(): is order guaranteed?

2009-07-12 Thread Dan
On Sun, 12 Jul 2009 23:39:12 -0400, Uri Guttman wrote: < stuff snipped > > intersting point. the docs say: > > Joins the separate strings of LIST into a single string with > fields separated by the value of EXPR, and returns that new > string. Example: > > but the key point (implied i would sa

Re: join(): is order guaranteed?

2009-07-12 Thread Uri Guttman
> "CO" == Chas Owens writes: CO> On Sun, Jul 12, 2009 at 14:31, Dan wrote: >> Hi people. >> >> Is the order of results from a join() operation guaranteed ( assuming my >> array doesn't change, of course )? CO> snip CO> Interesting, the docs for the join function make no guaran

Re: join(): is order guaranteed?

2009-07-12 Thread Chas. Owens
On Sun, Jul 12, 2009 at 14:31, Dan wrote: > Hi people. > > Is the order of results from a join() operation guaranteed ( assuming my > array doesn't change, of course )? snip Interesting, the docs for the join function make no guarantee about the order of the join; however, the historic order has b

Re: join(): is order guaranteed?

2009-07-12 Thread Shawn H. Corey
On Mon, 2009-07-13 at 04:31 +1000, Dan wrote: > Hi people. > > Is the order of results from a join() operation guaranteed ( assuming my > array doesn't change, of course )? > > Dan > > No, the order does not change. Perl is too lazy to change anything without good cause. -- Just my 0.0

Re: join and parenthesis. Is this a bug?

2009-03-03 Thread Jim Gibson
On 3/3/09 Tue Mar 3, 2009 3:05 AM, "freefox" scribbled: > Hi, > > As join is a build in I guess it should/could be called without > parenthesis. > However these two lines gives me two different answers. > > my @strings = ('foo', 'bar'); > > my $string1 = q{('} . join q{', '}, @strings . q{')

Re: join operator for arrays question

2008-10-03 Thread Dr.Ruud
"John W. Krahn" schreef: > BTW $$_[0] is usually written as $_->[0]. I think it is a pity that O::Deparse() doesn't do this: $ perl -MO=Deparse -e '$$_[0] = 1' $$_[0] = 1; -e syntax OK $ perl -MO=Deparse -e '$_->[0] = 1' $$_[0] = 1; -e syntax OK -- Affijn, Ruud "Gewoon is een tijger." -- T

Re: join operator for arrays question

2008-10-02 Thread John W. Krahn
JAaronAnderson.com wrote: Ok, thanks guys for posting, I am posting from within my GoogleGroup Account. Ergo my comment... let's not be critical and get down to the code! the code I was asking about was :: map { $_ = $$_[0] } @userlist; I dont understand it fully but I got what I wanted to get

Re: join operator for arrays question

2008-10-02 Thread JAaronAnderson.com
Ok, thanks guys for posting, I am posting from within my GoogleGroup Account. Ergo my comment... let's not be critical and get down to the code! the code I was asking about was :: map { $_ = $$_[0] } @userlist; I dont understand it fully but I got what I wanted to get done with the following::.

Re: join operator for arrays question

2008-09-27 Thread Jeff Pang
> Message du 27/09/08 15:41 > De : "John W. Krahn" > A : "Perl Beginners" > Copie à : > Objet : Re: join operator for arrays question > > > JAaronAnderson.com wrote: > > =pod > > Hey fellow GoogleGroup Brothers & Sisters, > > I

Re: join operator for arrays question

2008-09-27 Thread John W. Krahn
JAaronAnderson.com wrote: =pod Hey fellow GoogleGroup Brothers & Sisters, I hate to disappoint you but this is not a "GoogleGroup", this is a mailing list controlled by perl.org. I am hoping to ask you all a quick Perl intermediate logic question… I have called an obj command which returns

Re: join operator for arrays question

2008-09-27 Thread Mr. Shawn H. Corey
On Fri, 2008-09-26 at 13:15 -0700, JAaronAnderson.com wrote: > my @userlist = $obj->command_ok(qw/user list/, "","",""); > # it then returns this info I think > # “emailHandle”, “User FullName” > # because it shows Array elements in memory > # foreach of them but not the mapped qw word list hm

Re: "Join" Function

2005-08-09 Thread Christer Ekholm
"Vineet Pande" <[EMAIL PROTECTED]> writes: > hi, > In the following code which reads a file.txt (SEE ATTACHMENT) where I > am trying to understand how to put the DNA sequence in to a single > string... > > print "enter file with DNA sequence: "; > $seqfile = ; > chomp $seqfile; > unless ( open(DNA

Re: "Join" Function

2005-08-08 Thread John W. Krahn
Vineet Pande wrote: > hi, Hello, > In the following code which reads a file.txt (SEE ATTACHMENT) where I am > trying to understand how to put the DNA sequence in to a single string... > > print "enter file with DNA sequence: "; > $seqfile = ; > chomp $seqfile; > unless ( open(DNAFILE, $seqfile)

Re: "Join" Function

2005-08-08 Thread Jeff Eggen
>>> "Vineet Pande" <[EMAIL PROTECTED]> 08/08/2005 9:39:00 am >>> >@dna = ; [snip] >$dna = join( '', @dna); >print "$dna\n"; >THE OUTPUT IS EXACTLY THE SAME AS IN file.txt.Why don't we get the >string joined...of course i agree i must clean whitespace...bu then what is >expected out of join(

RE: "Join" Function

2005-08-08 Thread Ankur Gupta
Vineet Pande wrote: > hi, > In the following code which reads a file.txt (SEE ATTACHMENT) where I > am trying to understand how to put the DNA sequence in to a single > string... > > print "enter file with DNA sequence: "; > $seqfile = ; > chomp $seqfile; > unless ( op

Re: Join strings problem

2004-01-21 Thread drieux
On Jan 21, 2004, at 6:46 PM, Luinrandir Hernsen wrote: I thanks you very much for reply and all 3 ways do work. unfortunately I did not state the situation completely. $Building is to = the variable $EW0NS0 thru $EW10NS10 This is so I can set certain variables like my $EW5NS5="TEST.gif"; to show a

Re: Join strings problem

2004-01-21 Thread drieux
On Jan 21, 2004, at 2:26 PM, Luinrandir Hernsen wrote: #!/usr/local/bin/perl use strict; use warnings; my ($Building, $row, $col); { dan's gonna kill me for that one... 8-) } print qq|Content-type: text/html\n\n|; my $EW5NS5="TEST.gif"; ##this is the string I need to build. print qq|\n|; for ($

Re: join question - maybe map

2003-10-16 Thread Sudarshan Raghavan
Gary Stainburn wrote: Hi folks, I've got a hash such as: %masters=('VSL01'=>{'type'=>'S','name'=>'Vehicle Ledger accounts'}, 'ALD01'=>{'type'=>'S','name'=>'ALD Automotive Ltd'}, 'ALP01'=>{'type'=>'S','name'=>'Alphabet GB Ltd'}, 'ANC01'=>{'type'=>'S','name'=>'ANC Rent

RE: Join problem

2002-10-20 Thread Vincent Lee
.com] Sent: Thursday, October 17, 2002 8:08 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: Join problem Hi - it must be an undef in your array, your join should work as posted. You might try something like (untested): for (@array) { if ($_) { push @clean_array, $_ } } n

Re: Join problem

2002-10-18 Thread John W. Krahn
Vincent Lee wrote: > > Hello All, Hello, > I've got a problem with the JOIN function > > I've got a list of columns that gets returned from the > database. > > I push the column values into an array and then join > them with a comma. The problem is that JOIN puts a > comma in the first value.

RE: Join problem

2002-10-18 Thread Beau E. Cox
Hi - it must be an undef in your array, your join should work as posted. You might try something like (untested): for (@array) { if ($_) { push @clean_array, $_ } } now join on @clean_array... Aloha => Beau. -Original Message- From: Vincent Lee [mailto:vjlee_us@;yahoo.com]

Re: Join Problem

2002-10-18 Thread Alfred Vahau
>shift @columns if not defined $column[0]; ^ Thanks for the correction. It seemed almost like a natural extension of defined which I tried before posting. Alfred, Jeff 'japhy' Pinyan wrote: > On Oct 18, Alfred Vahau said: > > >> How do I get rid of the comm

Re: Join Problem

2002-10-18 Thread Jeff 'japhy' Pinyan
On Oct 18, Alfred Vahau said: >> How do I get rid of the comma in the first value? >You could try shifting to the left like > >shift @columns if (undef $column[0]); undef() is not a test. undef() undefines things. shift @columns if not defined $column[0]; The simplest solution is: print j

Re: Join problem

2002-10-18 Thread Rob
As per my previous post, init your array with @columns = () instead of @columns = "" Cheers, Rob - Original Message - From: "Vincent Lee" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, October 17, 2002 12:47 PM Subject: Join problem > Hello All, > > I've got a

Re: Join problem

2002-10-17 Thread Dharmender Rai
It may be the case that there is the first value that is not visible that is the value is a null string. Otherwise it should work. --- Vincent Lee <[EMAIL PROTECTED]> wrote: > Hello All, > > I've got a problem with the JOIN function > > I've got a list of columns that gets returned from > the

RE: join hashes?

2002-09-24 Thread david
Keith wrote: > I've been working with perl for a while now, and I still have not been > able to grasp the concept of references. I've got Beginning Perl by Simon > Cozens published by Wrox, I have the Camel, and the cookbook. After > reading the information, and trying to ask people as well I sti

RE: join hashes?

2002-09-24 Thread Sudarshan Raghavan
-- Forwarded message -- Date: Thu, 26 Sep 2002 12:22:33 +0530 (IST) From: Sudarshan Raghavan <[EMAIL PROTECTED]> To: "Meidling, Keith, CTR, OSD-C3I" <[EMAIL PROTECTED]> Subject: RE: join hashes? On Tue, 24 Sep 2002, Meidling, Keith, CTR, OSD-C3I wrote: &g

RE: join hashes?

2002-09-24 Thread Meidling, Keith, CTR, OSD-C3I
Message- From: david [mailto:[EMAIL PROTECTED]] Sent: Monday, September 23, 2002 2:57 PM To: [EMAIL PROTECTED] Subject: RE: join hashes? Sean D. Rowe wrote: > I know it's a reference to a hash. What I don't know is why it's printing > out like this. I have hash values that

RE: join hashes?

2002-09-23 Thread david
Sean D. Rowe wrote: > I know it's a reference to a hash. What I don't know is why it's printing > out like this. I have hash values that I need to print out, but not in you know it's a reference to a hash. good. the HASH(Ox1c6ed80) thingy is the memory address of the reference. > any order,

RE: join hashes?

2002-09-23 Thread nkuipers
>I don't think I completely understand your code. When you put > > 'join( '|', values %hash )' That line of code is read pretty much the way it looks. It's like saying "Ok Perl, I want you to grab all the values in this hash and glue 'em together with a pipe character". So for example,

RE: join hashes?

2002-09-23 Thread Rowe, Sean D.
s, but maybe I'm missing something. I'm really grateful for your help, but could you be a bit more specific? I'd appreciate it. Thanks. Sean -Original Message- From: John W. Krahn [mailto:[EMAIL PROTECTED]] Sent: Saturday, September 21, 2002 5:32 AM To: [EMAIL PROTECTED] S

Re: join hashes?

2002-09-21 Thread John W. Krahn
"Sean D. Rowe" wrote: > > ( this message was accidentally submitted under the subject RE: getpid? > Sorry ) > > I'm having a very strange problem that I'm hoping someone has come across > before. I'm using a hash to collect some field values. I want to write the > hash values to file, and I wa

RE: join

2002-01-31 Thread Deen Hameed
is this scary or what? LOL :) On Thu, 31 Jan 2002, Deen Hameed wrote: > > the ? is a special character within a regular expression (which is what > the two /s inside split contain). If you want to split on the ?, you'll > have to escape it, like \? > > Have a look at perldoc perlre for what re

Re: join

2002-01-31 Thread Deen Hameed
the ? is a special character within a regular expression (which is what the two /s inside split contain). If you want to split on the ?, you'll have to escape it, like \? Have a look at perldoc perlre for what regular expressions are about. deen On Thu, 31 Jan 2002, Darren Simpson wrote: > hi

Re: join

2002-01-31 Thread Jason Purdy
Oops - split cannot take "?" as its first parameter - I apologize ... go w/ the /\?/ approach. :) Jason If memory serves me right, on Thursday 31 January 2002 11:15, Jason Purdy wrote: > The //'s around the ? treat the first paramater of the split() function as > a regular expression, which tr

Re: join

2002-01-31 Thread Jason Purdy
The //'s around the ? treat the first paramater of the split() function as a regular expression, which treats the question mark as a special character (saying to match the preceding char(s) zero or one time). If you're trying to split $testdata with an actual question mark, try using quotes in

RE: join

2002-01-31 Thread Nikola Janceski
? is a special charater (a quantifier like * or {6} ) it quantifies to 0 or 1; it's also a modifier to a quantifier causing it to match the least of the quantifier. Just put a \ in front of it split(/\?/,$testdata); -Original Message- From: Darren Simpson [mailto:[EMAIL PROTECTED]] Sen

RE: join

2002-01-31 Thread Hanson, Robert
The question mark is a special character in a regular expression meaning "zero or one" and *must* follow a character or character class. If you want to split on the question mark character you need to escape it so that it no longer has special meaning. Like this: split(/\?/,$testdata); Rob --