Re: regx substitution question

2012-09-05 Thread John W. Krahn
Shlomi Fish wrote: thanks for your answer. See below for my response. On Wed, 5 Sep 2012 09:54:11 -0400 Shawn H Corey wrote: On Wed, 5 Sep 2012 14:33:13 +0100 jet speed wrote: i have an regx question. i have the array contents, now i want to remove the first 2 characters (fc) of each elem

Re: regx substitution question

2012-09-05 Thread John W. Krahn
Shlomi Fish wrote: Replying to myself, I have a correction which Shawn inspired. On Wed, 5 Sep 2012 16:49:42 +0300 Shlomi Fish wrote: On Wed, 5 Sep 2012 14:33:13 +0100 jet speed wrote: i have an regx question. i have the array contents, now i want to remove the first 2 characters (fc) of e

Re: regx substitution question

2012-09-05 Thread John W. Krahn
Shlomi Fish wrote: On Wed, 5 Sep 2012 14:33:13 +0100 jet speed wrote: i have an regx question. i have the array contents, now i want to remove the first 2 characters (fc) of each element in the array and store it in a second array ex: @array2 @array ="fc20/1, fc30/22, fc40/3, fc20/1"; outpu

Re: regx substitution question

2012-09-05 Thread Jim Gibson
On Sep 5, 2012, at 7:02 AM, Shlomi Fish wrote: >># remove the first 2 characters from every element of the array >>my @array2 = map { s/^..//msx } @array1; >> > > This code is wrong in two respects: > > 1. the map clause will return the return value of the s/// subtitution and > will

Re: regx substitution question

2012-09-05 Thread Shlomi Fish
Replying to myself, I have a correction which Shawn inspired. On Wed, 5 Sep 2012 16:49:42 +0300 Shlomi Fish wrote: > Hi Sj, > > On Wed, 5 Sep 2012 14:33:13 +0100 > jet speed wrote: > > > Hi All, > > > > i have an regx question. i have the array contents, now i want to > > remove the first 2

Re: regx substitution question

2012-09-05 Thread Shlomi Fish
Hi Shawn, thanks for your answer. See below for my response. On Wed, 5 Sep 2012 09:54:11 -0400 Shawn H Corey wrote: > On Wed, 5 Sep 2012 14:33:13 +0100 > jet speed wrote: > > > Hi All, > > > > i have an regx question. i have the array contents, now i want to > > remove the first 2 characters

Re: regx substitution question

2012-09-05 Thread Shawn H Corey
On Wed, 5 Sep 2012 14:33:13 +0100 jet speed wrote: > Hi All, > > i have an regx question. i have the array contents, now i want to > remove the first 2 characters (fc) of each element in the array and > store it in a second array ex: @array2 > > @array ="fc20/1, fc30/22, fc40/3, fc20/1"; > > o

Re: regx substitution question

2012-09-05 Thread Shlomi Fish
Hi Sj, On Wed, 5 Sep 2012 14:33:13 +0100 jet speed wrote: > Hi All, > > i have an regx question. i have the array contents, now i want to > remove the first 2 characters (fc) of each element in the array and > store it in a second array ex: @array2 > > @array ="fc20/1, fc30/22, fc40/3, fc20/1"

regx substitution question

2012-09-05 Thread jet speed
Hi All, i have an regx question. i have the array contents, now i want to remove the first 2 characters (fc) of each element in the array and store it in a second array ex: @array2 @array ="fc20/1, fc30/22, fc40/3, fc20/1"; output @array2 ="20/1, 30/22, 40/3, 20/1"; please advice. Thanks Sj

Re: $_ substitution Question

2010-04-02 Thread jet speed
On Thu, Apr 1, 2010 at 5:58 PM, Shawn H Corey wrote: > jet speed wrote: > >> Hi Chaps, >> >> I need bit more help with this, i slightly modified the code based on the >> inputs, still having the same issue of $_ substitution. >> >> Appreciate your help with this. >> >> ###

Re: $_ substitution Question

2010-04-01 Thread Shawn H Corey
jet speed wrote: Hi Chaps, I need bit more help with this, i slightly modified the code based on the inputs, still having the same issue of $_ substitution. Appreciate your help with this. ## #!/usr/bin/perl use strict; use warnings; my $base

Re: $_ substitution Question

2010-04-01 Thread jet speed
Hi All, Further to my previous email, if i add the fulll path of each directory the, $_ Sustitution works with below code #!/usr/bin/perl use strict; use warnings; my @list = ( '/usr/openv/netbackup/logs/bpcd' , '/usr/openv/netbackup/logs/bprd' , '/usr/openv/netbackup/logs/admin' , '/usr/openv

Re: $_ substitution Question

2010-04-01 Thread jet speed
Hi Chaps, I need bit more help with this, i slightly modified the code based on the inputs, still having the same issue of $_ substitution. Appreciate your help with this. ## #!/usr/bin/perl use strict; use warnings; my $base = "/usr/openv/netba

Re: $_ substitution Question

2010-03-30 Thread Shlomi Fish
Hi Sarath, I'm CCing to the list. On Monday 29 Mar 2010 08:55:55 KKde wrote: > HI Shlomi, > > > system("/usr/bin/find \"$_\" -mtime 3 -print -exec ls '{}' \;"); > > I got confused. Can you plz explain me why $_ is surrounded by another > double quotes? Why it isn't interpolated in the outer dou

Re: $_ substitution Question

2010-03-29 Thread jet speed
Many Thanks Simon, John and everyone else for pointing me to the correct direction. Cheeers !! Js On Fri, Mar 26, 2010 at 7:03 PM, Shlomi Fish wrote: > On Friday 26 Mar 2010 20:51:17 John W. Krahn wrote: > > jet speed wrote: > > > Hi, > > > > Hello, > > > > > I have a simple code below, > > > >

Re: $_ substitution Question

2010-03-27 Thread Shlomi Fish
On Saturday 27 Mar 2010 06:59:10 chintan sheth wrote: > Hi , > use system "(/usr/bin/find \"$_\" -type f -mtime 3 -print -exec ls '{}' > \;)"; > No! That's wrong! This is your second reply of this trend. Are you some kind of spammer or troll? Regards, Shlomi Fish --

Re: $_ substitution Question

2010-03-26 Thread chintan sheth
Hi , use system "(/usr/bin/find \"$_\" -type f -mtime 3 -print -exec ls '{}' \;)"; Thanks , Chintan On 3/26/10, Shlomi Fish wrote: > > On Friday 26 Mar 2010 20:51:17 John W. Krahn wrote: > > jet speed wrote: > > > Hi, > > > > Hello, > > > > > I have a simple code below, > > > > > > #

Re: $_ substitution Question

2010-03-26 Thread Shlomi Fish
On Friday 26 Mar 2010 20:51:17 John W. Krahn wrote: > jet speed wrote: > > Hi, > > Hello, > > > I have a simple code below, > > > > ### > > #!/usr/bin/perl > > > > use strict; > > use warnings; > > > > my @list =( '/usr/data/logs' , '/usr/data1/logs'); > > forea

Re: $_ substitution Question

2010-03-26 Thread John W. Krahn
John W. Krahn wrote: jet speed wrote: I have a simple code below, ### #!/usr/bin/perl use strict; use warnings; my @list =( '/usr/data/logs' , '/usr/data1/logs'); foreach (@list) { print "$_ \n"; system "(/usr/bin/find "$_" -mtime 3 -print -exec ls '{}' \;)";

Re: $_ substitution Question

2010-03-26 Thread Shlomi Fish
Hi jet speed, On Friday 26 Mar 2010 19:17:46 jet speed wrote: > Hi, > I have a simple code below, > > ### > #!/usr/bin/perl > > use strict; > use warnings; > > my @list =( '/usr/data/logs' , '/usr/data1/logs'); > foreach (@list) > { > print "$_ \n"; > > system "

Re: $_ substitution Question

2010-03-26 Thread John W. Krahn
jet speed wrote: Hi, Hello, I have a simple code below, ### #!/usr/bin/perl use strict; use warnings; my @list =( '/usr/data/logs' , '/usr/data1/logs'); foreach (@list) { print "$_ \n"; system "(/usr/bin/find "$_" -mtime 3 -print -exec ls '{}' \;)"; } #

$_ substitution Question

2010-03-26 Thread jet speed
Hi, I have a simple code below, ### #!/usr/bin/perl use strict; use warnings; my @list =( '/usr/data/logs' , '/usr/data1/logs'); foreach (@list) { print "$_ \n"; system "(/usr/bin/find "$_" -mtime 3 -print -exec ls '{}' \;)"; } ###

Re: Substitution question

2009-07-01 Thread John W. Krahn
Gurunandan R. Bhat wrote: On Tue, 2009-06-30 at 22:47 -0700, John W. Krahn wrote: That should be: $current_path =~ s|/|\\|g; Oh!! Did not know you could use '|' as a pattern delimiter. Yes. You can use just about any character. John -- Those people who think they know everything ar

Re: Substitution question

2009-07-01 Thread Gurunandan R. Bhat
On Tue, 2009-06-30 at 22:47 -0700, John W. Krahn wrote: > That should be: > > $current_path =~ s|/|\\|g; Oh!! Did not know you could use '|' as a pattern delimiter. Regards

RE: Substitution question

2009-06-30 Thread sanket vaidya
Thanks John. It works Regards, Sanket Vaidya -Original Message- From: John W. Krahn [mailto:jwkr...@shaw.ca] Sent: Wednesday, July 01, 2009 11:17 AM To: Perl Beginners Subject: Re: Substitution question sanket vaidya wrote: > Hi all, Hello, > As a part of one program I need

Re: Substitution question

2009-06-30 Thread John W. Krahn
sanket vaidya wrote: Hi all, Hello, As a part of one program I need to get the current working directory. So I get this using cwd(). I want to replace forward slash (/) by backslash (\) in the path which I get because I work on windows. You shouldn't need to do that. Kindly look at the co

Re: Substitution question

2009-06-30 Thread Gurunandan R. Bhat
Are you sure that your substitution works? With the pattern you have quoted, you should be getting a "Search pattern not terminated" error. To answer your other question, patterns to search must be enclosed inside '/'s (forward slashes). You can change pattern delimiters then you must precede th

Substitution question

2009-06-30 Thread sanket vaidya
Hi all, As a part of one program I need to get the current working directory. So I get this using cwd(). I want to replace forward slash (/) by backslash (\) in the path which I get because I work on windows. Kindly look at the code below: use warnings; use strict; use Cwd; my $cu

Re: regex substitution question

2006-12-31 Thread Mathew Snyder
John W. Krahn wrote: > Mathew Snyder wrote: >> A script I've been working on will provide time spent on a work ticket in >> H:MM >> format. However, if the MM section is less than 10 it only shows as H:M so I >> need to append a 0 to it. So, for instance, if the output looks like this >> 9:7 I

Re: regex substitution question

2006-12-31 Thread John W. Krahn
Mathew Snyder wrote: > A script I've been working on will provide time spent on a work ticket in H:MM > format. However, if the MM section is less than 10 it only shows as H:M so I > need to append a 0 to it. So, for instance, if the output looks like this > 9:7 I > need to append the 0 to the 7

regex substitution question

2006-12-31 Thread Mathew Snyder
A script I've been working on will provide time spent on a work ticket in H:MM format. However, if the MM section is less than 10 it only shows as H:M so I need to append a 0 to it. So, for instance, if the output looks like this 9:7 I need to append the 0 to the 7 making it 9:07. The output is

RE: simple substitution question

2005-02-18 Thread Manav Mathur
=~ is the bind operator. see perldoc perlop. Manav -Original Message- From: Harold Castro [mailto:[EMAIL PROTECTED] Sent: Friday, February 18, 2005 12:17 PM To: beginners@perl.org Subject: simple substitution question Hi, There is something that's bothering me for so

Re: simple substitution question

2005-02-18 Thread Ing. Branislav Gerzo
Harold Castro [HC], on Thursday, February 17, 2005 at 22:47 (-0800 (PST)) typed: HC> for example: HC> here is my string: HC> $_ = "but"; HC> s/u/a/g; HC> print $_; what about this: ( my $string = "but" ) =~ s/u/a/g; -- ...m8s, cu l8r, Brano. [Old Farts don't have to be politically correct.]

RE: simple substitution question

2005-02-17 Thread Bedanta Bordoloi, Gurgaon
old Castro [mailto:[EMAIL PROTECTED] Sent: Friday, February 18, 2005 12:17 PM To: beginners@perl.org Subject: simple substitution question Hi, There is something that's bothering me for so long regarding the use of $_ variable. for example: here is my string: $_ = "but"; s/

simple substitution question

2005-02-17 Thread Harold Castro
Hi, There is something that's bothering me for so long regarding the use of $_ variable. for example: here is my string: $_ = "but"; s/u/a/g; print $_; This will simply print "bat" My problem is using a variable in place of $_. how will I tell that the one i'm going to substitute is the $strin

RE: Regulare Expressions/ Substitution Question

2001-11-15 Thread Gibbs Tanton - tgibbs
x27; ' Sent: 11/15/2001 12:05 PM Subject: RE: Regulare Expressions/ Substitution Question > -Original Message- > From: Gibbs Tanton - tgibbs [mailto:[EMAIL PROTECTED]] > Sent: Thursday, November 15, 2001 12:08 PM > To: 'Miretsky, Anya '; ''[EMAIL PROTECTE

RE: Regulare Expressions/ Substitution Question

2001-11-15 Thread Bob Showalter
> -Original Message- > From: Miretsky, Anya [mailto:[EMAIL PROTECTED]] > Sent: Thursday, November 15, 2001 11:57 AM > To: 'Bob Showalter' > Subject: RE: Regulare Expressions/ Substitution Question > > > I don't understand why but if I write the sub

RE: Regulare Expressions/ Substitution Question

2001-11-15 Thread Bob Showalter
> -Original Message- > From: Gibbs Tanton - tgibbs [mailto:[EMAIL PROTECTED]] > Sent: Thursday, November 15, 2001 12:08 PM > To: 'Miretsky, Anya '; ''[EMAIL PROTECTED]' ' > Subject: RE: Regulare Expressions/ Substitution Question > >

RE: Regulare Expressions/ Substitution Question

2001-11-15 Thread Gibbs Tanton - tgibbs
PROTECTED]' Sent: 11/15/2001 10:37 AM Subject: Regulare Expressions/ Substitution Question I am trying to replace all occurences of the word St with St. without generating St.. in the incorrect substitutions of St. The code I have been playing with is something like: $item = "35 Main

Re: Regulare Expressions/ Substitution Question

2001-11-15 Thread birgit kellner
--On Donnerstag, 15. November 2001 11:37 -0500 "Miretsky, Anya" <[EMAIL PROTECTED]> wrote: > I am trying to replace all occurences of the word St with St. without > generating St.. in the incorrect substitutions of St. > > The code I have been playing with is something like: > > $item = "35 Main

RE: Regulare Expressions/ Substitution Question

2001-11-15 Thread Bob Showalter
> -Original Message- > From: Miretsky, Anya [mailto:[EMAIL PROTECTED]] > Sent: Thursday, November 15, 2001 11:37 AM > To: '[EMAIL PROTECTED]' > Subject: Regulare Expressions/ Substitution Question > > > I am trying to replace all occurences of the wor

Regulare Expressions/ Substitution Question

2001-11-15 Thread Miretsky, Anya
I am trying to replace all occurences of the word St with St. without generating St.. in the incorrect substitutions of St. The code I have been playing with is something like: $item = "35 Main St." (it could also be "35 Main St" in which case I want the substitution to happen) $varS = "st"; $