Help - Search - Member List - Calendar
Full Version: encoding script pain
WorkTheWeb Forums > Webmaster Resources > Perl Beginner Help
Support our Sponsors!
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/[/\[/;
$var =~ s/]/\]/;
system("mencoder $var -ovc lavc -oac copy -o $var.avi");
}
}


in this script i am having a big problem.........the script just ends
after the system command and returns to the shell..........what could
be the reason???

some1 plz help me

thnx in adv
Saurabh

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 Singhvi wrote:

QUOTE
#!/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/[/\[/;
$var =~ s/]/\]/;
system("mencoder $var -ovc lavc -oac copy -o $var.avi");
}
}


in this script i am having a big problem.........the script just ends
after the system command and returns to the shell..........what could
be the reason???

some1 plz help me

thnx in adv
Saurabh





--
Vladimir D Belousov
HiTech solutions for business
http://businessreklama.ru

John W. Krahn
Saurabh Singhvi wrote:
QUOTE
#!/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/[/\[/;
$var =~ s/]/\]/;
system("mencoder $var -ovc lavc -oac copy -o $var.avi");
}
}


in this script i am having a big problem.........the script just ends
after the system command and returns to the shell..........what could
be the reason???

This should work better:

#!/usr/bin/perl -w
use strict;

opendir DIR, '.' or die "Couldn't open '.' $!";
( my @names = readdir DIR ) or die "Couldn't read '.' $!";
closedir DIR;

foreach my $name ( @names ) {
next unless $name =~ /avi$/;
my $var = $name;
system( 'mencoder', qq("Q$varE"), '-ovc', 'lavc', '-oac', 'copy', '-o',
qq("Q$varE.avi") ) == 0
or die "system 'mencoder' failed: $?";
}



John
--
use Perl;
program
fulfillment


PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.