Ask a Question related to PERL Beginners, Design and Development.
-
Manish Uskaikar #1
Command line Syntax
Hi,
I want to do a simple search replace on a unix command prompt. What i require is a syntax to do is?
echo "I am Manish"|<perl command>
output I am Jeff.
Please help.
Regards
Manish U
------------------------------
The information contained in this message is confidential and proprietary to KnowledgeWorks Global Limited, Mumbai, India. It is intended only for the use of the individual or entity to whom it is addressed. If you are not the intended recipient, or the authorized agent thereof, you are hereby notified that any disclosure, use, distribution, dissemination or copying in any form of any information contained in this message is strictly prohibited. If you have received this message by mistake or error, please notify us immediately by return email to the sender or by fax on number +91-22-28291673 and delete all copies of the original message.
Phone : 91-22-56971177 Ext 323
Manish Uskaikar Guest
-
Syntax error - line too long
I'm trying to send a newsletter to a bunch of people using cfmail. Some of them receive it and some don't. The ones that do not recieve it get an... -
ASP Command Object Syntax Errors
I'm having difficulty using a straight-forward ASP/VBScript Command Object generated by DMX04. The code is supposed to insert into a SQL Server 2000... -
Grant Command Syntax
I've got a MySQL database which contains users and their passwords. I have a PHP script that allows me to add new users and passwords to the... -
RUN/execute a Command-Line command from an ASP page
Hi, I need to RUN/execute a Command-Line command from an ASP page. This is the command: sse45.exe -i k:\o\2.wmv -o k:\o\2.shh -w 128 -df 0 -m 2... -
RUN/execute a Command-Line command from an ASP page.
Hi, I need to RUN/execute a Command-Line command from an ASP page. This is the command: sse45.exe -i k:\o\2.wmv -o k:\o\2.shh -w 128 -df 0 -m 2... -
Ramprasad A Padmanabhan #2
Re: Command line Syntax
Manish Uskaikar wrote:
> Hi,
>
> I want to do a simple search replace on a unix command prompt. What i require is a syntax to do is?
> echo "I am Manish"|<perl command>
> output I am Jeff.
>
> Please help.
>
> Regards
> Manish U
> ------------------------------
> The information contained in this message is confidential and proprietary to KnowledgeWorks Global Limited, Mumbai, India. It is intended only for the use of the individual or entity to whom it is addressed. If you are not the intended recipient, or the authorized agent thereof, you are hereby notified that any disclosure, use, distribution, dissemination or copying in any form of any information contained in this message is strictly prohibited. If you have received this message by mistake or error, please notify us immediately by return email to the sender or by fax on number +91-22-28291673 and delete all copies of the original message.
>
> Phone : 91-22-56971177 Ext 323
>
There must be a better way but what comes to my mind is
echo "I am Manish" | perl -e 'while(<>){ s/Manish/Jeff/g ; print "$_"}'
BTW why would you want to do it in perl
A much faster alternative will be
echo "I am Manish" | sed 's;Manish;Jeff'
Bye
Ram
Ramprasad A Padmanabhan Guest
-
James Edward Gray II #3
Re: Command line Syntax
On Dec 1, 2003, at 8:06 AM, Ramprasad A Padmanabhan wrote:
echo "I am Manish" | perl -pe 's/Manish/Jeff/g'> There must be a better way but what comes to my mind is
>
> echo "I am Manish" | perl -e 'while(<>){ s/Manish/Jeff/g ; print "$_"}'
James
James Edward Gray II Guest
-
Drieux #4
Re: Command line Syntax
On Dec 1, 2003, at 3:41 AM, Manish Uskaikar wrote:
jeff,> I want to do a simple search replace on a unix command prompt.
> What i require is a syntax to do is?
> echo "I am Manish"|<perl command>
> output I am Jeff.
I am drieux.
What I would recommend is something old school,
in which you go with something like code:
#!/usr/bin/perl -w
use strict;
my ($find, $replace) = @ARGV;
while(<STDIN>)
{
$_ =~ s/$find/$replace/;
print $_;
}
then you can do:
[jeeves: 22:] echo "I am Manish" | ./simple_filter Manish Boyish
I am Boyish
[jeeves: 23:]
if you then put your script in one of the directories
which are in you PATH, as I do with my $HOME/bin,
then it will be findable.
As you want to 'grow it out' to handle the
error cases such as not having enough arguments,
and more and more complex RegEx, then you can
style it as you like.
HTH.
ciao
drieux
---
Drieux Guest



Reply With Quote

