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 rob.di...@gmx.com wrote: On 14 July 2014 14:22:55 BST, John SJ Anderson geneh...@genehack.org 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

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 esch...@gmail.com wrote: I apologize for having to ask this but my nearly-80-year-old brain just could not come up with a

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, /Lars --

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

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 option) which

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 lars.noo...@gmail.com 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])'

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 lars.noo...@gmail.com 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

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 For

Re: Apologetic request for simple one-off script

2014-07-14 Thread John Delacour
On 14 Jul 2014, at 05:39, Shlomi Fish shlo...@shlomifish.org 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.

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 johndelac...@gmail.com wrote: On 14 Jul 2014, at 05:39, Shlomi Fish shlo...@shlomifish.org wrote: don't use two-args open perldoc -f open In the one- and two-argument forms of the call, the mode and filename

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

Re: Apologetic request for simple one-off script

2014-07-14 Thread John Delacour
On 14 Jul 2014, at 14:11, Shlomi Fish shlo...@shlomifish.org 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,

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 johndelac...@gmail.com wrote: On 14

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 geneh...@genehack.org 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

Re: Apologetic request for simple one-off script

2014-07-14 Thread Rob Dixon
On 14 July 2014 15:18:31 BST, John Delacour johndelac...@gmail.com wrote: On 14 Jul 2014, at 14:11, Shlomi Fish shlo...@shlomifish.org wrote: perldoc -f open This is irrelevant. Two-args open is dangerous - always use three-args open: *

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

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 esch...@gmail.com wrote: I apologize for having to ask this but my nearly-80-year-old brain

Re: Apologetic request for simple one-off script

2014-07-13 Thread David Precious
On Sun, 13 Jul 2014 16:43:41 -0400 ESChamp esch...@gmail.com 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 ...

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 I

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

Re: Apologetic request for simple one-off script

2014-07-13 Thread John Delacour
On 13 Jul 2014, at 21:43, ESChamp esch...@gmail.com 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 (DATA){

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

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 -e line 1.

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 Can't find string

Re: Apologetic request for simple one-off script

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

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 johndelac...@gmail.com wrote: On 13 Jul 2014, at 23:48, ESChamp esch...@gmail.com wrote: John Delacour has written on 7/13/2014 5:31 PM: On 13 Jul 2014, at 21:43, ESChamp esch...@gmail.com wrote: ...lastname firstname