Hello,

With this line the script run, no errors.

system "su postgres -c '/usr/local/pgsql/bin/pg_ctl
start -D /opt/@bancos[$i]'";

two things :

I use of stricts and warnings, and come this error
compilation when i wrote into my code.

Global symbol "$x" requires explicit package name at
./start-banco.pl line 7.
Global symbol "@word" requires explicit package name
at ./start-banco.pl line 11.
Global symbol "@bancos" requires explicit package name
at ./start-banco.pl line 17.

The compilation show there are variables globals.

What I can to resolve this problem ?

And How I can to use perldoc to read a directory and
store your names in a array ?

equal with x =`ls opt`;  @word = split /\s+/, $x;

I'm bash programmer, and i want learn perl.
 
Best regards,

Rodrigo Faria



> On Mar 23, 10:43 am, [EMAIL PROTECTED]
(Rodrigo Tavares)
> wrote:
> > Hello,
> >
> > My code is below:
> >
> 
> You should start your script with the following two
lines:
> use strict;
> use warnings;
> 
> You could use Perl's builtin 'readdir' function to
get the contents of
> a directory.
> Type 'perldoc -f readdir' for more info.
> > $aux = `ls /opt`;
> > @word = split /\s+/, $aux;
> >
> 
> No need for the initialization.
> > my @bancos = ();
> >
> 
> Use a more descriptive name than $i.
> $dir or $directory, possibly.
> > foreach my $i (@word)
> >   {
> >     if ( -e "/opt/$i/postgresql.conf" )
> >       {
> >        push(@bancos,$i);
> >       }
> >   }
> >
> 
> No need for a 'c' style for loop.
> 
> foreach my $dir ( @bancos )
> {
>    `su postgres -c "/usr/local/pgsql/bin/pg_ctl
start -D $dir`
> }
> > for ($i = 0; $i < @bancos; $i++)
> > {
> 
> You forgot the backticks for issuing a system
command.
> >   su postgres -c "/usr/local/pgsql/bin/pg_ctl
start -D
> > @bancos[$i]";
> >
> > }
> >
> > After running the script como the error:
> >
> > Can't locate object method "su" via package
"postgres"
> > (perhaps you forgot to load "postgres"?) at
./teste.pl
> > line 19.
> >
> > I don't understad this message ?
> >
> > Best regards,
> >
> > Rodrigo Faria Tavares
> >
> HTH, Ken


__________________________________________________
Fale com seus amigos  de graça com o novo Yahoo! Messenger 
http://br.messenger.yahoo.com/ 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to