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/\\ /;
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
#!/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/\[
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
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"; }
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
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
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
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
>
>
> 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(
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 $_`; }
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
12 matches
Mail list logo