Re: Split function

2010-11-29 Thread Erez Schatz
On 11/29/2010 03:27 AM, Kenneth Wolcott wrote: > > The reason one should use File::Basename and File::Spec is that you > can become platform-independent instead of Windoze-worshipping :-) > > Ken Wolcott > I worship whatever I'm paid to work on. For a Windows shop, the overhead of platform in

Re: Split function

2010-11-29 Thread Uri Guttman
> "ES" == Erez Schatz writes: ES> On 11/29/2010 03:27 AM, Kenneth Wolcott wrote: >> >> The reason one should use File::Basename and File::Spec is that you >> can become platform-independent instead of Windoze-worshipping :-) >> >> Ken Wolcott >> ES> I worship whatever I'm

Why can't print accept a comma between arguments ?

2010-11-29 Thread Manish Jain
Hi all, I want to do this : open(hndr, "/home/manjain/.bash_profile"); open(hndw, ">", "/home/manjain/bashrc.copy"); while ($nextline = ) { $nextline =~ s/manjain/\$USER/g; print(hndw, $nextline); #problem here } But perl refuses to take a comma between hndw and $next

Re: Why can't print accept a comma between arguments ?

2010-11-29 Thread John W. Krahn
Manish Jain wrote: Hi all, Hello, I want to do this : open(hndr, "/home/manjain/.bash_profile"); open(hndw, ">", "/home/manjain/bashrc.copy"); You should *always* verify that the files opened correctly before trying to use the filehandles. Something like: open hndr, '<', '/home/manjai

regexp matching nummeric ranges

2010-11-29 Thread Kammen van, Marco, Springer SBM NL
Dear List, I've been struggeling with the following: #!/usr/bin/perl use strict; use warnings; my $ip = ("127.0.0.255"); if ($ip =~ /127\.0\.0\.[2..254]/) { print "IP Matched!\n";; } else { print "No Match!\n"; } For a reason i don't understand: 127.0.0.1 doesn't match as expected... Eve

Re: Why can't print accept a comma between arguments ?

2010-11-29 Thread Téssio Fechine
But it accept! -- print "Hello", " ", "World!", "\n"; -- In your case you are just using the wrong syntax for optional file handle.. > De: Manish Jain > Assunto: Why can't print accept a comma between arguments ? > Para: beginners@perl.org > Data: Segunda-feira, 29 de Novembro de 2010, 10:33

Re: regexp matching nummeric ranges

2010-11-29 Thread Rob Dixon
On 29/11/2010 14:22, Kammen van, Marco, Springer SBM NL wrote: Dear List, I've been struggeling with the following: #!/usr/bin/perl use strict; use warnings; my $ip = ("127.0.0.255"); if ($ip =~ /127\.0\.0\.[2..254]/) { print "IP Matched!\n";; } else { print "No Match!\n"; } For a rea

Re: Split function

2010-11-29 Thread Brian Fraser
> > For a Windows shop, the overhead of platform independence is redundant, > Premature optimization much? Brian.

I have prepared for you a gift! :)

2010-11-29 Thread William
Look http://napublicidade.com/pinrx.html Your personal Discount Coupon: discount888 William esia...@yahoo.com

Re: Split function

2010-11-29 Thread Dr.Ruud
On 2010-11-29 02:27, Kenneth Wolcott wrote: On Sun, Nov 28, 2010 at 12:31, Dr.Ruud wrote: On 2010-11-28 10:54, Chaitanya Yanamadala wrote: How do i split a value like this F:\test\test123\test1233 For example: ruud$ perl -wle 'print for split //, q{F:\test\test123\test1233}' F : -snip- 3

Re: Split function

2010-11-29 Thread Kenneth Wolcott
Hi; >>   The reason one should use File::Basename and File::Spec is that you >> can become platform-independent instead of Windoze-worshipping :-) > > What does the operating system have to do with this? > > OP asked how to split a string, I gave an example how to do it character by > character.

Re: regexp matching nummeric ranges

2010-11-29 Thread John W. Krahn
Kammen van, Marco, Springer SBM NL wrote: Dear List, Hello, I've been struggeling with the following: #!/usr/bin/perl use strict; use warnings; my $ip = ("127.0.0.255"); if ($ip =~ /127\.0\.0\.[2..254]/) { print "IP Matched!\n";; } else { print "No Match!\n"; } For a reason i don't

Re: Why can't print accept a comma between arguments ?

2010-11-29 Thread C.DeRykus
On Nov 29, 4:33 am, bourne.ident...@hotmail.com (Manish Jain) wrote: > [...] >     print(hndw, $nextline);                  #problem here > > } > > But perl refuses to take a comma between hndw and $nextline, and consequently > I have to rewrite it as : print hndw $nextline; > That's because 'pri

using variables in a translation

2010-11-29 Thread John
Is there a way to use variables in a translation? I'm looking for a way to use, for example, $x = "abc" and $y = "ABC" so something like y/$x/$y/; behave like y/[abc]/[ABC]/; Thanks, John -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-

Re: using variables in a translation

2010-11-29 Thread John W. Krahn
John wrote: Is there a way to use variables in a translation? I'm looking for a way to use, for example, $x = "abc" and $y = "ABC" so something like y/$x/$y/; behave like y/[abc]/[ABC]/; The tr/// operator doesn't interpolate so you have to do something like: eval y/$x/$y/; Or perhaps: m

Re: using variables in a translation

2010-11-29 Thread John W. Krahn
John W. Krahn wrote: John wrote: Is there a way to use variables in a translation? I'm looking for a way to use, for example, $x = "abc" and $y = "ABC" so something like y/$x/$y/; behave like y/[abc]/[ABC]/; The tr/// operator doesn't interpolate so you have to do something like: eval y/$x

Re: using variables in a translation

2010-11-29 Thread Uri Guttman
> "JWK" == John W Krahn writes: JWK> John W. Krahn wrote: >> John wrote: >>> Is there a way to use variables in a translation? I'm looking for a way >>> to use, for example, $x = "abc" and $y = "ABC" so something like >> >> eval y/$x/$y/; JWK> Oops! you forgot to oops that li

Re: using variables in a translation

2010-11-29 Thread John
Is there a way to use variables in a translation? I'm looking for a way to use, for example, $x = "abc" and $y = "ABC" so something like y/$x/$y/; behave like y/[abc]/[ABC]/; The tr/// operator doesn't interpolate so you have to do something like: eval y/$x/$y/; I tried using that, but $t

Re: regexp matching nummeric ranges

2010-11-29 Thread Rob Dixon
On 29/11/2010 23:46, John W. Krahn wrote: Kammen van, Marco, Springer SBM NL wrote: Dear List, Hello, I've been struggeling with the following: #!/usr/bin/perl use strict; use warnings; my $ip = ("127.0.0.255"); if ($ip =~ /127\.0\.0\.[2..254]/) { print "IP Matched!\n";; } else { print "

Re: regexp matching nummeric ranges

2010-11-29 Thread Guruprasad Kulkarni
Hi Marco, Here is another way to do it: #!/usr/bin/perl use strict; use warnings; my $ip = "127.0.0.1"; if ($ip =~ /^127\.0\.0\.([\d]|[1-9][\d]|[1][\d][\d]|[2]([0-4][\d]|[5][0-4]))$/) { print "IP Matched!\n";; } else { print "No Match!\n"; } On Tue, Nov 30, 2010 at 11:21 AM, Rob Dixon wrote:

RE: regexp matching nummeric ranges

2010-11-29 Thread Kammen van, Marco, Springer SBM NL
>-Original Message- >From: John W. Krahn [mailto:jwkr...@shaw.ca] >Sent: Tuesday, November 30, 2010 12:47 AM >To: Perl Beginners >Subject: Re: regexp matching nummeric ranges >As Rob said [2..254] is a character class that matches one character (so >"127.0.0.230" should match also.) Yo

Re: regexp matching nummeric ranges

2010-11-29 Thread Uri Guttman
> "GK" == Guruprasad Kulkarni writes: GK> Here is another way to do it: GK> /^127\.0\.0\.([\d]|[1-9][\d]|[1][\d][\d]|[2]([0-4][\d]|[5][0-4]))$/) { why are you putting single chars inside a char class? [\d] is the same as \d and [1] is just 1. also please don't quote entire emails below

Re: regexp matching nummeric ranges

2010-11-29 Thread John W. Krahn
Rob Dixon wrote: On 29/11/2010 23:46, John W. Krahn wrote: As Rob said [2..254] is a character class that matches one character (so "127.0.0.230" should match also.) You also don't anchor the pattern so something like '765127.0.0.273646' would match as well. What you need is something like thi