Re: A simple question about the Perl line

2009-11-27 Thread Majian
Thanks all . On Sat, Nov 28, 2009 at 3:00 AM, Randal L. Schwartz wrote: > > "Majian" == Majian writes: > > Majian> Hi ,all: > Majian> I have a problem about this : > > Majian> cat test: > Majian> 12 > Majian> 23 > Majian> 34 > Majian> 45 > Majian> 56 > Majian> 67 > > Majian> I want to bec

Re: a simple question about the line

2009-11-27 Thread Chris Charley
- Original Message - From: "Dermot" Newsgroups: perl.beginners To: "John W. Krahn" Cc: "Perl Beginners" Sent: Friday, November 27, 2009 12:29 PM Subject: Re: a simple question about the line 2009/11/27 John W. Krahn : Hello, $ echo &quo

Re: A simple question about the Perl line

2009-11-27 Thread Randal L. Schwartz
> "Majian" == Majian writes: Majian> Hi ,all: Majian> I have a problem about this : Majian> cat test: Majian> 12 Majian> 23 Majian> 34 Majian> 45 Majian> 56 Majian> 67 Majian> I want to become like this : Majian> 1223 Majian> 3445 Majian> 5667 Majian> I thought it for a long time , but I

Re: a simple question about the line

2009-11-27 Thread Dermot
2009/11/27 John W. Krahn : > Hello, > > $ echo "12 > 23 > 34 > 45 > 56 > 67 > 78" | perl -lpe'$\=--$|?$,:$/' > 1223 > 3445 > 5667 > 78 For the benefit of this Luddite, please explain? Dp. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@

Re: a simple question about the line

2009-11-27 Thread John W. Krahn
Majian wrote: Hi, all : Hello, I have a problem about the lines of the file , like this : cat test 12 23 34 45 56 67 78 ... == I want to display like this : 1223 3445 5667 It means the next line is after the last line . How do it by the Perl ? $ echo "12 23 34 45 56 6

Re: A simple question about the Perl line

2009-11-27 Thread lan messerschmidt
On Fri, Nov 27, 2009 at 8:34 PM, Majian wrote: > Could  you explain  it ? > > What is the meaning of the $.? And Why use  the "%2"  operator? > $. means the line number, see perldoc perlvar and look for $. %2 means the modulus operator. # perl -le 'print $_%2 for 0..3' 0 1 0 1 HTH. -- To unsub

a simple question about the line

2009-11-27 Thread Majian
Hi, all : I have a problem about the lines of the file , like this : cat test 12 23 34 45 56 67 78 ... == I want to display like this : 1223 3445 5667 It means the next line is after the last line . How do it by the Perl ? Thanks in advance ~ -- To unsubscribe, e-

Re: A simple question about the Perl line

2009-11-27 Thread lan messerschmidt
On Fri, Nov 27, 2009 at 8:03 PM, Majian wrote: > Hi ,all: > > I have a problem about this : > > cat test: > 12 > 23 > 34 > 45 > 56 > 67 > ... > > I want to become like this : > 1223 > 3445 > 5667 > ... > # perl -e ' $m=<) { chomp if $.%2; print; }' 1223 3445 5667 -- To unsubscribe, e-m

A simple question about the Perl line

2009-11-27 Thread Majian
Hi ,all: I have a problem about this : cat test: 12 23 34 45 56 67 ... I want to become like this : 1223 3445 5667 ... That means the next line is after the above line ~ I thought it for a long time , but I have no idea yet~~ Can someone help me ? Thanks

Re: while() I have a simple question

2009-07-23 Thread Chas. Owens
On Thu, Jul 23, 2009 at 21:29, Steve Bertrand wrote: > I just ran into an issue where I was loosing literally half of some > expected data, which for a theoretical accounting system, would make for > some interesting audit trails (I already shave a fraction for myself, > but 50% will be noticeable

while() I have a simple question

2009-07-23 Thread Steve Bertrand
I just ran into an issue where I was loosing literally half of some expected data, which for a theoretical accounting system, would make for some interesting audit trails (I already shave a fraction for myself, but 50% will be noticeable ;) Is my oversight as simple as knowing that the previous-to

Re: a simple question

2004-06-16 Thread WilliamGunther
In a message dated 6/16/2004 12:10:54 PM Eastern Daylight Time, [EMAIL PROTECTED] writes: >Thanks in advance for your kind help. > >For the following string: > >" axyzb cxyzd " > >What is the command to extract the substrings with "xyz" in them? In this case, I'd like to >get two st

Re: a simple question

2004-06-16 Thread Bernard Kenik
This code should do it. my $List = " axyzb cxyzd "; my @Words = split(' ', $List); print "@Words\n"; my $Word; my @xyz; foreach $Word (@Words) { push @xyz, $Word if $Word =~ /.*xyz.*/; } print "@xyz"; "Kevin Zhang" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Tha

Re: Identifying words containing a specific substring in a sentence (was: a simple question)

2004-06-16 Thread Jeff 'japhy' Pinyan
On Jun 16, Kevin Zhang said: >One more question, how do I strip out all letters before "xyz". For the >original example, how would I get "xyzb" and "xyzd"? I would suggest this slightly modified grep(): my @matches = grep { /(xyz.*)/ and ($_ = $1) } split ' ', $string; Here, instead o

Re: Identifying words containing a specific substring in a sentence (was: a simple question)

2004-06-16 Thread Kevin Zhang
Thank you so much (and for the tip too). It works great! One more question, how do I strip out all letters before "xyz". For the original example, how would I get "xyzb" and "xyzd"? Thanks again, Kevin David Dorward <[EMAIL PROTECTED]> wrote: Tip: This is a beginners list, therefore many que

Re: a simple question

2004-06-16 Thread Jeff 'japhy' Pinyan
On Jun 16, Kevin Zhang said: >For the following string: > >" axyzb cxyzd " > >What is the command to extract the substrings with "xyz" in them? In this >case, I'd like to get two strings "axyzb" and "cxyzd". Well, you could do: my @matches = grep /xyz/, split ' ', $string; Let me

Identifying words containing a specific substring in a sentence (was: a simple question)

2004-06-16 Thread David Dorward
Tip: This is a beginners list, therefore many questions will be simple. Aim for more descriptive subject lines and life will be easier for users of the list archives. On 16 Jun 2004, at 17:10, Kevin Zhang wrote: For the following string: " axyzb cxyzd " What is the command to extrac

a simple question

2004-06-16 Thread Kevin Zhang
Thanks in advance for your kind help. For the following string: " axyzb cxyzd " What is the command to extract the substrings with "xyz" in them? In this case, I'd like to get two strings "axyzb" and "cxyzd". - Do you Yahoo!? Y

RE: probably a simple question

2002-06-05 Thread Bryan R Harris
uot;blue\n" : print "red\n" } > -Original Message- > From: Bryan R Harris [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, June 05, 2002 1:52 PM > To: [EMAIL PROTECTED] > Subject: Re: probably a simple question > > > > > > $_ % 2 ? print "bl

Re: probably a simple question

2002-06-05 Thread Janek Schleicher
Bryan R Harris wrote at Wed, 05 Jun 2002 19:51:49 +0200: >> $_ % 2 ? print "blue\n" : print "red\n" foreach (@your_list); > > > This actually works?! Very strange notation, how does the compiler see this line? >I assume the > mod operator evaluates to 1-true or 0-false, what does the "?" do?

RE: probably a simple question

2002-06-05 Thread David . Wagner
, June 05, 2002 10:52 To: [EMAIL PROTECTED] Subject: Re: probably a simple question > $_ % 2 ? print "blue\n" : print "red\n" foreach (@your_list); This actually works?! Very strange notation, how does the compiler see this line? I assume the mod operator evaluates to 1-tru

RE: probably a simple question

2002-06-05 Thread Nikola Janceski
an R Harris [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, June 05, 2002 1:52 PM > To: [EMAIL PROTECTED] > Subject: Re: probably a simple question > > > > > > $_ % 2 ? print "blue\n" : print "red\n" foreach (@your_list); > > > This actually w

Re: probably a simple question

2002-06-05 Thread Bryan R Harris
> $_ % 2 ? print "blue\n" : print "red\n" foreach (@your_list); This actually works?! Very strange notation, how does the compiler see this line? I assume the mod operator evaluates to 1-true or 0-false, what does the "?" do? What does the ":" do? How do you have a foreach at the end of a

RE: probably a simple question

2002-06-05 Thread Bob Showalter
> -Original Message- > From: Zachary Buckholz [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, June 04, 2002 10:11 PM > To: [EMAIL PROTECTED] > Subject: probably a simple question > > > Is there any function to tell if a number is even or odd? > I am looking for an

Re: probably a simple question

2002-06-05 Thread Rajeev Rumale
> Sent: Wednesday, June 05, 2002 5:01 PM Subject: Re: probably a simple question > Zachary Buckholz wrote: > > > Is there any function to tell if a number is even or odd? > > I am looking for an easy way to loop through a list and > > output table cell bgcolor based on eve

Re: probably a simple question

2002-06-05 Thread Sudarsan Raghavan
Zachary Buckholz wrote: > Is there any function to tell if a number is even or odd? > I am looking for an easy way to loop through a list and > output table cell bgcolor based on even / odd. > > if its an even numbered row make it red if its odd make > it blue. $_ % 2 ? print "blue\n" : print "r

Re: probably a simple question

2002-06-05 Thread Tor Hildrum
> Is there any function to tell if a number is even or odd? > I am looking for an easy way to loop through a list and > output table cell bgcolor based on even / odd. > > if its an even numbered row make it red if its odd make > it blue. > > I have done it in the past by turning a switch on or o

probably a simple question

2002-06-05 Thread Zachary Buckholz
Is there any function to tell if a number is even or odd? I am looking for an easy way to loop through a list and output table cell bgcolor based on even / odd. if its an even numbered row make it red if its odd make it blue. I have done it in the past by turning a switch on or off but I think t

RE: A simple question

2002-05-20 Thread Shishir K. Singh
AM To: 'Stuart Clark'; 'Perl List' Subject: RE: A simple question > -Original Message- > From: Stuart Clark [mailto:[EMAIL PROTECTED]] > Sent: Friday, May 17, 2002 11:08 PM > To: 'Perl List' > Subject: A simple question > > > Hi All

RE: A simple question

2002-05-20 Thread Bob Showalter
> -Original Message- > From: Stuart Clark [mailto:[EMAIL PROTECTED]] > Sent: Friday, May 17, 2002 11:08 PM > To: 'Perl List' > Subject: A simple question > > > Hi All > Is there an easier way of picking out the number 16764 in this line > rather t

a simple question

2002-05-18 Thread Stuart Clark
Hi All Is there an easier way of picking out the number 16764 in this line rather that using an array, split then $number[3] I just want to get 16764 into $recievedmail Is the answer something like this $recievedmail = ($data)[3]; $data = "Received 921MB 16764 3955 375 2.2% 1296 7.7%";

Re: A simple question

2002-05-17 Thread John W. Krahn
Stuart Clark wrote: > > Hi All > Is there an easier way of picking out the number 16764 in this line > rather that using an array, split then $number[3] > > I just want to get 16764 into $recievedmail > > Is the answer something like this > > $recievedmail = ($data)[3]; > > $data = "Received

A simple question

2002-05-17 Thread Stuart Clark
Hi All Is there an easier way of picking out the number 16764 in this line rather that using an array, split then $number[3] I just want to get 16764 into $recievedmail Is the answer something like this $recievedmail = ($data)[3]; $data = "Received 921MB 16764 3955 375 2.2% 1296 7.7%";

Re: a simple question

2002-02-26 Thread Michael Kelly
On 2/26/02 10:27 PM, jds <[EMAIL PROTECTED]> wrote: > #win2k system > > ... > @array=; > ... > > Q:when running,how to break the input,and not exit program? Hi jds, Your EOF char. On most systems, this is ^D, and on Windows I believe it is ^Z. Hope that helps, -- Michael -- To unsubscrib

a simple question

2002-02-26 Thread jds
#win2k system ... @array=; ... Q:when running,how to break the input,and not exit program?

Re: A simple question

2001-07-10 Thread Craig Moynes/Markham/IBM
From: Jie Meng <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, July 10, 2001 5:02 PM Subject: A simple question > > Dear all, > > I plan to write a simple remote connection script, and then "ls" the content > > of the current directory, inpu

Re: A simple question

2001-07-10 Thread M.W. Koskamp
- Original Message - From: Jie Meng <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, July 10, 2001 5:02 PM Subject: A simple question Dear all, I plan to write a simple remote connection script, and then "ls" the content of the current directory, input

Re: A simple question

2001-07-10 Thread Luke Bakken
Use rsh or ssh - system "rsh -l $username $hostname ls"; for the above to wrk without a password, your client machine's hostname must be in $username's .rhosts file. Better yet, use ssh with RSA or DSA authentication - then you won't be exposing your password in plaintext. There's also a Net::

Re: A simple question

2001-07-10 Thread Craig S Monroe
IL PROTECTED]> Sent: Tuesday, July 10, 2001 11:02 AM Subject: A simple question Dear all, I plan to write a simple remote connection script, and then "ls" the content of the current directory, input like telnet hostname username password ls I use the following script: system (&q

A simple question

2001-07-10 Thread Jie Meng
Dear all, I plan to write a simple remote connection script, and then "ls" the content of the current directory, input like telnet hostname username password ls I use the following script: system ("telnet hostname"); = "username\n"; = "password\n"; system ("ls"); It failed in the syntax.