RE: regex puzzle

2005-07-29 Thread bingfeng zhao
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

Re: regex puzzle

2005-07-29 Thread Flemming Greve Skovengaard
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

Want code to display date in different timezone

2005-07-29 Thread Anil Kumar, Malyala
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

Re: regex puzzle

2005-07-29 Thread Roberto Ruiz
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):\/\/)?.+$/; # ^ ^

Read a single line in a file.

2005-07-29 Thread Umesh T G
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

RE: error message with net::FTP

2005-07-29 Thread Laurent Coudeur
-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

$#{$array}

2005-07-29 Thread Vineet Pande
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

Re: $#{$array}

2005-07-29 Thread Umesh T G
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

RE: Read a single line in a file.

2005-07-29 Thread arjun.mallik
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:

RE: $#{$array}

2005-07-29 Thread Moon, John
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

Re: $#{$array}

2005-07-29 Thread Jeff 'japhy' Pinyan
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,

Re: Getting Date Stamp of a file on a Win32 System

2005-07-29 Thread Dave Adams
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 =

Grep uniqueness issue

2005-07-29 Thread jason_normandin
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

Re: Grep uniqueness issue

2005-07-29 Thread Eric Walker
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)

Re: Re: Grep uniqueness issue

2005-07-29 Thread jason_normandin
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

Re: Grep uniqueness issue

2005-07-29 Thread Jeff 'japhy' Pinyan
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

Re: Re: Grep uniqueness issue

2005-07-29 Thread jason_normandin
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:

RE: Grep uniqueness issue

2005-07-29 Thread Ankur Gupta
[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

Re: regex puzzle

2005-07-29 Thread Pedro Henrique Calais
/^((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

Remembering Positions in Array after processing the element

2005-07-29 Thread Edward WIJAYA
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

Re: Getting Date Stamp of a file on a Win32 System

2005-07-29 Thread Robert
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

regular expression match question

2005-07-29 Thread Pine Yan
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

Re: IF statements and modules - do they mix?

2005-07-29 Thread Scott R. Godin
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

Re: Want code to display date in different timezone

2005-07-29 Thread Wiggins d'Anconia
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

Re: regular expression match question

2005-07-29 Thread Jeff 'japhy' Pinyan
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

RE: regular expression match question

2005-07-29 Thread Pine Yan
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

RE: regular expression match question

2005-07-29 Thread Jeff 'japhy' Pinyan
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)+?

Re: regular expression match question

2005-07-29 Thread Tom Allison
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]}, \$

RE: regular expression match question

2005-07-29 Thread Pine Yan
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

Re: $#{$array}

2005-07-29 Thread Tom Allison
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

Re: Grep uniqueness issue

2005-07-29 Thread Tom Allison
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

Re: regex puzzle

2005-07-29 Thread Tom Allison
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):\/\/)?.+$/; # ^

Re: Want code to display date in different timezone

2005-07-29 Thread Tom Allison
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

Re: passing hash data from one subroutine to another using refs

2005-07-29 Thread Tom Allison
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

Re: login shell?

2005-07-29 Thread Tom Allison
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

RE: regular expression match question

2005-07-29 Thread Pine Yan
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

newbie help for podcast script

2005-07-29 Thread alexeijh
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 ...

newbie help for podcast script [with attach]

2005-07-29 Thread alexeijh
*** 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

RE: regular expression match question

2005-07-29 Thread Jeff 'japhy' Pinyan
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.

RE: regular expression match question

2005-07-29 Thread Pine Yan
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

Re: $#{$array}

2005-07-29 Thread John W. Krahn
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

RE: Want code to display date in different timezone

2005-07-29 Thread Tim Johnson
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

Re: newbie help for podcast script [with attach]

2005-07-29 Thread John W. Krahn
[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

Re: login shell?

2005-07-29 Thread John W. Krahn
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

Re: Remembering Positions in Array after processing the element

2005-07-29 Thread John W. Krahn
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(

Perl framework for windows-prob in makefile

2005-07-29 Thread Dhanashri Bhate
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