Re: encoding script pain

2005-03-04 Thread John W. Krahn
Saurabh Singhvi wrote: #!/usr/bin/perl -w use strict; opendir(DIR,".") or die "Couldn't open $!"; our @names = readdir(DIR) or die "Couldn't open $!"; closedir(DIR); foreach my $name (@names){ if ($name =~ /avi$/) { my $var = $name; $var =~ s/\s/\\ /;

Re: encoding script pain

2005-03-04 Thread Vladimir D Belousov
First, your regext could be $var =~ s/[\s\[\]]/\\$1/g; Next, you should use two arguments style "system" calls: system("/usr/local/bin/programm", args); Third, you have to analyze a return code of a "system" command: my $status = system(...); print "Error [errno = $status]\n" if($status); Saurabh

encoding script pain

2005-03-04 Thread Saurabh Singhvi
#!/usr/bin/perl -w use strict; opendir(DIR,".") or die "Couldn't open $!"; our @names = readdir(DIR) or die "Couldn't open $!"; closedir(DIR); foreach my $name (@names){ if ($name =~ /avi$/) { my $var = $name; $var =~ s/\s/\\ /; $var =~ s/\[

Re: encoding script

2005-01-13 Thread Chris Devers
On Thu, 13 Jan 2005, JupiterHost.Net wrote: > > > perl -mstrict -we 'for(`ls`) { chomp;print `grep foo $_`; }' > > By which you're basically saying the following non-Perl statement:: > > > Right we already covered that a day or so ago, the shell is not the > way to go: Oh? I love Perl, but

Re: encoding script

2005-01-13 Thread JupiterHost.Net
perl -mstrict -we 'for(`ls`) { chomp;print `grep foo $_`; }' By which you're basically saying the following non-Perl statement:: Right we already covered that a day or so ago, the shell is not the way to go: perl -mstrict -MFile::Slurp -we 'for(read_dir(".")) { print "Process $_ here\n"; }

Re: encoding script

2005-01-12 Thread Chris Devers
On Wed, 12 Jan 2005, JupiterHost.Net wrote: > Saurabh Singhvi wrote: > > HI all, > > Hello, > > > i want to write a perl script in linux that would get the file names > > in the directory i am running it in and then execute a system command > > for each file.(the encoding line). how should i go

Re: encoding script

2005-01-12 Thread John W. Krahn
Saurabh Singhvi wrote: HI all, Hello, i want to write a perl script in linux that would get the file names in the directory i am running it in and then execute a system command for each file.(the encoding line). how should i go about it?? Something like this should work: #!/usr/bin/perl use warning

Re: encoding script

2005-01-12 Thread JupiterHost.Net
perl -mstrict -we 'for(`ls`) { chomp;print `grep foo $_`; }' Yikes, please don't shell out for this, and please don't suggest newbies should shell out for these calls. If you are going to write shell, why not just write shell. Your "script" is completely insufficient in terms of error handling, se

RE: encoding script

2005-01-12 Thread McBride, Dennis
ame (@names) { # do stuff here } I hope this helps -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of zentara Sent: Wednesday, January 12, 2005 6:58 AM To: beginners@perl.org Subject: Re: encoding script On Wed, 12 Jan 2005 08:03:19 +, [EMAIL PROTECTED

Re: encoding script

2005-01-12 Thread Wiggins d Anconia
> > > Saurabh Singhvi wrote: > > HI all, > > Hello, > > > i want to write a perl script in linux that would get the file names > > in the directory i am running it in and then execute a system command > > for each file.(the encoding line). how should i go about it?? > > perl -mstrict -we 'for(

Re: encoding script

2005-01-12 Thread JupiterHost.Net
Saurabh Singhvi wrote: HI all, Hello, i want to write a perl script in linux that would get the file names in the directory i am running it in and then execute a system command for each file.(the encoding line). how should i go about it?? perl -mstrict -we 'for(`ls`) { chomp;print `grep foo $_`; }

encoding script

2005-01-12 Thread Saurabh Singhvi
HI all, i want to write a perl script in linux that would get the file names in the directory i am running it in and then execute a system command for each file.(the encoding line). how should i go about it?? thnx in adv Saurabh PS:- i think i would be using "syscall" but i am confused about th