Oh, bug,it should be
CODE
use warnings;
use strict;
my @address = (http://test;, http://;, www, , ftp:/foo );
for (@address)
{
print \$_\ is valid. \n if /^((http|ftp):\/\/)?.+$/;
}
/CODE
|-Original Message-
|From: bingfeng zhao [mailto:[EMAIL PROTECTED]
|Sent: Friday, July
bingfeng zhao wrote:
See following sample code:
CODE
use warnings;
use strict;
my @address = (http://test;, http://;, www, , ftp:/foo );
for (@address)
{
print \$_\ passed! \n if /^((http|ftp):\/\/)?.+$/;
}
/CODE
the running result is:
http://test; is valid.
http://; is valid.
www
Hi friends,
Can you help me out.
I have a program in which the time zone is GMT and the time is displayed
as Thu, 28 Jul 2005 11:21:17 GMT.
I want to display the time in IST. How can I achieve this in PERL.
Regards,
Anil Kumar Malyala
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For
On Fri, Jul 29, 2005 at 01:48:15PM +0800, bingfeng zhao wrote:
See following sample code:
my @address = (http://test;, http://;, www, , ftp:/foo );
for (@address)
{
print \$_\ passed! \n if /^((http|ftp):\/\/)?.+$/;
# ^ ^
Hello List,
I have a file with multiple lines. I want to read only the first line.
and a particular word in that line.
For eg:
File.txt
apple,grape,orange,banana
some other lines
continued.
So I want only the word grape here. How to get it?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For
-Original Message-
From: Owen [mailto:[EMAIL PROTECTED]
Sent: 29 July 2005 00:07
To: beginners@perl.org
Subject: Re: error message with net::FTP
On Thu, 28 Jul 2005 10:17:35 -0400
Laurent Coudeur [EMAIL PROTECTED] wrote:
I am having some trouble with net::FTP module I get this error
Hi,
I don't not understand how the $#{$array_r} returns highest element as 4
and not 5???
#!/usr/bin/perl
use warnings;
use strict;
my @array = (1,2,3,4,5);
my $array_r = [EMAIL PROTECTED];
print the highest element is number $#{$array_r}\n;
Cheers
V
Hi,
On 7/29/05, Vineet Pande [EMAIL PROTECTED] wrote:
I don't not understand how the $#{$array_r} returns highest element as 4
and not 5???
#!/usr/bin/perl
use warnings;
use strict;
my @array = (1,2,3,4,5);
my $array_r = [EMAIL PROTECTED];
print the highest element is number
Original Message-
From: Umesh T G [mailto:[EMAIL PROTECTED]
Sent: Friday, July 29, 2005 3:47 PM
To: beginners@perl.org
Subject: Read a single line in a file.
Hello List,
I have a file with multiple lines. I want to read only the first line.
and a particular word in that line.
For eg:
Subject: $#{$array}
Hi,
I don't not understand how the $#{$array_r} returns highest element as 4
and not 5???
#!/usr/bin/perl
use warnings;
use strict;
my @array = (1,2,3,4,5);
my $array_r = [EMAIL PROTECTED];
print the highest element is number $#{$array_r}\n;
FYI ...
SUN1-BATCHperl -e
On Jul 29, Vineet Pande said:
I don't not understand how the $#{$array_r} returns highest element as
4 and not 5???
$#arrayname returns the highest INDEX in the array -- that means it
returns the location of the last element in the array. If your array has
10 elements, $#array returns 9,
Robert,
Thanks very much. It works great. Your code was nice and simple.
Much appreciated.
DA
On 7/28/05, Robert [EMAIL PROTECTED] wrote:
I found this maybe it will help:
use strict;
use File::stat;
use POSIX qw(strftime);
my $file = 'test.txt';
my $s =
Hey Guys
I am having an odd problem using grep to ensure an array only contains distinct
entries.
I have a list similar to the following in a file (short example of a much
longer list)
support01-FastEthernet1/0
support01-RH
jnormandin-p370-1691-SH-Cpu-2
jnormandin-p370-1691-SH
These entries
can you use the uniq command?
On Friday 29 July 2005 09:03 am, [EMAIL PROTECTED] wrote:
Hey Guys
I am having an odd problem using grep to ensure an array only contains
distinct entries.
I have a list similar to the following in a file (short example of a much
longer list)
Unfortunately I cannot as this is a cross-platform implementation. I need to
avoid using any OS dependant commands.
From: Eric Walker [EMAIL PROTECTED]
Date: 2005/07/29 Fri AM 11:19:16 EDT
To: beginners@perl.org
CC: [EMAIL PROTECTED]
Subject: Re: Grep uniqueness issue
can you use the
On Jul 29, [EMAIL PROTECTED] said:
I am having an odd problem using grep to ensure an array only contains
distinct entries.
You should probably use a hash (along with your array, if you need to keep
the order they're in) to ensure unique-ness.
support01-FastEthernet1/0
support01-RH
Thanks.
Just so that I understand:
push @pingErrorsName, $element if !grep $_ eq $element, @pingErrorsName;
Is actually taking each value in @pingErrorsName and validating if it is equal
to $element.
From: Jeff 'japhy' Pinyan [EMAIL PROTECTED]
Date: 2005/07/29 Fri AM 11:32:15 EDT
To:
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:
Hey Guys
I am having an odd problem using grep to ensure an array only
contains distinct entries.
I have a list similar to the following in a file (short example of a
much longer list)
support01-FastEthernet1/0
support01-RH
/^((http|ftp):\/\/)?.+$/
In my opinion the problem is that ' .+' means 'anything',
and '' is matched by this part of the regex
( is anything too).
regards
Pedro
- Original Message -
From: Roberto Ruiz [EMAIL PROTECTED]
To: beginners@perl.org
Sent: Friday, July 29, 2005 6:52 AM
Hi,
I wanted to append two subsequent characters (non *) in
an array and then storing them into new array.
But then I also want to restore the '*' string in its
initial position in the new array result.
I have the code below but still not
achieving the task.
How can I modify them so that I can
Dave Adams [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Robert,
Thanks very much. It works great. Your code was nice and simple.
Much appreciated.
DA
I can't take credit. I just GOOGLE'd it.
Glad it helped.
Robert
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional
A script like this:
line1: $string3 = bacdeabcdefghijklabcdeabcdefghijkl;
line2: $string4 = xxyyzzbatttvv;
line3: print \$1 = $1 [EMAIL PROTECTED],$+[0]}, \$ = $\n
if($string3
=~ /(a|b)*/);
line4: print \$1 = $1 [EMAIL PROTECTED],$+[0]}, \$ = $\n
John W. Krahn wrote:
Scott R. Godin wrote:
Dave Adams wrote:
Does perl allow you to conditionally include a module?
[snip]
If you're using Perl 5.7.3 or later you can
use if $DEBUG, diagnostics -verbose;
details in 'perldoc if'
:)
And all you people who answered with something other
Anil Kumar, Malyala wrote:
Hi friends,
Can you help me out.
I have a program in which the time zone is GMT and the time is displayed
as Thu, 28 Jul 2005 11:21:17 GMT.
I want to display the time in IST. How can I achieve this in PERL.
Regards,
Anil Kumar Malyala
One option using
On Jul 29, Pine Yan said:
line1: $string3 = bacdeabcdefghijklabcdeabcdefghijkl;
line2: $string4 = xxyyzzbatttvv;
line3: print \$1 = $1 [EMAIL PROTECTED],$+[0]}, \$ = $\n
if($string3
=~ /(a|b)*/);
line4: print \$1 = $1 [EMAIL PROTECTED],$+[0]}, \$ = $\n
line1: $string3 = bacdeabcdefghijklabcdeabcdefghijkl;
line2: $string4 = xxyyzzbatttvv;
line3: print \$1 = $1 [EMAIL PROTECTED],$+[0]}, \$ = $\n
if($string3
=~ /(a|b)*/);
line4: print \$1 = $1 [EMAIL PROTECTED],$+[0]}, \$ = $\n
if($string4
=~ //);
$1 = a
On Jul 29, Pine Yan said:
line1: $string3 = bacdeabcdefghijklabcdeabcdefghijkl;
line2: $string4 = xxyyzzbatttvv;
If the regexp says match zero or more of (a or b), why can't we
match an empty string in the first place? What causes (a|b)* to make no
difference from (a|b)+?
Pine Yan wrote:
A script like this:
line1: $string3 = bacdeabcdefghijklabcdeabcdefghijkl;
line2: $string4 = xxyyzzbatttvv;
line3: print \$1 = $1 [EMAIL PROTECTED],$+[0]}, \$ = $\n
if($string3
=~ /(a|b)*/);
line4: print \$1 = $1 [EMAIL PROTECTED],$+[0]}, \$
The regex /[ab]*/ on the string bad matches 'ba' because regexes are
greedy by default. They want to match as MUCH as they can.
BUT regexes also try to find the earliest match in the string. This is
why /[ab]*/ on the string cab matches ''. Because the engine found a
successful match of 0
Vineet Pande wrote:
Hi,
I don't not understand how the $#{$array_r} returns highest element as
4 and not 5???
#!/usr/bin/perl
use warnings;
use strict;
my @array = (1,2,3,4,5);
my $array_r = [EMAIL PROTECTED];
print the highest element is number $#{$array_r}\n;
Cheers
V
Ankur Gupta wrote:
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:
Hey Guys
I am having an odd problem using grep to ensure an array only
contains distinct entries.
I have a list similar to the following in a file (short example of a
much longer list)
support01-FastEthernet1/0
Roberto Ruiz wrote:
On Fri, Jul 29, 2005 at 01:48:15PM +0800, bingfeng zhao wrote:
See following sample code:
my @address = (http://test;, http://;, www, , ftp:/foo );
for (@address)
{
print \$_\ passed! \n if /^((http|ftp):\/\/)?.+$/;
# ^
Anil Kumar, Malyala wrote:
Hi friends,
Can you help me out.
I have a program in which the time zone is GMT and the time is displayed
as Thu, 28 Jul 2005 11:21:17 GMT.
I want to display the time in IST. How can I achieve this in PERL.
Regards,
Anil Kumar Malyala
Another option is
sub func2 {
my ($ref_hash) = @_;
foreach my $key ( keys %$ref_hash ){
print $key: $ref_hash-{$key}\n;
}
}
What you can't do here is:
sub func2 {
my %hash = @_;
}
You've broken the reference back to the original hash.
you will
Bryan R Harris wrote:
Is there a way to determine in perl whether the current script was run from
a login shell or not?
- B
ENV{PS1} ???
That's mentioned in my .bashrc script
# If running interactively, then:
if [ $PS1 ]; then
so I assume that it's part of the %ENV and if so
According to perdoc, the // regexp does mean to inherit pervious
match.
So for me, line3 and line4 shall give the same result. Thus the second
case is correct,
while the first one doesn't make sense. And your example also reflects
this inherit
process.
Sincerely
Pine
-Original
Hi,
This is basically my 1st perl script.
It's a podcast download app. I don't now the etiquette for attaching
files, but I have attached a 100 line perl file.
It seems that it fails if there is only 1 podcast for a feed with:
fetching http://www.abc.net.au/science/k2/podcast/drk_rss.xml ...
*** SORRY, forgot to attach file. ***
Hi,
This is basically my 1st perl script.
It's a podcast download app. I don't now the etiquette for attaching
files, but I have attached a 100 line perl file.
It seems that it fails if there is only 1 podcast for a feed with:
fetching
On Jul 29, Pine Yan said:
line3: print \$1 = $1 [EMAIL PROTECTED],$+[0]}, \$ = $\n
if($string3
=~ /(a|b)*/);
line4: print \$1 = $1 [EMAIL PROTECTED],$+[0]}, \$ = $\n
if($string4
=~ //);
$1 = a @{0,2}, $ = ba
$1 = @{0,0}, $ =
I'll go over it again.
No more questions. :D
Sincerely
Pine
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response
Tom Allison wrote:
Vineet Pande wrote:
I don't not understand how the $#{$array_r} returns highest element
as 4 and not 5???
#!/usr/bin/perl
use warnings;
use strict;
my @array = (1,2,3,4,5);
my $array_r = [EMAIL PROTECTED];
print the highest element is number $#{$array_r}\n;
You can
The Time::Local module also works well.
-Original Message-
From: Tom Allison [mailto:[EMAIL PROTECTED]
Sent: Friday, July 29, 2005 4:03 PM
To: Anil Kumar, Malyala
Cc: beginners@perl.org
Subject: Re: Want code to display date in different timezone
[Tim Johnson] snip
Another option is
[EMAIL PROTECTED] wrote:
*** SORRY, forgot to attach file. ***
Hi,
Hello,
This is basically my 1st perl script.
It's a podcast download app. I don't now the etiquette for attaching
files, but I have attached a 100 line perl file.
It seems that it fails if there is only 1 podcast for
Tom Allison wrote:
Bryan R Harris wrote:
Is there a way to determine in perl whether the current script was run
from
a login shell or not?
ENV{PS1} ???
That's mentioned in my .bashrc script
# If running interactively, then:
if [ $PS1 ]; then
so I assume that it's part of the
Edward WIJAYA wrote:
Hi,
Hello,
I wanted to append two subsequent characters (non *) in
an array and then storing them into new array.
But then I also want to restore the '*' string in its
initial position in the new array result.
Perhaps this will give you some ideas:
perl -le'
@x = qw(
Hi!
I'm trying to get Perl framework installed on windows.
But the problem is in one of the makefiles...
don't know if this is the right place to ask this question, but could not find
any info anywhere else! :(
in a makefile the char \ means line continuation,
but if i have a macro in the
46 matches
Mail list logo