Re: Apologetic request for simple one-off script

2014-07-17 Thread ESChamp
Michael Lynch has written on 7/17/2014 8:30 AM: > how about using awk to print the last column, using number of columns > variable $NF: > > |awk '{print $NF}' file| Great idea! In Windows, I used gawk "{print $NF}" file Thanks. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org

Re: Apologetic request for simple one-off script

2014-07-17 Thread Ron Bergin
Shawn H Corey wrote: > On Thu, 17 Jul 2014 17:36:28 +0300 > Lars Noodén wrote: > >> David's example with the autosplit seems much better but if a slice >> were done instead, what would be the more elegant (least inelegant?) >> way of doing it? > > I wouldn't use a slice at all: > > perl -nE'say((

Re: Apologetic request for simple one-off script

2014-07-17 Thread Shawn H Corey
On Thu, 17 Jul 2014 17:36:28 +0300 Lars Noodén wrote: > David's example with the autosplit seems much better but if a slice > were done instead, what would be the more elegant (least inelegant?) > way of doing it? I wouldn't use a slice at all: perl -nE'say((split/\s+/)[-1])' file -- Don't s

Re: Apologetic request for simple one-off script

2014-07-17 Thread Lars Noodén
On 07/17/2014 05:16 PM, Uri Guttman wrote: > On 07/17/2014 09:02 AM, Lars Noodén wrote: >> Or maybe something like this in perl itself? >> >> perl -ne 'print @{[split(/\s+/,)]}[-1],qq(\n);' file > > much earlier in this thread there were one liner examples of perl using > the -a (autosplit optio

Re: Apologetic request for simple one-off script

2014-07-17 Thread Uri Guttman
On 07/17/2014 09:02 AM, Lars Noodén wrote: On 07/17/2014 03:30 PM, Michael Lynch wrote: how about using awk to print the last column, using number of columns variable $NF: awk '{print $NF}' file Regards, Mike Or maybe something like this in perl itself? perl -ne 'print @{[split(/\s+/,)]}

Re: Apologetic request for simple one-off script

2014-07-17 Thread Lars Noodén
On 07/17/2014 03:30 PM, Michael Lynch wrote: > how about using awk to print the last column, using number of columns > variable $NF: > > awk '{print $NF}' file > > > Regards, > Mike Or maybe something like this in perl itself? perl -ne 'print @{[split(/\s+/,)]}[-1],qq(\n);' file Regards, /La

Re: Apologetic request for simple one-off script

2014-07-17 Thread Michael Lynch
how about using awk to print the last column, using number of columns variable $NF: awk '{print $NF}' file Regards, Mike On Sun, Jul 13, 2014 at 4:43 PM, ESChamp wrote: > I apologize for having to ask this but my nearly-80-year-old brain just > could not come up with a solution. > > I have a

Re: Apologetic request for simple one-off script

2014-07-17 Thread Shlomi Fish
Hi all, On Mon, 14 Jul 2014 16:20:37 +0100 Rob Dixon wrote: > On 14 July 2014 14:22:55 BST, John SJ Anderson wrote: > >Hi. List Mom here. > > > >Please take this off list, it's not on-topic. > > > >John: Thank you for answering the OP's question. However, Shlomi is > >right, the two argument fo

Re: Apologetic request for simple one-off script

2014-07-14 Thread Rob Dixon
On 14 July 2014 15:18:31 BST, John Delacour wrote: > >On 14 Jul 2014, at 14:11, Shlomi Fish wrote: > >>> perldoc -f open > >> This is irrelevant. Two-args open is dangerous - always use >three-args open: >> >> * http://perl-begin.org/tutorials/bad-elements/#open-function-style > >Who wrote that?

Re: Apologetic request for simple one-off script

2014-07-14 Thread Rob Dixon
On 14 July 2014 14:22:55 BST, John SJ Anderson wrote: >Hi. List Mom here. > >Please take this off list, it's not on-topic. > >John: Thank you for answering the OP's question. However, Shlomi is >right, the two argument form of open() is something that the general >Perl community considers to be a

Re: Apologetic request for simple one-off script

2014-07-14 Thread John SJ Anderson
You were asked to take this off list once. I'm now telling you, in my official capacity as list moderator: further discussion of this is off-topic and does not belong on this list. Let it go. thanks, john. On Mon, Jul 14, 2014 at 7:18 AM, John Delacour wrote: > > On 14 Jul 2014, at 14:11, Sh

Re: Apologetic request for simple one-off script

2014-07-14 Thread John Delacour
On 14 Jul 2014, at 14:11, Shlomi Fish wrote: >> perldoc -f open > This is irrelevant. Two-args open is dangerous - always use three-args open: > > * http://perl-begin.org/tutorials/bad-elements/#open-function-style Who wrote that? Ah...a certain Shlomi Fish. open my $fh, "< $path"; # with o

Re: Apologetic request for simple one-off script

2014-07-14 Thread John SJ Anderson
Hi. List Mom here. Please take this off list, it's not on-topic. John: Thank you for answering the OP's question. However, Shlomi is right, the two argument form of open() is something that the general Perl community considers to be a deprecated style that should not be used with new code. This l

Re: Apologetic request for simple one-off script

2014-07-14 Thread Shlomi Fish
On Mon, 14 Jul 2014 11:13:05 +0100 John Delacour wrote: > > On 14 Jul 2014, at 05:39, Shlomi Fish wrote: > > > don't use two-args open > > perldoc -f open > > In the one- and two-argument forms of the call, the mode and > filename should be concatenated (in that order

Re: Apologetic request for simple one-off script

2014-07-14 Thread John Delacour
On 14 Jul 2014, at 05:39, Shlomi Fish wrote: > don't use two-args open perldoc -f open In the one- and two-argument forms of the call, the mode and filename should be concatenated (in that order), preferably separated by white space. You can--but shouldn't--

Re: Apologetic request for simple one-off script

2014-07-13 Thread Shlomi Fish
Hi John, On Mon, 14 Jul 2014 04:15:39 +0100 John Delacour wrote: > > On 13 Jul 2014, at 23:48, ESChamp wrote: > > > John Delacour has written on 7/13/2014 5:31 PM: > >> > >> On 13 Jul 2014, at 21:43, ESChamp wrote: > >> > >>> ...lastname firstname other other other ... emailaddress > >>>

Re: Apologetic request for simple one-off script

2014-07-13 Thread John Delacour
On 13 Jul 2014, at 23:48, ESChamp wrote: > John Delacour has written on 7/13/2014 5:31 PM: >> >> On 13 Jul 2014, at 21:43, ESChamp wrote: >> >>> ...lastname firstname other other other ... emailaddress >>> >>> I wish to write a new file that contains only the emailaddress field >>> contents.

Re: Apologetic request for simple one-off script

2014-07-13 Thread ESChamp
Paul Johnson has written on 7/13/2014 7:22 PM: > On Sun, Jul 13, 2014 at 06:44:18PM -0400, ESChamp wrote: >> Paul Johnson has written on 7/13/2014 5:00 PM: >> > perl -nale 'print $F[-1]' < original_file.txt > just_email.txt >> >> e:\Docs\>perl -nale 'print $F[-1]' < 4sam.txt > just_email.txt >> Ca

Re: Apologetic request for simple one-off script

2014-07-13 Thread Paul Johnson
On Sun, Jul 13, 2014 at 06:44:18PM -0400, ESChamp wrote: > Paul Johnson has written on 7/13/2014 5:00 PM: > > perl -nale 'print $F[-1]' < original_file.txt > just_email.txt > > e:\Docs\>perl -nale 'print $F[-1]' < 4sam.txt > just_email.txt > Can't find string terminator "'" anywhere before EOF at

Re: Apologetic request for simple one-off script

2014-07-13 Thread ESChamp
Paul Johnson has written on 7/13/2014 5:00 PM: > perl -nale 'print $F[-1]' < original_file.txt > just_email.txt e:\Docs\>perl -nale 'print $F[-1]' < 4sam.txt > just_email.txt Can't find string terminator "'" anywhere before EOF at -e line 1. ??? 4sam.txt is the file to be operated on. SAmple lin

Re: Apologetic request for simple one-off script

2014-07-13 Thread John Delacour
On 13 Jul 2014, at 21:43, ESChamp wrote: > ...lastname firstname other other other ... emailaddress > > I wish to write a new file that contains only the emailaddress field > contents. Here’s an easily-understood way of doing it: #!/usr/bin/perl use strict; while (){ chomp; @_ = split / /

Re: Apologetic request for simple one-off script

2014-07-13 Thread Tushar N K Jain
I had this in my temp file: abc 123 53432 t...@gmail.com abc 123 53432 t...@gmail.com abc 123 53432 t...@gmail.com abc 123 53432 t...@gmail.com abc 123 53432 t...@gmail.com Running the following command: perl -n -e 'm/.* ([^ ]+@.*)$/i; print $1."\n"' temp will print: t...@gmail.com t...@gmail.

Re: Apologetic request for simple one-off script

2014-07-13 Thread Paul Johnson
On Sun, Jul 13, 2014 at 04:43:41PM -0400, ESChamp wrote: > I apologize for having to ask this but my nearly-80-year-old brain just > could not come up with a solution. > > I have a text file consisting of several space-separated fields: > > lastname firstname other other other ... emailaddress >

Re: Apologetic request for simple one-off script

2014-07-13 Thread David Precious
On Sun, 13 Jul 2014 16:43:41 -0400 ESChamp wrote: > I apologize for having to ask this but my nearly-80-year-old brain > just could not come up with a solution. > > I have a text file consisting of several space-separated fields: > > lastname firstname other other other ... emailaddress > > I

Re: Apologetic request for simple one-off script

2014-07-13 Thread Tushar N K Jain
You can try the following regexp: .*([^ ]+@.*)$ This assumes that the email address is the last string and all strings are space separated. -- Fruit Vendor On Sun, Jul 13, 2014 at 3:43 PM, ESChamp wrote: > I apologize for having to ask this but my nearly-80-year-old brain just > could not c

Apologetic request for simple one-off script

2014-07-13 Thread ESChamp
I apologize for having to ask this but my nearly-80-year-old brain just could not come up with a solution. I have a text file consisting of several space-separated fields: lastname firstname other other other ... emailaddress I wish to write a new file that contains only the emailaddress field c

Re: Simple one :-)

2002-09-17 Thread Michael Fowler
On Tue, Sep 17, 2002 at 05:06:31PM -0400, Chas Owens wrote: > Nope, you are looking at an indirect method call (OO Perl stuff). The > actual call is > > FH->print($arg1, $arg2); While it's tempting to say this, because the syntax looks identical, it's not the case. Try substituting a different

Re: Simple one :-)

2002-09-17 Thread david
Anthony Saffer wrote: > print(OUTFILE, "$PNdString\n"); > > This is line #19 in my code. When I run it I am told I cannot have a coma > after the filehandle. Why not?? I thought this was standard Perl syntax? > > Anthony if you put a comma after your filehandle, it could mean something totally

Re: Simple one :-)

2002-09-17 Thread Chas Owens
On Tue, 2002-09-17 at 16:48, Anthony Saffer wrote: > print(OUTFILE, "$PNdString\n"); > > This is line #19 in my code. When I run it I am told I cannot have a coma after the >filehandle. Why not?? I thought this was standard Perl syntax? > > Anthony Nope, you are looking at an indirect method c

RE: Simple one :-)

2002-09-17 Thread Sean Rowe
September 17, 2002 3:49 PM To: Perl Beginners List Subject: Simple one :-) print(OUTFILE, "$PNdString\n"); This is line #19 in my code. When I run it I am told I cannot have a coma after the filehandle. Why not?? I thought this was standard Perl syntax? Anthony -- To unsubscribe,

Simple one :-)

2002-09-17 Thread Anthony Saffer
print(OUTFILE, "$PNdString\n"); This is line #19 in my code. When I run it I am told I cannot have a coma after the filehandle. Why not?? I thought this was standard Perl syntax? Anthony

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

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