Sed-type-function
List, Does perl have any built-in sed-like function? I found ASED.pm, but would rather go with something built in. I looked around a bit, but didnt find anything. I guess I could go with using the Shell module but would rather using as few modules as possible. Thanks, Dave Kettmann NetLogic 636-561-0680 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Sed-type-function
Dave Kettmann wrote: List, Does perl have any built-in sed-like function? I found ASED.pm, but would rather go with something built in. I looked around a bit, but didnt find anything. I guess I could go with using the Shell module but would rather using as few modules as possible. I'm not sure what you mean by sed-like function. Perl can do anything sed can do. There is also a script that converts sed to perl, see `perldoc s2p` -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Sed-type-function
I guess and easy syntax for search and replace similar to: s/this/that/g ... Guess I will look at the s2p you mentioned as well. Dave -Original Message- From: Randy W. Sims [mailto:[EMAIL PROTECTED] Sent: Monday, August 23, 2004 10:39 AM To: Dave Kettmann Cc: Perl List (E-mail) Subject: Re: Sed-type-function Dave Kettmann wrote: List, Does perl have any built-in sed-like function? I found ASED.pm, but would rather go with something built in. I looked around a bit, but didnt find anything. I guess I could go with using the Shell module but would rather using as few modules as possible. I'm not sure what you mean by sed-like function. Perl can do anything sed can do. There is also a script that converts sed to perl, see `perldoc s2p` -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Sed-type-function
On Aug 23, 2004, at 10:50 AM, Dave Kettmann wrote: I guess and easy syntax for search and replace similar to: s/this/that/g ... Perl supports this exact syntax, so you are confusing a lot of us now... :D James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Sed-type-function
I guess and easy syntax for search and replace similar to: s/this/that/g ... Perl has that, you can use exactly the same syntax -- s/search/replace/g hth Jeff Guess I will look at the s2p you mentioned as well. Dave -Original Message- From: Randy W. Sims [mailto:[EMAIL PROTECTED] Sent: Monday, August 23, 2004 10:39 AM To: Dave Kettmann Cc: Perl List (E-mail) Subject: Re: Sed-type-function Dave Kettmann wrote: List, Does perl have any built-in sed-like function? I found ASED.pm, but would rather go with something built in. I looked around a bit, but didnt find anything. I guess I could go with using the Shell module but would rather using as few modules as possible. I'm not sure what you mean by sed-like function. Perl can do anything sed can do. There is also a script that converts sed to perl, see `perldoc s2p` -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Sed-type-function
Hmm .. wonder why I didnt see that in any of the books i looked at. Ok off I go then, Thanks for the help! Sorry to confuse you guys :) Dave -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, August 23, 2004 10:59 AM To: Dave Kettmann Cc: Perl List (E-mail) Subject: RE: Sed-type-function I guess and easy syntax for search and replace similar to: s/this/that/g ... Perl has that, you can use exactly the same syntax -- s/search/replace/g hth Jeff Guess I will look at the s2p you mentioned as well. Dave -Original Message- From: Randy W. Sims [mailto:[EMAIL PROTECTED] Sent: Monday, August 23, 2004 10:39 AM To: Dave Kettmann Cc: Perl List (E-mail) Subject: Re: Sed-type-function Dave Kettmann wrote: List, Does perl have any built-in sed-like function? I found ASED.pm, but would rather go with something built in. I looked around a bit, but didnt find anything. I guess I could go with using the Shell module but would rather using as few modules as possible. I'm not sure what you mean by sed-like function. Perl can do anything sed can do. There is also a script that converts sed to perl, see `perldoc s2p` -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Sed-type-function
Hmm .. wonder why I didnt see that in any of the books i looked at. Ok off I go then, Thanks for the help! Sorry to confuse you guys :) Dave start here - perldoc perlop (or http://www.perldoc.com/perl5.8.4/pod/perlop.html#Regexp-Quote-Like-Operators) and perldoc perlretut ( or http://www.perldoc.com/perl5.8.4/pod/perlretut.html) Jeff I guess and easy syntax for search and replace similar to: s/this/that/g ... Perl has that, you can use exactly the same syntax -- s/search/replace/g hth Jeff Guess I will look at the s2p you mentioned as well. Dave -Original Message- From: Randy W. Sims [mailto:[EMAIL PROTECTED] Sent: Monday, August 23, 2004 10:39 AM To: Dave Kettmann Cc: Perl List (E-mail) Subject: Re: Sed-type-function Dave Kettmann wrote: List, Does perl have any built-in sed-like function? I found ASED.pm, but would rather go with something built in. I looked around a bit, but didnt find anything. I guess I could go with using the Shell module but would rather using as few modules as possible. I'm not sure what you mean by sed-like function. Perl can do anything sed can do. There is also a script that converts sed to perl, see `perldoc s2p` -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Sed-type-function
Ok ... I'm going to try to confuse everyone again because either a) I'm dense or b) I'm asking the wrong question. Everyone can agree with option a, and I will not get mad :). Ok .. here goes again... I looked at s2p and it spit out 2 pages of perl code of which the sed command was a small bit of code. It is nothing major that I want to do an example is below: I want this ...: Aug 23 14:28:32 Auth.notice: (Access-Request 10.10.116.4 166 000611-011c0c): Login OK [000611-011c0c] To be this ...: Aug 23 14:25:32 (Access-Request 10.10.116.4 166 000611-011c0c): Login OK Or to make it easier, I want to take out the 'Auth.notice: ' and anything encased in []'s. I dont know if im confusing things more, or if I was pointed in the right direction and I just dont understand. Someone please help this poor confused person figure out WTH he is doing wrong :-D Dave Ketmmann NetLogic 636-561-0680 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, August 23, 2004 11:04 AM To: Dave Kettmann Cc: Perl List (E-mail) Subject: RE: Sed-type-function Hmm .. wonder why I didnt see that in any of the books i looked at. Ok off I go then, Thanks for the help! Sorry to confuse you guys :) Dave start here - perldoc perlop (or http://www.perldoc.com/perl5.8.4/pod/perlop.html#Regexp-Quote-Like-Operators) and perldoc perlretut ( or http://www.perldoc.com/perl5.8.4/pod/perlretut.html) Jeff I guess and easy syntax for search and replace similar to: s/this/that/g ... Perl has that, you can use exactly the same syntax -- s/search/replace/g hth Jeff Guess I will look at the s2p you mentioned as well. Dave -Original Message- From: Randy W. Sims [mailto:[EMAIL PROTECTED] Sent: Monday, August 23, 2004 10:39 AM To: Dave Kettmann Cc: Perl List (E-mail) Subject: Re: Sed-type-function Dave Kettmann wrote: List, Does perl have any built-in sed-like function? I found ASED.pm, but would rather go with something built in. I looked around a bit, but didnt find anything. I guess I could go with using the Shell module but would rather using as few modules as possible. I'm not sure what you mean by sed-like function. Perl can do anything sed can do. There is also a script that converts sed to perl, see `perldoc s2p` -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Sed-type-function
$str =~ s/Auth.notice: //; $str =~ s/\[[\]]*\]//; print $str; I'm not sure if there's a way to put it all in one line, but this should do it nonetheless. -David On Mon, 23 Aug 2004 14:31:01 -0500, Dave Kettmann [EMAIL PROTECTED] wrote: Ok ... I'm going to try to confuse everyone again because either a) I'm dense or b) I'm asking the wrong question. Everyone can agree with option a, and I will not get mad :). Ok .. here goes again... I looked at s2p and it spit out 2 pages of perl code of which the sed command was a small bit of code. It is nothing major that I want to do an example is below: I want this ...: Aug 23 14:28:32 Auth.notice: (Access-Request 10.10.116.4 166 000611-011c0c): Login OK [000611-011c0c] To be this ...: Aug 23 14:25:32 (Access-Request 10.10.116.4 166 000611-011c0c): Login OK Or to make it easier, I want to take out the 'Auth.notice: ' and anything encased in []'s. I dont know if im confusing things more, or if I was pointed in the right direction and I just dont understand. Someone please help this poor confused person figure out WTH he is doing wrong :-D Dave Ketmmann NetLogic 636-561-0680 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, August 23, 2004 11:04 AM To: Dave Kettmann Cc: Perl List (E-mail) Subject: RE: Sed-type-function Hmm .. wonder why I didnt see that in any of the books i looked at. Ok off I go then, Thanks for the help! Sorry to confuse you guys :) Dave start here - perldoc perlop (or http://www.perldoc.com/perl5.8.4/pod/perlop.html#Regexp-Quote-Like-Operators) and perldoc perlretut ( or http://www.perldoc.com/perl5.8.4/pod/perlretut.html) Jeff I guess and easy syntax for search and replace similar to: s/this/that/g ... Perl has that, you can use exactly the same syntax -- s/search/replace/g hth Jeff Guess I will look at the s2p you mentioned as well. Dave -Original Message- From: Randy W. Sims [mailto:[EMAIL PROTECTED] Sent: Monday, August 23, 2004 10:39 AM To: Dave Kettmann Cc: Perl List (E-mail) Subject: Re: Sed-type-function Dave Kettmann wrote: List, Does perl have any built-in sed-like function? I found ASED.pm, but would rather go with something built in. I looked around a bit, but didnt find anything. I guess I could go with using the Shell module but would rather using as few modules as possible. I'm not sure what you mean by sed-like function. Perl can do anything sed can do. There is also a script that converts sed to perl, see `perldoc s2p` -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Sed-type-function
Dave Kettmann wrote: Ok ... I'm going to try to confuse everyone again because either a) I'm dense or b) I'm asking the wrong question. Everyone can agree with option a, and I will not get mad :). Ok .. here goes again... I looked at s2p and it spit out 2 pages of perl code of which the sed command was a small bit of code. It is nothing major that I want to do an example is below: I want this ...: Aug 23 14:28:32 Auth.notice: (Access-Request 10.10.116.4 166 000611-011c0c): Login OK [000611-011c0c] To be this ...: Aug 23 14:25:32 (Access-Request 10.10.116.4 166 000611-011c0c): Login OK Or to make it easier, I want to take out the 'Auth.notice: ' s/Auth.notice: //; and anything encased in []'s. s/\[[^]]*]//; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Sed-type-function
Please consider bottom-posting to lists, and trimming old parts of the reply. Anyone that doesn't have the earlier material can look in the archives. Thanks :-) On Mon, 23 Aug 2004, Dave Kettmann wrote: I want this ...: Aug 23 14:28:32 Auth.notice: (Access-Request 10.10.116.4 166 000611-011c0c): Login OK [000611-011c0c] To be this ...: Aug 23 14:25:32 (Access-Request 10.10.116.4 166 000611-011c0c): Login OK Or to make it easier, I want to take out the 'Auth.notice: ' and anything encased in []'s. I dont know if im confusing things more, or if I was pointed in the right direction and I just dont understand. Someone please help this poor confused person figure out WTH he is doing wrong :-D Ok, this is easy to do in Perl, but before providing a sample, please show the list how you would accomplish this using sed. The Perl example will probably be very similar. Hint: if you can get the string you want to process into $string -- let's assume you have code that somehow gets Aug 23... into $string -- then all you need to do is apply the substitutions to that variable: $string =~ s/Auth.notice: //; $string =~ s/\[[^\]]*\]//; That appears to work in this contrived example on the command line: $ perl -le '$foo = bl[baz]ooz; $foo =~ s/\[[^\]]*\]//; print $foo' blooz $ Which successfully removs the harder of those two patterns. If this doesn't get you anywhere, please send the list examples of both the Sed and the Perl code that you have tried so far. -- Chris Devers [EMAIL PROTECTED] http://devers.homeip.net:8080/blog/ np: 'The Twilight Zone Radio Dramas Collection' by Rod Serling et al from 'The Twilight Zone Radio Dramas Collection' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Sed-type-function
On Aug 23, 2004, at 2:31 PM, Dave Kettmann wrote: Ok ... I'm going to try to confuse everyone again because either a) I'm dense or b) I'm asking the wrong question. Everyone can agree with option a, and I will not get mad :). Ok .. here goes again... For future reference, we prefer you submit your attempts to code up a solution, which we will then help fix. Make us feel like we aren't doing all the work. ;) I looked at s2p and it spit out 2 pages of perl code of which the sed command was a small bit of code. It is nothing major that I want to do an example is below: I'm unfamiliar with the program, but I have to say, Yuck. I want this ...: Aug 23 14:28:32 Auth.notice: (Access-Request 10.10.116.4 166 000611-011c0c): Login OK [000611-011c0c] To be this ...: Aug 23 14:25:32 (Access-Request 10.10.116.4 166 000611-011c0c): Login OK Or to make it easier, I want to take out the 'Auth.notice: ' and anything encased in []'s. Here's one simple way you might accomplish that in Perl: #!/usr/bin/perl use strict; use warnings; my $text = 'Aug 23 14:28:32 Auth.notice: (Access-Request 10.10.116.4 166 000611-011c0c): Login OK [000611-011c0c]'; $text =~ s/Auth\.notice://; $text =~ s/\[[^]]+\]//; print $text\n; __END__ Hope that helps. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response