One liner

2008-02-13 Thread Dermot
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.

regex one liner

2006-03-20 Thread stu meacham
I would like to modify a file 'in place' at the command line with regexes. The file changes daily and is messy. Can one negate a regex itself as opposed to a class of regular expressions? If I could remove everything but that selected by m/\d{2}\t\d{2}\t\d{2}/g life would be better as I know

Perl one liner....

2006-05-23 Thread Nagasamudram, Prasanna Kumar
Hi All I'm trying to do a find and replace on the file content using the following command on windows. perl -p -i.bak -e 's/FOO/BAR/g' abc.txt abc.txt === test abcd sdfds sdfdsf fdFOO fsd fds hgjhg df fsd hfhj gFOOfd gfdgfd gdf gdf gdf sfsd fsd But the abc.txt remains un

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. >

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"

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

One Liner Problems

2002-07-23 Thread Balint, Jess
Hello. What is wrong with this? perl -e 'for(1..300){sleep 1;print ".";}' It never prints anything. Thanks. Jess -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

one liner need help

2009-03-12 Thread 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 " && " unless

RE: regex one liner

2006-03-20 Thread Timothy Johnson
What have you tried? Have you seen the -i option? -Original Message- From: stu meacham [mailto:[EMAIL PROTECTED] Sent: Monday, March 20, 2006 2:33 PM To: beginners@perl.org Subject: regex one liner I would like to modify a file 'in place' at the command line with regexes.

Re: regex one liner

2006-03-20 Thread Jay Savage
On 3/20/06, stu meacham <[EMAIL PROTECTED]> wrote: > I would like to modify a file 'in place' at the command line with regexes. > The file changes daily and is messy. Can one negate a regex itself as > opposed to a class of regular expressions? If I could remove everything but > that selected

RE: regex one liner

2006-03-21 Thread stu meacham
> perl -i -p -e 's/^(\d{2}\t\d{2}\t\d{2})/g' This was the 1st thing that I > tried; it doesn't work. It was initially easy but different things kept > appearing that forced me to use > 1 statements on the command line. Negating what I want seems like it ought to be simple. > > > What have

Re: regex one liner

2006-03-21 Thread Jay Savage
On 3/20/06, stu meacham <[EMAIL PROTECTED]> wrote: > > > perl -i -p -e 's/^(\d{2}\t\d{2}\t\d{2})/g' This was the 1st thing that I > > tried; it doesn't work. It was initially easy but different things kept > > appearing that forced me to use > 1 > statements on the command line. Negating what

Re: regex one liner

2006-03-21 Thread stu meacham
I tried one final time with non-capturing parentheses i.e. (?: to no avail. This works just fine however: perl -i -p -e '@matches = m/\d{2}\t\d{2}\t\d{2}/g; s/.*//g; print"@matches\n"' Retrieve, delete what's left, and rewrite what's to be kept. It should now work everytime all the time. C

RE: regex one liner

2006-03-21 Thread Timothy Johnson
We run into one of these "How do I do this in a one-liner?" questions pretty frequently, and I for one have to ask, what exactly makes the one-liner so compelling, especially when you are using it for something that will be run repeatedly? IMHO it would have been much more practic

Re: regex one liner

2006-03-21 Thread Jay Savage
On 3/21/06, Timothy Johnson <[EMAIL PROTECTED]> wrote: > > We run into one of these "How do I do this in a one-liner?" questions > pretty frequently, and I for one have to ask, what exactly makes the > one-liner so compelling, especially when you are using it for

Re: regex one liner

2006-03-21 Thread Mr. Shawn H. Corey
Timothy Johnson wrote: We run into one of these "How do I do this in a one-liner?" questions pretty frequently, and I for one have to ask, what exactly makes the one-liner so compelling, especially when you are using it for something that will be run repeatedly? Because you can u

RE: regex one liner

2006-03-21 Thread Timothy Johnson
> >-Original Message- >From: Mr. Shawn H. Corey [mailto:[EMAIL PROTECTED] >Sent: Tuesday, March 21, 2006 1:36 PM >To: beginners perl >Subject: Re: regex one liner > >Timothy Johnson wrote: >> We run into one of these "How do I do this in a one-liner?&quo

Re: regex one liner

2006-03-21 Thread Mr. Shawn H. Corey
Timothy Johnson wrote: And you can't do this? alias pcalc='perl ~/pcalc.pl' No. With alias, I can create an alias file that works with sh (and ksh, bash) and csh (and tcsh). This would be dot'ed in your .profile as: . ~/.alias or source'd in your .cshrc as: source ~/.alias If you

Re: regex one liner

2006-03-21 Thread Kevin Viel
BTW, out here in the real world (that would be UNIX), *.pl stands for Perl Library file, not a script. What extension do you suggest using, if any, in the real world? Thanks, Kevin -- Kevin Viel Department of Genetics

Re: regex one liner

2006-03-21 Thread Dave Gray
On 3/21/06, Kevin Viel <[EMAIL PROTECTED]> wrote: > > BTW, out here in the real world (that would be UNIX), *.pl stands for > > Perl Library file, not a script. > > What extension do you suggest using, if any, in the real world? .ps for perl script /snicker -- To unsubscribe, e-mail: [EMAIL PROT

Re: regex one liner

2006-03-21 Thread Jay Savage
D] > > >Sent: Tuesday, March 21, 2006 1:36 PM > > >To: beginners perl > > >Subject: Re: regex one liner > > > > > >Timothy Johnson wrote: > > >> We run into one of these "How do I do this in a one-liner?" questions > > >>

RE: regex one liner

2006-03-21 Thread Timothy Johnson
> > >-Original Message- >From: Mr. Shawn H. Corey [mailto:[EMAIL PROTECTED] >Sent: Tuesday, March 21, 2006 2:29 PM >To: beginners perl >Subject: Re: regex one liner > >Timothy Johnson wrote: >> And you can't do this? >> >> alias pcalc

RE: regex one liner

2006-03-21 Thread Timothy Johnson
> >-Original Message- >From: Jay Savage [mailto:[EMAIL PROTECTED] >Sent: Tuesday, March 21, 2006 3:06 PM >To: Timothy Johnson >Subject: Re: regex one liner >> >> >> And as for the issue of slightly varying regexes as arguments to a >> script (d

Re: regex one liner

2006-03-21 Thread Omega -1911
With all the debate going on, let me just say that a perl script was THE ONLY method that allowed me to change paths in 13,161 files and scripts when I moved from one provider to another. Try a *one-liner" on multiple files (13,000+) located in different directories... With a Perl script,

Re: regex one liner

2006-03-21 Thread Chad Perrin
On Tue, Mar 21, 2006 at 09:27:28AM -0500, Jay Savage wrote: > On 3/20/06, stu meacham <[EMAIL PROTECTED]> wrote: > > > > > perl -i -p -e 's/^(\d{2}\t\d{2}\t\d{2})/g' This was the 1st thing that I > > > tried; it doesn't work. It was initially easy but different things kept > > > appearing that

Re: regex one liner

2006-03-21 Thread Chad Perrin
On Tue, Mar 21, 2006 at 04:32:21PM -0700, Chad Perrin wrote: > > misused the carat. Mea culpa, Jay. I didn't mean to lead you astray. . . . and here I go with the stupid mistakes again. I meant Stu, not Jay. -- Chad Perrin [ CCD CopyWrite | http://ccd.apotheon.org ] "Real ugliness is not har

Re: regex one liner

2006-03-21 Thread Chad Perrin
On Tue, Mar 21, 2006 at 04:05:17PM -0700, Dave Gray wrote: > On 3/21/06, Kevin Viel <[EMAIL PROTECTED]> wrote: > > > BTW, out here in the real world (that would be UNIX), *.pl stands for > > > Perl Library file, not a script. > > > > What extension do you suggest using, if any, in the real world? >

Re: regex one liner

2006-03-21 Thread Mr. Shawn H. Corey
Timothy Johnson wrote: Beyond being rude and immature, this is off-topic. Please don't try to start a "my OS is better than your OS" war. I wasn't trying to be rude but Perl was developed and evolved in UNIX; something most people don't know. In UNIX, all scripts, whether there are Perl, sh,

Re: regex one liner

2006-03-21 Thread Mr. Shawn H. Corey
Chad Perrin wrote: Actually, I tend to either use no file extension or .plx as the file extension for a non-library script. I'm pretty sure ActivePerl recognizes .plx (not entirely sure, but pretty sure), though I generally do all my scripting on *nix, so it's not really an issue here. In UNI

RE: regex one liner

2006-03-22 Thread stu meacham
Good question. I went to a script right away after the difficulty with the one-liner and returned to the command line syntax problem more out of curiosity than anything else. I'm a fan of the command line because once I get one that works all I need is the 'history' command

Re: Perl one liner....

2006-05-23 Thread M Senthil Kumar
On Tue, 23 May 2006, Nagasamudram, Prasanna Kumar wrote: |I'm trying to do a find and replace on the file content using the |following command on windows. [snipped] |perl -p -i.bak -e 's/FOO/BAR/g' abc.txt [snipped] Hi, Try: $ perl -pi.bak -e 's/FOO/BAR/' abc.txt Note: abc.txt has BAR, abc

Re: Perl one liner....

2006-05-23 Thread Mr. Shawn H. Corey
On Tue, 2006-23-05 at 11:36 -0700, M Senthil Kumar wrote: > > On Tue, 23 May 2006, Nagasamudram, Prasanna Kumar wrote: > > |I'm trying to do a find and replace on the file content using the > |following command on windows. > > [snipped] > > |perl -p -i.bak -e 's/FOO/BAR/g' abc.txt > > [snipped

RE: Perl one liner....

2006-05-23 Thread Nagasamudram, Prasanna Kumar
Thanks Shawn...that worked... I think it was everything to do with double quotes on windows. -Original Message- From: Mr. Shawn H. Corey [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 23, 2006 11:50 PM To: beginners@perl.org Subject: Re: Perl one liner On Tue, 2006-23-05 at 11:36

One liner If statements

2003-01-02 Thread Jensen Kenneth B SrA AFPC/DPDMPQ
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"; $somevar++; } Or can you only have 1 command preceding the if? I tried Print "hi" $somevar++ if (co

one liner replace / with \

2003-01-10 Thread Paul Kraus
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 I get this error useless use of a constant in void context at -e line 1. this is on a windows xp machine. Paul Kraus Network Administrator PEL Supp

eval parameters one liner

2003-09-08 Thread Stephen Gilbert
I know I saw something like this in the past I just can't find it. Anyone got any ideas? perl -e 'print eval { @ARGV }, "\n"' 5 + 5 it should be able to take any perl arithmetic operator. so: perl -e 'print eval { @ARGV }, "\n"' 840928302840982 / 74098374 or perl -e 'print eval { @ARGV }, "\

cryptic one liner explain

2009-01-30 Thread thebarn...@gmail.com
Hi I run this command and pipe the output to a perl one liner. not quite sure how it parses the data: svmon -Pt3 | perl -e 'while(<>){print if($.==2 || $& && !$x++); $.=0 if (/^--+$/)}' which outputs:

Simple one liner problem.

2001-08-22 Thread SAWMaster
I can't seem to use variables like thiswhy not? Is there a simple way to do this? Without having to manually do it with an array traversing check/change function? $workingcopy =~ tr/$lettertochange/$lettertochangeto/g; I also tried $workingcopy =~ s/$lettertochange/$lettertochangeto/g; Th

Perl one-liner problem

2001-09-07 Thread David Gilden
Any idea why this aint working? perl -wpi.org -e s@/cgi-bin/forum_idx.pl@/fakecgi/fakeforum_idx.pl@ Thanks Dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

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 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 Pr

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 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 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 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 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 (<&g

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 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; prin

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*(.*)$/ &&

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 (<>)

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...@

Echo perl one-liner intact

2010-12-15 Thread Mike Martin
Hi I am trying pass a perl one-liner to at intact eg: echo 'perl -mLinux::DVB::DVBT -e 'my $dvb=Linux::DVB::DVBT->new(O_NONBLOCK,'O_RDONLY');$dvb->set_frontend('frequency' => '497167000','tsid' => '4222');my $file="/s

Perl One-liner de-compile?

2005-04-25 Thread Larsen, Errin M HMMA/IT
Hi everyone, Here is an example from the perlrun perldoc page: perl -ane 'print pop(@F), "\n";' is equivalent to while(<>) { @F = split(' '); print pop(@F), "\n"; } My question is, can I get Perl to evaluate a command line (like above) and print out the

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 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 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 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 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 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
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 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 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 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 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

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: > 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

Two-liner to one-liner

2004-01-28 Thread Jan Eden
Hi all, I tried to stuff the following two lines into one, but did not succeed: my($teilnehmer) = $eingabe =~ m/(?<=Teilnehmer:\n\n)(.+)/s; my(@teilzeilen) = split /\n/, $teilnehmer; This does not work: my @teilnehmer = $eingabe =~ m/(?<=Teilnehmer:\n\n)(.+)/s; This does neither: my @teilnehm

Re: eval parameters one liner

2003-09-08 Thread John W. Krahn
Stephen Gilbert wrote: > > I know I saw something like this in the past I just can't find it. Anyone got any > ideas? > > perl -e 'print eval { @ARGV }, "\n"' 5 + 5 > > it should be able to take any perl arithmetic operator. so: > > perl -e 'print eval { @ARGV }, "\n"' 840928302840982 / 740983

Re: eval parameters one liner

2003-09-08 Thread Paul Johnson
On Mon, Sep 08, 2003 at 03:50:25PM -0400, Stephen Gilbert wrote: > I know I saw something like this in the past I just can't find it. Anyone got any > ideas? > > perl -e 'print eval { @ARGV }, "\n"' 5 + 5 > > it should be able to take any perl arithmetic operator. so: > > perl -e 'print eval {

Re: eval parameters one liner

2003-09-08 Thread R. Joseph Newton
"John W. Krahn" wrote: > Stephen Gilbert wrote: > > > > I know I saw something like this in the past I just can't find it. Anyone got any > > ideas? > > > > perl -e 'print eval { @ARGV }, "\n"' 5 + 5 > > > > it should be able to take any perl arithmetic operator. so: > > > > perl -e 'print eval {

Re: eval parameters one liner

2003-09-08 Thread John W. Krahn
"R. Joseph Newton" wrote: > > "John W. Krahn" wrote: > > > > Try it like this: > > > > perl -le 'print eval "@ARGV"' > > Good on 'nix/'nux, I guess. On Windows, It takes a little different quoting: You mean like: perl -le "print eval [EMAIL PROTECTED]" > Greetings! E:\d_drive\perlStuff>perl

Re: eval parameters one liner

2003-09-09 Thread R. Joseph Newton
"John W. Krahn" wrote: > > > Try it like this: > > > > > > perl -le 'print eval "@ARGV"' > > > > Good on 'nix/'nux, I guess. On Windows, It takes a little different quoting: > > You mean like: > > perl -le "print eval [EMAIL PROTECTED]" > > > Greetings! E:\d_drive\perlStuff>perl -le "print eval $

Re: cryptic one liner explain

2009-01-30 Thread Erez Schatz
On 1/30/2009 12:59 AM, thebarn...@gmail.com wrote: Hi I run this command and pipe the output to a perl one liner. not quite sure how it parses the data: svmon -Pt3 | perl -e 'while(<>){print if($.==2 || $& && !$x++); $.=0 if (/^--+$/)}' i understand that it reset

Re: cryptic one liner explain

2009-01-30 Thread John W. Krahn
thebarn...@gmail.com wrote: Hi Hello, I run this command and pipe the output to a perl one liner. not quite sure how it parses the data: svmon -Pt3 | perl -e 'while(<>){print if($.==2 || $& && !$x++); $.=0 if (/^--+$/)}' That can be shortened to: svmon -P

Re: cryptic one liner explain

2009-01-31 Thread thebarn...@gmail.com
> > perl -ne'print if $.==2 || $& && !$x++; $.=0 if /^--+$/' > > The $.==2 tests if the current line number is 2.  If $. is 2 then the > current line is printed and the program goes on to the next statement. > If $. is not 2 then $& is tested and if $& is false then the current > line is printed an

Deleting Duplicate Lines one-liner

2001-07-30 Thread David Blevins
Here is a one-liner I just wrote to delete duplicate lines in a file. perl -ni.bak -e 'unless ($last eq $_){print $_};$last=$_;' theFile Going with the TMTOWTDI credo, I was just curious if anyone knew of a better way. Thanks, David -- To unsubscribe, e-mail: [EMAIL PROT

RE: Simple one liner problem.

2001-08-22 Thread Yacketta, Ronald
> $workingcopy =~ tr/$lettertochange/$lettertochangeto/g; > shot in the dark, taken from my shell scripting days try {} around your variables $workingcopy =~ tr/${lettertochange}/${lettertochangeto}/g; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTE

Re: Simple one liner problem.

2001-08-22 Thread Lynn Glessner
Yacketta, Ronald" <[EMAIL PROTECTED]> To: "SAWMaster" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Wednesday, August 22, 2001 11:53 AM Subject: RE: Simple one liner problem. > > > > $workingcopy =~ tr/$lettertochange/$lettertochangeto/g; > > &

Re: Simple one liner problem.

2001-08-22 Thread Paul Johnson
On Wed, Aug 22, 2001 at 02:53:44PM -0400, Yacketta, Ronald wrote: > > > > $workingcopy =~ tr/$lettertochange/$lettertochangeto/g; > > > shot in the dark, taken from my shell scripting days > > try {} around your variables > $workingcopy =~ tr/${lettertochange}/${lettertochangeto}/g; shot in t

Re: Simple one liner problem.

2001-08-22 Thread Dan Grossman
> shot in the light ;-) > > The tables are built at compile time, so if you want to use variables > here you will need to use string eval. > > eval "tr/$lettertochange/$lettertochangeto/"; Does this mean that I have to use $_ for such a translation, or is there a way to modify a string inside a

Re: Simple one liner problem.

2001-08-22 Thread Paul Johnson
On Wed, Aug 22, 2001 at 12:21:29PM -0700, Dan Grossman wrote: > > eval "tr/$lettertochange/$lettertochangeto/"; > > Does this mean that I have to use $_ for such a translation, or is > there a way to modify a string inside an eval? Here's a complete example: #!/usr/local/bin/perl -w use stric

Re: Perl one-liner problem

2001-09-07 Thread Me
> Any idea why this aint working? > > perl -wpi.org -e s@/cgi-bin/forum_idx.pl@/fakecgi/fakeforum_idx.pl@ no quotes around the string to be evaluated (the s@...@...@ bit). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Perl one-liner problem

2001-09-08 Thread Me
[on list] > On Apache Unix, this just hangs and does nothing and I have to do "control d" to kill it! > > perl -wpi.org -e "s@/cgi-bin/forum_idx.pl@/fakecgi/fakeforum_idx.pl@" It doesn't hang, it's waiting for input. Other notes: 1. A backup file given .org as its extension? Weird. Most people

Pipe inside perl one liner

2007-02-11 Thread vjp2
I wonder if it is possibl to merge these two perl one liners inside one perl one liners, by putting the pipe statement inside? speach () { cat $1 | perl -n00e'tr/\t\r\n/ /s; print qq($1\n) while s/^(.{0,36}\S)\s+//;print qq(\n)' | perl -pe 'if ($.%4==2) {$_ .= qq(\n).(q(-) x 37).qq(\n)} elsif (

search replace one liner problem

2007-09-17 Thread jrpfinch
I would like to execute the following regex on a file: s/(\$Revision:\s+)(\d+\.\d+)(\s+\$.+use constant VERSION\s+=> ")(.+?) (")/$1$2$3Revision $2$5/gs I am doing this in bash as follows: REGEX='s/(\$Revision:\s+)(\d+\.\d+)(\s+\$.+use constant VERSION\s+=> ") (.+?)(")/$1$2$3Revision $2$5/gs' REG

substr and =~ as one liner

2001-11-27 Thread Frank Newland
How can I express the following two lines as a one liner? === $left_trim = substr($_,85,13); $left_trim =~ s/^\s+// ; ## Remove leading spaces === tia frank -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

html entity conversion... one liner?

2002-01-31 Thread KAVANAGH, Michael
I thought it would be good to be able to do this: $item = ""; $item =~ tr/<>/(<)(>)/; to convert those <> symbols to their entity references. however, the tr operator doesn't seem to like using () to group... any comments on how to make this operation in to a

Convert to a one liner

2002-02-08 Thread Scott Lutz
This should be a weekly thing : See who can send in the most useful Perl one liner! So to start it off, I would like some suggestions on some "not so cryptic" one liner methods to do the following : #!/usr/bin/perl -w use strict; opendir(TEMP_DIR, "/home/slutz/temp");

output record separator in one liner

2009-04-13 Thread Rick
perl -lane' print "$F[0] ", "$F[4]" , " $F[5]";' Is there anyway to incoporate $\ <- output record separtor to do this instead of printing out w/ manual spaces beteween the variables? -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@pe

Re: Echo perl one-liner intact

2010-12-15 Thread Jim Gibson
On 12/15/10 Wed Dec 15, 2010 8:05 AM, "Mike Martin" scribbled: > Hi > > I am trying pass a perl one-liner to at intact eg: > > echo 'perl -mLinux::DVB::DVBT -e 'my > $dvb=Linux::DVB::DVBT->new(O_NONBLOCK,'O_RDONLY');$dvb->set_fronten

Re: Echo perl one-liner intact

2010-12-15 Thread Onteria
> Hi > > I am trying pass a perl one-liner to at intact eg: > > echo 'perl -mLinux::DVB::DVBT -e 'my > $dvb=Linux::DVB::DVBT->new(O_NONBLOCK,'O_RDONLY');$dvb->set_frontend('frequency' > => '497167000','tsid' => &#

Re: Echo perl one-liner intact

2010-12-15 Thread Mike Martin
On 15 December 2010 16:21, Jim Gibson wrote: > On 12/15/10 Wed  Dec 15, 2010  8:05 AM, "Mike Martin" > scribbled: > >> Hi >> >> I am trying pass a perl one-liner to at intact eg: >> >> echo 'perl -mLinux::DVB::DVBT -e 'my >> $dv

Re: Echo perl one-liner intact

2010-12-15 Thread Brandon McCaig
On Wed, Dec 15, 2010 at 8:47 PM, Mike Martin wrote: > to explain further the aim is that the one-liner is generated on the > fly and then passed to at to schedule recordings which is why I want > it to be a one liner so that at wll parse it correctly > > generating seperate

Re: Echo perl one-liner intact

2010-12-15 Thread C.DeRykus
On Dec 15, 8:05 am, redt...@gmail.com (Mike Martin) wrote: > Hi > > I am trying pass a perl one-liner to at intact eg: > > echo 'perl -mLinux::DVB::DVBT -e 'my > $dvb=Linux::DVB::DVBT->new(O_NONBLOCK,'O_RDONLY');$dvb->set_frontend('frequency'

one-liner multi-line regex problem

2005-04-25 Thread 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 blocks to remove start with a line "BEGIN:VTODO" (without the quotes) and

Perl one-liner to print columns

2005-04-25 Thread Larsen, Errin M HMMA/IT
Hi Perlers, I typically will type the following to collect a specific column of data from some command's output: # some_command | awk '{print $4}' I wanted to start using perl one-liners more often, so I thought I'd try the column thing first. This is what I came up with: # some_comma

Re: Perl One-liner de-compile?

2005-04-25 Thread Paul Johnson
On Mon, Apr 25, 2005 at 01:45:15PM -0500, Larsen, Errin M HMMA/IT wrote: > Hi everyone, > > Here is an example from the perlrun perldoc page: > > perl -ane 'print pop(@F), "\n";' > > is equivalent to > > while(<>) { > @F = split(' '); > print pop(@F), "\n"; > }

RE: Perl One-liner de-compile?

2005-04-25 Thread Larsen, Errin M HMMA/IT
> -Original Message- > From: Paul Johnson [mailto:[EMAIL PROTECTED] > Sent: Monday, April 25, 2005 1:53 PM > To: Larsen, Errin M HMMA/IT > Cc: beginners@perl.org > Subject: Re: Perl One-liner de-compile? > > > On Mon, Apr 25, 2005 at 01:45:15PM -0500, Larse

RE: Perl One-liner de-compile?

2005-04-25 Thread Charles K. Clarkson
Larsen, Errin M HMMA/IT wrote: : Or is the @f array a secret array I'm not cleared to know about? We could tell 'ya, but then we'd have to kill 'ya. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: Perl One-liner de-compile?

2005-04-25 Thread Jeff 'japhy' Pinyan
On Apr 25, Larsen, Errin M HMMA/IT said: $ perl -MO=Deparse -ane 'print pop(@F), "\n";' Note the @F, it's capital-F. # perl -MO=Deparse -nae 'print $f[4]' /some/directory/somefile You're using a lowercase @f here. LINE: while (defined($_ = )) { our(@F) = split(" ", $_, 0); print $f[4];

  1   2   3   >