Re: Using case in Perl

2007-04-05 Thread Jenda Krynicky
From: Jeff Pang <[EMAIL PROTECTED]> > >Which is the same as > > > >sub say {print @_, "\n"} > > > >chomp( my $var = ); > >for( $var ) { > >if( /\D/ ){ > >say "Needs a number!" > >} > >elsif( $_ == 1 ) { > >say "Got 1!" > >} > >elsif( $_ == 2 ) { > >say "

Re: Using case in Perl

2007-04-05 Thread Jeff Pang
> >Which is the same as > >sub say {print @_, "\n"} > >chomp( my $var = ); >for( $var ) { >if( /\D/ ){ >say "Needs a number!" >} >elsif( $_ == 1 ) { >say "Got 1!" >} >elsif( $_ == 2 ) { >say "Got 2!" >} >else { >say "You said $_" >}

Re: Using case in Perl

2007-04-05 Thread Jenda Krynicky
From: oryann9 <[EMAIL PROTECTED]> > To share some information in the up-incoming Perl 5.10 > there will be a replacement for the switch clause. > > The given-when is the Perl answer to the switch > (or case) keyword in other programming languages. > It replaces Switch.pm, which was a pre-Perl 5.10

Re: Using case in Perl

2007-04-04 Thread oryann9
--- > > Perl doesn't have the "switch" control statement. > But you can get it by looking at CPAN: > http://search.cpan.org/~rgarcia/Switch-2.13/Switch.pm > To share some information in the up-incoming Perl 5.10 there will be a replacement for the switch clause. The given-when is the Perl answe

Re: Using case in Perl

2007-04-04 Thread Chas Owens
On 4/4/07, Igor Sutton Lopes <[EMAIL PROTECTED]> wrote: snip unless (fork) { snip The fork function has three returns: undef, zero, and non-zero. It returns 0 to the child and a pid that is non-zero to the parent on success or undef to the parent on failure. It is important to catch this

Re: Using case in Perl

2007-04-04 Thread Igor Sutton Lopes
On 2007/04/04, at 14:58, Jeff Pang wrote: How about this? if ($ARGV[0] eq 'start') { print "Starting PostgreSQL:\n"; unless (fork) { exec "su - $PGUSER -c \"$DAEMON -D \'$PGDATA\' "; }else { print "ok\n"; exit; } } elsif ($ARGV[0] eq 'stop') { ..

Re: Using case in Perl

2007-04-04 Thread Jeff Pang
>In bash i have: > >#case $1 in ># start) ># $ECHO_N "Starting PostgreSQL: "$ECHO_C ># su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>>$PGLOG 2>&1 ># echo "ok" ># ;; > >In perl, How I to build it ? > How about this? if ($ARGV[0] eq 'start') { print "Starting PostgreSQL:\

Using case in Perl

2007-04-04 Thread Rodrigo Tavares
Hello, I'm changing the script postgresq-init.sh for postgresql-init.pl. I made all perl scripts for store the database names. But my doubt is the case. In bash i have: #case $1 in # start) # $ECHO_N "Starting PostgreSQL: "$ECHO_C # su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG