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
- 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
> "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
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...@
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
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
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-
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
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
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
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
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
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
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
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
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
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
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
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
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?
, 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
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
> $_ % 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
> -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
>
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
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
> 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
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
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
> -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
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%";
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
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%";
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
#win2k system
...
@array=;
...
Q:when running,how to break the input,and not exit program?
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
- 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
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::
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
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.
40 matches
Mail list logo