RE: one liner for removing string from an element of string array

2012-07-20 Thread Nemana, Satya
improved automatically since you love it. -Original Message- From: Shlomi Fish [mailto:shlo...@shlomifish.org] Sent: 13 July 2012 17:00 To: Nemana, Satya Cc: beginners@perl.org Subject: Re: one liner for removing string from an element of string array Hi Satya, On Fri, 13 Jul 2012 15:38:20

Re: one liner for removing string from an element of string array

2012-07-13 Thread Shawn H Corey
On 12-07-13 12:32 PM, Uri Guttman wrote: On 07/13/2012 12:27 PM, Shawn H Corey wrote: On 12-07-13 11:59 AM, Shlomi Fish wrote: See File::Basename -http://perldoc.perl.org/File/Basename.html . In the future, you may wish to use regular expressions for similar task There are a number of modules

Re: one liner for removing string from an element of string array

2012-07-13 Thread Shawn H Corey
On 12-07-13 12:32 PM, Uri Guttman wrote: On 07/13/2012 12:27 PM, Shawn H Corey wrote: On 12-07-13 11:59 AM, Shlomi Fish wrote: See File::Basename -http://perldoc.perl.org/File/Basename.html . In the future, you may wish to use regular expressions for similar task There are a number of modules

Re: one liner for removing string from an element of string array

2012-07-13 Thread Uri Guttman
On 07/13/2012 12:27 PM, Shawn H Corey wrote: On 12-07-13 11:59 AM, Shlomi Fish wrote: See File::Basename -http://perldoc.perl.org/File/Basename.html . In the future, you may wish to use regular expressions for similar task There are a number of modules installed with Perl that make working wit

Re: one liner for removing string from an element of string array

2012-07-13 Thread Shawn H Corey
On 12-07-13 11:59 AM, Shlomi Fish wrote: See File::Basename -http://perldoc.perl.org/File/Basename.html . In the future, you may wish to use regular expressions for similar task There are a number of modules installed with Perl that make working with file systems easier: perldoc File::Basen

Re: one liner for removing string from an element of string array

2012-07-13 Thread Shlomi Fish
Hi Satya, On Fri, 13 Jul 2012 15:38:20 + "Nemana, Satya" wrote: > Hi > > I have written a small program like this to just print file2 from the second > element of the array by removing the .template from the entry (the name file2 > can change and can be longer or shorter) > > use strict;

Re: one liner for removing string from an element of string array

2012-07-13 Thread Ron Bergin
Nemana, Satya wrote: > Hi > > I have written a small program like this to just print file2 from the > second element of the array by removing the .template from the entry (the > name file2 can change and can be longer or shorter) > > use strict; > use Data::Dumper; > use warnings; > > my @templates

RE: one liner in Windows to replace string

2009-08-25 Thread Wagner, David --- Senior Programmer Analyst --- CFS
> -Original Message- > From: Shawn H. Corey [mailto:shawnhco...@gmail.com] > Sent: Monday, August 24, 2009 11:57 > To: Wagner, David --- Senior Programmer Analyst --- CFS > Cc: Tony Esposito; Beginners Perl > Subject: Re: one liner in Windows to replace string

RE: one liner in Windows to replace string

2009-08-25 Thread Wagner, David --- Senior Programmer Analyst --- CFS
> -Original Message- > From: Shawn H. Corey [mailto:shawnhco...@gmail.com] > Sent: Monday, August 24, 2009 11:00 > To: Tony Esposito > Cc: Beginners Perl > Subject: Re: one liner in Windows to replace string > > Tony Esposito wrote: > > perl -p -i.b

RE: one liner in Windows to replace string

2009-08-25 Thread Wagner, David --- Senior Programmer Analyst --- CFS
From: Tony Esposito [mailto:tony1234567...@yahoo.co.uk] Sent: Monday, August 24, 2009 14:09 To: Shawn H. Corey Cc: Wagner, David --- Senior Programmer Analyst --- CFS; Beginners Perl Subject: Re: one liner in Windows to

RE: one liner in Windows to replace string

2009-08-25 Thread Wagner, David --- Senior Programmer Analyst --- CFS
From: Tony Esposito [mailto:tony1234567...@yahoo.co.uk] Sent: Monday, August 24, 2009 13:20 To: Shawn H. Corey; Wagner, David --- Senior Programmer Analyst --- CFS Cc: Beginners Perl Subject: Re: one liner in Windows to

RE: one liner in Windows to replace string

2009-08-25 Thread Wagner, David --- Senior Programmer Analyst --- CFS
> -Original Message- > From: Tony Esposito [mailto:tony1234567...@yahoo.co.uk] > Sent: Monday, August 24, 2009 10:46 > To: Beginners Perl > Cc: tony1234567...@yahoo.co.uk > Subject: one liner in Windows to replace string > > perl -p -i.bak -e 's/CONSTANT/VARIABLE/' C:\test.txt >

Re: one liner in Windows to replace string

2009-08-24 Thread Shawn H. Corey
Telemachus wrote: Ok, not to be a jerk, but look at it this way: it's clear that Windows + one-liners are not going well. In the time we've all gone back and forth on this, you could have written a 10 line script and run it about 20 times. Pick your battles, I say. True, but it means "A Poor

Re: one liner in Windows to replace string

2009-08-24 Thread Telemachus
On Mon Aug 24 2009 @ 8:08, Tony Esposito wrote: > Looks good but it bombs ... the Perl interpreter crashes from the DOS prompt > ... using version 5.10.0 build 1005 from ActiveState. > > But it was better than what I had, that's for sure > > This makes for a bit of a mind teaser thanks to it be

Re: one liner in Windows to replace string

2009-08-24 Thread Tony Esposito
ndoze ... :-) From: Shawn H. Corey To: Tony Esposito Cc: "Wagner, David --- Senior Programmer Analyst --- CFS" ; Beginners Perl Sent: Monday, 24 August, 2009 14:49:47 Subject: Re: one liner in Windows to replace string Tony Esposito wrote: > I am happy that it works with double quotes BUT

Re: one liner in Windows to replace string

2009-08-24 Thread Tony Esposito
x27;)"  # does not work -- compilation error ... ?? From: Bob McConnell To: Tony Esposito ; Shawn H. Corey ; "Wagner, David --- Senior Programmer Analyst --- CFS" Cc: Beginners Perl Sent: Monday, 24 August, 2009 14:39:57 Subject: RE: one liner in Windows to replace s

Re: one liner in Windows to replace string

2009-08-24 Thread Shawn H. Corey
Tony Esposito wrote: I am happy that it works with double quotes BUT now, when I try to get all files in a directory with a certain extension, the following does not work ... perl -p -i.bak -e "'s/CONSTANT/VARIABLE/'" C:\***.txt does not like th leading * in the file name when I try to pull

RE: one liner in Windows to replace string

2009-08-24 Thread Bob McConnell
. Corey; Wagner, David --- Senior Programmer Analyst --- CFS Cc: Beginners Perl Subject: Re: one liner in Windows to replace string I am happy that it works with double quotes BUT now, when I try to get all files in a directory with a certain extension, the following does not work ... perl -p -i.bak

Re: one liner in Windows to replace string

2009-08-24 Thread Tony Esposito
txt files ... Help again. From: Shawn H. Corey To: "Wagner, David --- Senior Programmer Analyst --- CFS" Cc: Tony Esposito ; Beginners Perl Sent: Monday, 24 August, 2009 12:57:27 Subject: Re: one liner in Windows to replace string Wagner, David

Re: one liner in Windows to replace string

2009-08-24 Thread Shawn H. Corey
Wagner, David --- Senior Programmer Analyst --- CFS wrote: I ran under windows with what Tony sent, both the cmd and a korn shell and both worked and updated as expected.. If you have any questions and/or problems, please let me know. Thanks. What version of Windows?

Re: one liner in Windows to replace string

2009-08-24 Thread Telemachus
On Mon Aug 24 2009 @ 4:45, Tony Esposito wrote: > perl -p -i.bak -e 's/CONSTANT/VARIABLE/' C:\test.txt > > Trying to replace a string with this one line perl ... in Windows it does not > seem to work ... > > File test.txt contents is ... > > CONSTANT 100 > CONSTANT 200 > > nothing changes ...

Re: one liner in Windows to replace string

2009-08-24 Thread Shawn H. Corey
Tony Esposito wrote: perl -p -i.bak -e 's/CONSTANT/VARIABLE/' C:\test.txt Trying to replace a string with this one line perl ... in Windows it does not seem to work ... File test.txt contents is ... CONSTANT 100 CONSTANT 200 nothing changes ... acts as if it does not 'see' the CONSTANT strin

Re: one liner need help

2009-03-13 Thread Paul Johnson
On Fri, Mar 13, 2009 at 01:13:38PM +1100, Toby Stuart wrote: > Hello All > > It's been almost 13 years since I last posted on this board Not to *this* one. > PS. Where is $Bill? Is he still around? Ah, *that* one. That was a long time ago in a galaxy far, far away. -- Paul Johnson - p...@

Re: one liner need help

2009-03-12 Thread John W. Krahn
John W. Krahn wrote: John W. Krahn wrote: Toby Stuart wrote: Hello All Hello, It's been almost 13 years since I last posted on this board and my Perl skills are extremely rusty. Could someone help me to convert this to a one liner:- use strict; use warnings; while (<>) { /^##\s*(.*)$/

Re: one liner need help

2009-03-12 Thread John W. Krahn
John W. Krahn wrote: Toby Stuart wrote: Hello All Hello, It's been almost 13 years since I last posted on this board and my Perl skills are extremely rusty. Could someone help me to convert this to a one liner:- use strict; use warnings; while (<>) { /^##\s*(.*)$/ && print $1; print "

Re: one liner need help

2009-03-12 Thread John W. Krahn
Toby Stuart wrote: Hello All Hello, It's been almost 13 years since I last posted on this board and my Perl skills are extremely rusty. Could someone help me to convert this to a one liner:- use strict; use warnings; while (<>) { /^##\s*(.*)$/ && print $1; print " && " unless eof; } I

RE: one liner need help

2009-03-12 Thread Toby Stuart
Great. Thankyou chenxy. -Original Message- From: chenxy [mailto:tin...@gmail.com] Sent: Friday, 13 March 2009 2:01 PM To: Toby Stuart Cc: beginners@perl.org Subject: Re: one liner need help 2009/3/13 Toby Stuart < toby.stu...@figtreesys.com.au> Hello All It's been almo

Re: one liner need help

2009-03-12 Thread chenxy
2009/3/13 Toby Stuart > Hello All > > It's been almost 13 years since I last posted on this board and my Perl > skills are extremely rusty. Could someone help me to convert this to a one > liner:- > > > use strict; > use warnings; > > while (<>) { > /^##\s*(.*)$/ && print $1; > print " && " un

Re: One liner to generate truly random passwords from command line

2008-11-28 Thread Chas. Owens
On Fri, Nov 28, 2008 at 22:21, John W. Krahn <[EMAIL PROTECTED]> wrote: > Chas. Owens wrote: >> >> On Fri, Nov 28, 2008 at 10:28, John W. Krahn <[EMAIL PROTECTED]> wrote: >> snip >>> >>> perl -le'@chars = 33 .. 126; print map chr $chars[ rand @chars ], 1 .. 8' >> >> snip >> >> Perl Golf time: >> >>

Re: One liner to generate truly random passwords from command line

2008-11-28 Thread John W. Krahn
Chas. Owens wrote: On Fri, Nov 28, 2008 at 10:28, John W. Krahn <[EMAIL PROTECTED]> wrote: snip perl -le'@chars = 33 .. 126; print map chr $chars[ rand @chars ], 1 .. 8' snip Perl Golf time: perl -le'print map chr+(33..126)[rand 94],1..8' $ perl -le'print map chr+(33..126)[rand 94],1..8' Wa

Re: One liner to generate truly random passwords from command line

2008-11-28 Thread Chas. Owens
On Fri, Nov 28, 2008 at 10:28, John W. Krahn <[EMAIL PROTECTED]> wrote: snip > perl -le'@chars = 33 .. 126; print map chr $chars[ rand @chars ], 1 .. 8' snip Perl Golf time: perl -le'print map chr+(33..126)[rand 94],1..8' -- Chas. Owens wonkden.net The most important skill a programmer can have

Re: One liner to generate truly random passwords from command line

2008-11-28 Thread Chas. Owens
On Thu, Nov 27, 2008 at 15:04, Yimin Rong <[EMAIL PROTECTED]> wrote: > wget -q -O - "http://random.org/integers/? > num=8&min=33&max=126&col=8&base=16&format=plain&rnd=new" | perl -ne > 'foreach (split(/\t/, $_)) {print chr(hex($_));} print "\n"' > > wget reads web pages > random.org generates rand

Re: One liner to generate truly random passwords from command line

2008-11-28 Thread John W. Krahn
Yimin Rong wrote: wget -q -O - "http://random.org/integers/? num=8&min=33&max=126&col=8&base=16&format=plain&rnd=new" | perl -ne 'foreach (split(/\t/, $_)) {print chr(hex($_));} print "\n"' You can simplify the perl part to: perl -lane'print map chr hex, @F' Or just using perl: perl -MLWP::

Re: one-liner for if condition is met, substitute an incremented number

2008-09-21 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Here's a string in my file, #define MY2D_STRING"4.0.1.999.9" of which I'm trying to increment the last digit; let's say with 1, such that the output is 4.0.1.999.10 I've tried _various_ combinations, here's just one of them. (This works partially, but not

Re: one-liner for if condition is met, substitute an incremented number

2008-09-21 Thread Mr. Shawn H. Corey
On Fri, 2008-09-19 at 20:53 -0700, [EMAIL PROTECTED] wrote: > Here's a string in my file, > > #define MY2D_STRING"4.0.1.999.9" > > of which I'm trying to increment the last digit; let's say with 1, > > such that the output is 4.0.1.999.10 > > I've tried _various_ combinations, here'

Re: one liner for replacing under Windows?

2008-06-14 Thread Xavier Noria
On Sat, Jun 14, 2008 at 1:05 PM, Octavian Rasnita <[EMAIL PROTECTED]> wrote: > From: "Xavier Noria" <[EMAIL PROTECTED]>> On Sat, Jun 14, 2008 at 9:56 AM, > Octavian Rasnita <[EMAIL PROTECTED]> wrote: >> >>> Is there a one-liner command that can replace a certain text with another >>> in >>> more f

Re: one liner for replacing under Windows?

2008-06-14 Thread Octavian Rasnita
From: "Xavier Noria" <[EMAIL PROTECTED]>> On Sat, Jun 14, 2008 at 9:56 AM, Octavian Rasnita <[EMAIL PROTECTED]> wrote: Is there a one-liner command that can replace a certain text with another in more files specified with wildcards like *.html that works under Windows cmd? Since you ask this

Re: one liner for replacing under Windows?

2008-06-14 Thread Xavier Noria
On Sat, Jun 14, 2008 at 9:56 AM, Octavian Rasnita <[EMAIL PROTECTED]> wrote: > Is there a one-liner command that can replace a certain text with another in > more files specified with wildcards like *.html that works under Windows > cmd? Since you ask this you probably know the Windows shell does

Re: one liner for for and if

2008-05-08 Thread Richard Lee
Rob Dixon wrote: Richard Lee wrote: #!/usr/bin/perl use warnings; use strict; my @array = qw/one two three four/; print "$_\n" for @array last if "$_" eq q/three/; [EMAIL PROTECTED] tmp]# ./!$ ././././testthis2.pl syntax error at ././././testthis2.pl line 8, near "@array last " Execution

Re: one liner for for and if

2008-05-08 Thread Rob Dixon
Yitzchok Good wrote: > > if ("$_" eq q/three/) {print "$_\n" for @array last}; That won't even compile. Please don't publish nonsense. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: one liner for for and if

2008-05-08 Thread Rob Dixon
Richard Lee wrote: > #!/usr/bin/perl > > use warnings; > use strict; > > my @array = qw/one two three four/; > > print "$_\n" for @array last if "$_" eq q/three/; > > > [EMAIL PROTECTED] tmp]# ./!$ > ././././testthis2.pl > syntax error at ././././testthis2.pl line 8, near "@array last " > Exec

Re: one liner for for and if

2008-05-08 Thread Yitzchok Good
if ("$_" eq q/three/) {print "$_\n" for @array last}; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: One liner

2008-02-13 Thread Randal L. Schwartz
> "Robert" == Robert Leibl <[EMAIL PROTECTED]> writes: Robert> Dermot wrote: >> Hi, >> >> ls | perl -ne 'print if /\.$/'| sed 's/\(.*\)/mv & \1jpg/' | sh >> >> >> I concocted the above command to change files named >> >> A1234. to A1234.jpg >> >> Is there a pure perl one-liner for this?

Re: One liner

2008-02-13 Thread John W. Krahn
Dermot wrote: Hi, Hello, ls | perl -ne 'print if /\.$/'| sed 's/\(.*\)/mv & \1jpg/' | sh I concocted the above command to change files named A1234. to A1234.jpg Is there a pure perl one-liner for this? Just curious. perl -e'rename$_,"${_}jpg"or warn"$_: $!"for<*.>' John -- Perl isn'

Re: One liner

2008-02-13 Thread Robert Leibl
Dermot wrote: > Hi, > > ls | perl -ne 'print if /\.$/'| sed 's/\(.*\)/mv & \1jpg/' | sh > > > I concocted the above command to change files named > > A1234. to A1234.jpg > > Is there a pure perl one-liner for this? Just curious. > > Thanx, > Dp. > perl -e 'rename $_, $_."jpg" foreach (glob

Re: One liner to change one line

2007-08-16 Thread Chas Owens
On 8/16/07, John W. Krahn <[EMAIL PROTECTED]> wrote: snip > The object created by qr// *is* a compiled regex: snip Yeah my bad, the stringification confused me for a minute. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: One liner to change one line

2007-08-16 Thread Gunnar Hjalmarsson
Chas Owens wrote: qr// is just a fancy double quote that adds a non-capturing group and sets the appropriate options (in case you did something like qr/foo/i). The string "(?:-xism:foo)" is no more or less a regex than the string "foo". Let's look into that. C:\home>type test.pl $re1 = '(?i-x

Re: One liner to change one line

2007-08-16 Thread John W. Krahn
Chas Owens wrote: On 8/16/07, Paul Lalli <[EMAIL PROTECTED]> wrote: snip Silly rhetorical-ness aside, you seem unfamiliar with the term you introduced to this thread: "string form of a regexp": $ perl -le' $a = q{foo}; $b = qr{foo}; print $a; print $b; ' foo (?-xism:foo) My assertion is that y

Re: One liner to change one line

2007-08-16 Thread Chas Owens
On 8/16/07, Paul Lalli <[EMAIL PROTECTED]> wrote: snip > Silly rhetorical-ness aside, you seem unfamiliar with the term you > introduced to this thread: "string form of a regexp": > > $ perl -le' > $a = q{foo}; > $b = qr{foo}; > print $a; > print $b; > ' > foo > (?-xism:foo) > > My assertion is tha

Re: One liner to change one line

2007-08-16 Thread Paul Lalli
On Aug 16, 10:19 am, [EMAIL PROTECTED] (Chas Owens) wrote: > On 8/16/07, Paul Lalli <[EMAIL PROTECTED]> wrote: > > > On Aug 16, 5:12 am, [EMAIL PROTECTED] (Chas Owens) wrote: > > > Basically > > > it all comes down to this: always use quotemeta unless the variable is > > > known to contain the stri

Re: One liner to change one line

2007-08-16 Thread Chas Owens
On 8/16/07, Paul Lalli <[EMAIL PROTECTED]> wrote: > On Aug 16, 5:12 am, [EMAIL PROTECTED] (Chas Owens) wrote: > > Basically > > it all comes down to this: always use quotemeta unless the variable is > > known to contain the string form of a regex. > > No. It comes down to: "always use quotemeta un

Re: One liner to change one line

2007-08-16 Thread Paul Lalli
On Aug 16, 5:12 am, [EMAIL PROTECTED] (Chas Owens) wrote: > Basically > it all comes down to this: always use quotemeta unless the variable is > known to contain the string form of a regex. No. It comes down to: "always use quotemeta unless the variable is known to contain the string form of a re

Re: One liner to change one line

2007-08-16 Thread Paul Lalli
On Aug 16, 4:37 am, [EMAIL PROTECTED] (Dr.Ruud) wrote: > Paul Lalli schreef: > > > s/$h1_sec/$mod_sec/; #replace the pattern found with the > > modified version > > Many s/$search/replace/ constructs should have been written with > quotemeta, so that they look like: > > s/\Q${search}/repl

RE: One liner to change one line

2007-08-16 Thread Andrew Curry
Apologies I miss read the original remark. -Original Message- From: Chas Owens [mailto:[EMAIL PROTECTED] Sent: 16 August 2007 10:12 To: Andrew Curry Cc: Dr.Ruud; beginners@perl.org Subject: Re: One liner to change one line On 8/16/07, Andrew Curry <[EMAIL PROTECTED]> wrote

Re: One liner to change one line

2007-08-16 Thread Chas Owens
On 8/16/07, Andrew Curry <[EMAIL PROTECTED]> wrote: snip >> Many s/$search/replace/ constructs should have been written with quotemeta, >> so that they look like: >> >> s/\Q${search}/replace/ snip > Why? snip given my $search = "file.txt"; What do you want matched? Without the quotemeta it

RE: One liner to change one line

2007-08-16 Thread Andrew Curry
Why? -Original Message- From: Dr.Ruud [mailto:[EMAIL PROTECTED] Sent: 16 August 2007 09:37 To: beginners@perl.org Subject: Re: One liner to change one line Paul Lalli schreef: > s/$h1_sec/$mod_sec/; #replace the pattern found with the > modified version Many s/$search/r

Re: One liner to change one line

2007-08-16 Thread Dr.Ruud
Paul Lalli schreef: > s/$h1_sec/$mod_sec/; #replace the pattern found with the > modified version Many s/$search/replace/ constructs should have been written with quotemeta, so that they look like: s/\Q${search}/replace/ -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe,

Re: One liner to change one line

2007-08-15 Thread Xavier Noria
On Aug 15, 2007, at 7:04 PM, Xavier Noria wrote: perl -0777 -pi.bak -we 's{()(.*?)()}{$x = $2; $x =~ tr:-: :; "$1$x$3"}geis' *.html A small improvement, groups are unnecessary because the elements are guaranteed not to have hyphens (in general they could, for instance in a class name, b

Re: One liner to change one line

2007-08-15 Thread Paul Lalli
On Aug 15, 12:45 pm, [EMAIL PROTECTED] (Dennis G. Wicks) wrote: > Greetings; > > I have, conservatively, dozens of html files to change. > > I can find them and pass the file name to perl and > do the usual s/// changes but there is one change I can't > figure out. > > There is a line in each file

Re: One liner to change one line

2007-08-15 Thread Xavier Noria
On Aug 15, 2007, at 6:45 PM, Dennis G. Wicks wrote: Greetings; I have, conservatively, dozens of html files to change. I can find them and pass the file name to perl and do the usual s/// changes but there is one change I can't figure out. There is a line in each file that looks like Th

Re: one liner to remove \xa0 characters

2006-09-25 Thread Tom Phoenix
On 9/25/06, Michael Alipio <[EMAIL PROTECTED]> wrote: I have several files with \xa0 characters.. Do you know how can I remove them? Those sound like non-breaking spaces, so you probably want them to become ordinary spaces. Have you tried using s/// or tr/// ? perl -pi.bak -e 'tr/\xa0/ /'

Re: One liner to return unique IPs from web log?

2006-05-17 Thread John W. Krahn
Peter Scott wrote: > On Wed, 17 May 2006 10:57:44 -0400, Zembower, Kevin wrote: >>I tried to combine them into this: >> >>perl -ne 'print unless $seen{s/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) >>.*/$1/}++' access.log >> >>but it just returns the first entry of the file. > > And the problem with tha

Re: One liner to return unique IPs from web log?

2006-05-17 Thread Peter Scott
On Wed, 17 May 2006 10:57:44 -0400, Zembower, Kevin wrote: > I tried to combine them into this: > > perl -ne 'print unless $seen{s/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) > .*/$1/}++' access.log > > but it just returns the first entry of the file. And the problem with that is that in a scalar con

RE: One liner to return unique IPs from web log?

2006-05-17 Thread Zembower, Kevin
EMAIL PROTECTED] Sent: Wednesday, May 17, 2006 4:12 PM To: Perl Beginners Subject: Re: One liner to return unique IPs from web log? Zembower, Kevin wrote: > I'm trying to write a perl one-liner to return the unique IP addresses > from a Apache web log, like this: > > perl -

RE: One liner to return unique IPs from web log?

2006-05-17 Thread Zembower, Kevin
not it's an IP address or domain name. Thanks, again, for your help. -Kevin -Original Message- From: Jaime Murillo [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 17, 2006 4:08 PM To: beginners@perl.org Subject: Re: One liner to return unique IPs from web log? On Wednesday 17 May

Re: One liner to return unique IPs from web log?

2006-05-17 Thread John W. Krahn
Zembower, Kevin wrote: > I'm trying to write a perl one-liner to return the unique IP addresses > from a Apache web log, like this: > > perl -ne 'print if s/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) .*/$1/' > access.log | nawk '!x[$0]++' perl -lne'/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) / && !$x{$1}++

Re: One liner to return unique IPs from web log?

2006-05-17 Thread Jaime Murillo
On Wednesday 17 May 2006 07:57, Zembower, Kevin wrote: > I'm trying to write a perl one-liner to return the unique IP addresses > from a Apache web log, like this: > > perl -ne 'print if s/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) .*/$1/' > access.log | nawk '!x[$0]++' > > I tried to combine it with th

Re: One liner to return unique IPs from web log?

2006-05-17 Thread Joshua Colson
On Wed, 2006-05-17 at 10:57 -0400, Zembower, Kevin wrote: > Any advice on correcting my script? Thanks in advance for your > suggestions. > perl -e 'while (<>) { $seen{$1}++ if /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/; } print join("\n",sort keys % seen) . "\n";' access_log HTH -- Joshua Colson

Re: One liner to process stdin/stdout similar "in place edit", grep, cut and awk ($5 PayPal reward for the best answer!)

2005-05-18 Thread Jeff 'japhy' Pinyan
On May 18, Lance Murray said: perl -i -p -e "s/oldhostname/newhostname/g" /etc/hosts However, what is the syntax if I wanted to just process a text stream to stdout?, e.g.: cat /etc/hosts | perl "s/in_text/out_text/g" Simple: use the -p and -e switches, but not the -i switch. -- Jeff "japhy" Pin

Re: One liner to process stdin/stdout similar "in place edit", grep, cut and awk ($5 PayPal reward for the best answer!)

2005-05-18 Thread Jay Savage
On 5/18/05, Chris Devers <[EMAIL PROTECTED]> wrote: > On Wed, 18 May 2005, Lance Murray wrote: > > > However, what is the syntax if I wanted to just process a text stream > > to stdout?, e.g.: > > > > cat /etc/hosts | perl "s/in_text/out_text/g" > > > > I'm sure the answer is fairly simple. I'd j

Re: One liner to process stdin/stdout similar "in place edit", grep, cut and awk ($5 PayPal reward for the best answer!)

2005-05-18 Thread John W. Krahn
Lance Murray wrote: Hello: Hello, I've long used Perl's "in place edit" feature, and understand it and regex fairly well, e.g.: perl -i -p -e "s/oldhostname/newhostname/g" /etc/hosts However, what is the syntax if I wanted to just process a text stream to stdout?, e.g.: cat /etc/hosts | perl "s/in_

Re: One liner to process stdin/stdout similar "in place edit", grep, cut and awk ($5 PayPal reward for the best answer!)

2005-05-18 Thread Chris Devers
On Wed, 18 May 2005, Lance Murray wrote: > However, what is the syntax if I wanted to just process a text stream > to stdout?, e.g.: > > cat /etc/hosts | perl "s/in_text/out_text/g" > > I'm sure the answer is fairly simple. I'd just like to use perl one > liners in place of awk, cut, grep stateme

Re: one-liner multi-line regex problem

2005-04-25 Thread Kevin Horton
On 25-Apr-05, at 10:06 AM, Jay Savage wrote: On 4/25/05, Kevin Horton <[EMAIL PROTECTED]> wrote: I'm trying to write a perl one-liner that will edit an iCalendar format file to remove To Do items. The file contains several thousand lines, and I need to remove several multi-line blocks. The blocks

Re: one-liner multi-line regex problem

2005-04-25 Thread Kevin Horton
On 25-Apr-05, at 10:06 AM, Jay Savage wrote: On 4/25/05, Kevin Horton <[EMAIL PROTECTED]> wrote: I'm trying to write a perl one-liner that will edit an iCalendar format file to remove To Do items. The file contains several thousand lines, and I need to remove several multi-line blocks. The blocks

Re: one-liner multi-line regex problem

2005-04-25 Thread Dave Gray
> I'm trying to write a perl one-liner that will edit an iCalendar > format file to remove To Do items. The file contains several > thousand lines, and I need to remove several multi-line blocks. The > blocks to remove start with a line "BEGIN:VTODO" (without the quotes) > and end with a line "EN

Re: one-liner multi-line regex problem

2005-04-25 Thread Jay Savage
On 4/25/05, Kevin Horton <[EMAIL PROTECTED]> wrote: > I'm trying to write a perl one-liner that will edit an iCalendar > format file to remove To Do items. The file contains several > thousand lines, and I need to remove several multi-line blocks. The > blocks to remove start with a line "BEGIN:V

Re: one-liner multi-line regex problem

2005-04-25 Thread John Doe
Hi Kevin just hints, no solution :-) Am Montag, 25. April 2005 12.59 schrieb Kevin Horton: > I'm trying to write a perl one-liner that will edit an iCalendar > format file to remove To Do items. The file contains several > thousand lines, and I need to remove several multi-line blocks. The > bl

RE: one liner replace / with \

2003-01-10 Thread Bob Showalter
Paul Kraus wrote: > Now I wanted to replace any white space with a single space. > > I used this command > > perl -pi.bak -w -e "s/\s+/ /g" map.bat > > That worked correctly but it removed all of my new lines. Because new lines are whitespace. Adding -l (ell) to the perl command is the easiest

RE: one liner replace / with \

2003-01-10 Thread Paul Kraus
r [mailto:[EMAIL PROTECTED]] > Sent: Friday, January 10, 2003 11:53 AM > To: 'Paul Kraus'; Perl > Subject: RE: one liner replace / with \ > > > Paul Kraus wrote: > > I want to replace all forward slashes with back slashes is a file. > > Using a one liner I tried

RE: one liner replace / with \

2003-01-10 Thread Bob Showalter
Paul Kraus wrote: > I want to replace all forward slashes with back slashes is a file. > Using a one liner I tried > > perl -I -i.bak -w -e 's!/!\\!g' map.bat 1) You don't need -I 2) You do need -p 3) You probably need to use double-quotes instead of single, due to Windows shell brain damage.

Re: One liner If statements

2003-01-02 Thread R. Joseph Newton
PQ [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 02, 2003 1:29 PM > To: Dan Muey; [EMAIL PROTECTED] > Subject: RE: One liner If statements > > No specific reason why, was just exploring other ways to do the same thing. Messing >around with the benchmark module and seeing whi

RE: One liner If statements

2003-01-02 Thread david
Jensen Kenneth B Sra Afpc/Dpdmpq wrote: > Can else statements be added? > > print (hi), $somevar++ if( condition ) else print (bye); good idea but it doens't work that way. try: #!/usr/bin/perl -w use strict; my $var = 1; $var ? ( print("hello world\n"), $var++, print("

Re: One liner If statements

2003-01-02 Thread Rob Dixon
", $somevar++ if condition; is the same as print ("hi", $somevar++) if condition; which would print the unmodified value of $somevar. Something like: hi5 :-) Rob > - Original Message - > From: "Rob Dixon" <[EMAIL PROTECTED]> > To: <[EMAIL P

RE: One liner If statements

2003-01-02 Thread Dan Muey
cool , makes sense, just wondering -Original Message- From: Jensen Kenneth B SrA AFPC/DPDMPQ [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 02, 2003 1:29 PM To: Dan Muey; [EMAIL PROTECTED] Subject: RE: One liner If statements No specific reason why, was just exploring other ways to

RE: One liner If statements

2003-01-02 Thread Jensen Kenneth B SrA AFPC/DPDMPQ
: Dan Muey [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 02, 2003 1:25 PM To: [EMAIL PROTECTED] Subject: RE: One liner If statements Is there a specific reason you need to do it that way? If you need to run a bunch of code why not use sub routines if($hi eq $low) { &hi_is

RE: One liner If statements

2003-01-02 Thread Dan Muey
print "hi"; $somevar++; } else { print "Joemama"; } -Original Message- From: Jensen Kenneth B SrA AFPC/DPDMPQ [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 02, 2003 1:17 PM To: 'Tanton Gibbs'; [EMAIL PROTECTED] Subj

Re: One liner If statements

2003-01-02 Thread Paul Johnson
On Thu, Jan 02, 2003 at 12:56:46PM -0600, Jensen Kenneth B SrA AFPC/DPDMPQ wrote: > In reading messages on this list I've picked up some snippets like > > 'do some code here' if (condition); > > Can the same be done if you have an if statement like this > > If (condition){ > print "hi"; > $s

RE: One liner If statements

2003-01-02 Thread Jensen Kenneth B SrA AFPC/DPDMPQ
Can else statements be added? print (hi), $somevar++ if( condition ) else print (bye); -Original Message- From: Tanton Gibbs [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 02, 2003 1:07 PM To: [EMAIL PROTECTED] Subject: Re: One liner If statements also: print (hi), $somevar++ if

Re: One liner If statements

2003-01-02 Thread Tanton Gibbs
also: print (hi), $somevar++ if( condition ); - Original Message - From: "Rob Dixon" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 02, 2003 1:04 PM Subject: Re: One liner If statements > do { > print "hi"; >

Re: One liner If statements

2003-01-02 Thread Rob Dixon
do { print "hi"; $somevar++; } if condition; (You don't need to parenthesize the conditional expression in this format.) HTH, Rob "Jensen Kenneth B Sra Afpc/Dpdmpq" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > In reading messages on

Re: One liner brain curler (for me ;-)

2002-12-15 Thread John W. Krahn
Jerry Rocteur wrote: > > On Sunday, Dec 15, 2002, at 13:00 Europe/Brussels, John W. Krahn wrote: > >> perl -e 'for (@ARGV) {rename $_,uc($_) unless -e "uc($_)"; } ' * > >> What is wrong with it ??? > > > > subs/functions don't interpolate in quoted strings. > > > > perl -e'-e uc||rename($_,uc)for@

Re: One liner brain curler (for me ;-)

2002-12-15 Thread Jerry Rocteur
On Sunday, Dec 15, 2002, at 13:00 Europe/Brussels, John W. Krahn wrote: perl -e 'for (@ARGV) {rename $_,uc($_) unless -e "uc($_)"; } ' * What is wrong with it ??? subs/functions don't interpolate in quoted strings. perl -e'-e uc||rename($_,uc)for@ARGV' * You're incredible John.. You must be

Re: One liner brain curler (for me ;-)

2002-12-15 Thread John W. Krahn
Jerry Rocteur wrote: > > Hi, Hello, > After you guys sent me all those wonderful links yesterday I've become > a one liner freak ;-)) > > This one is driving me crazy, no matter how I do the unless, it always > ignores it and overwrites an existing file. > > I've been struggling with it for ho

RE: One Liner Problems

2002-07-23 Thread nkuipers
>= Original Message From "Balint, Jess" <[EMAIL PROTECTED]> = >Hello. What is wrong with this? > >perl -e 'for(1..300){sleep 1;print ".";}' > >It never prints anything. >Thanks. I wrote a script like this: for (1..5) { sleep 1; print "."; } when i ran it, i timed it. it took

RE: One Liner Problems

2002-07-23 Thread Jeff 'japhy' Pinyan
On Jul 23, Balint, Jess said: >Is there a command line switch for that? To automatically place a newline after every print(), use the -l switch. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan

Re: One Liner Problems

2002-07-23 Thread George Schlossnagle
STDOUT is line-buffered. either unbuffer it ($| = 1;) or use stderr perl -e 'for(1..300){sleep 1;print STDERR ".";}' On Tuesday, July 23, 2002, at 02:37 PM, Balint, Jess wrote: > Hello. What is wrong with this? > > perl -e 'for(1..300){sleep 1;print ".";}' > > It never prints anything. > Thank

RE: One Liner Problems

2002-07-23 Thread Balint, Jess
Is there a command line switch for that? -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 23, 2002 2:50 PM To: 'Balint, Jess'; '[EMAIL PROTECTED]' Subject: RE: One Liner Problems output is buffered. try it like this perl -e

RE: One Liner Problems

2002-07-23 Thread Nikola Janceski
output is buffered. try it like this perl -e 'for(1..300){sleep 1;print ".\n";}' > -Original Message- > From: Balint, Jess [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, July 23, 2002 2:37 PM > To: '[EMAIL PROTECTED]' > Subject: One Liner Problems > > > Hello. What is wrong with this? >

Re: One Liner Problems

2002-07-23 Thread Jeff 'japhy' Pinyan
On Jul 23, Balint, Jess said: >Hello. What is wrong with this? > >perl -e 'for(1..300){sleep 1;print ".";}' > >It never prints anything. >Thanks. Yes it does. It prints ".

Re: one liner file update problem on cygwin

2002-03-07 Thread Gyro
"Tanton Gibbs" <[EMAIL PROTECTED]> wrote in message 019201c1c610$decae5e0$81486e0a@brooklyn">news:019201c1c610$decae5e0$81486e0a@brooklyn... > I'm running perl on cygwin and trying to do the following one liner: > > perl -pi -e 'BEGIN{$pwd=`pwd`;} s/^HOME=.*/HOME=$pwd/;' makeinclude > > which wil

  1   2   >