SET HEADING OFF PAGESIZE 0 FEEDBACK OFF
This will output only the result of 513
Jose A. Torres
BUCS Global Production Support
(212) 670-3879 - Office
(800) 774-4156 - Pager
(914) 632-4630 - Home
> -----Original Message-----
> From: Yacketta, Ronald [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, August 16, 2001 7:43 PM
> To: [EMAIL PROTECTED]; Beginners (E-mail)
> Subject: RE: brainfart...need minor regex assistance
>
> ok, then why does this only print the 1 in 19?????
>
> #!/usr/bin/perl -w
>
>
> my $session = qx(
> sqlplus -S rtdiag/*****\@DBNAME <<-!
> SET HEA OFF;
> select count(*) from session_list;
> quit
> !
> );
> #rem leading carrage returns
> $session =~ tr/^\n//;
> #rem leading spaces
> $session =~ s/^\s+//;
> #get the error if we have one
> my ($sesserr,$seserrtxt) = ($session =~ /(.*): (.*)/);
> #get the session count
> my $sessions = ( $session =~ /^(\d+)/ );
> print "1 $session\n";
> print "2 $sessions\n";
>
>
> results in
> 1 19
>
>
> 2 1
> > -----Original Message-----
> > From: Curtis Poe [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, August 16, 2001 18:49
> > To: Beginners (E-mail)
> > Subject: Re: brainfart...need minor regex assistance
> >
> >
> > --- "Yacketta, Ronald" <[EMAIL PROTECTED]> wrote:
> > > Folks,
> > >
> > > I am loosing it today, for some odd reason I am banging my
> > head against the
> > > wall trying to
> > > parse some sql output.
> > >
> > > I have the following output:
> > >
> > > SQL>
> > > COUNT(*)
> > > ----------
> > > 513
> > >
> > > I just need the # in a variable (513)
> > >
> > > could someone slap me silly for some help here?
> > >
> > > Regards,
> > > Ron
> >
> > How you get that depends upon where your output is. Is it in
> > a scalar?
> >
> > $output = q/SQL>
> > COUNT(*)
> > ----------
> > 513/;
> > my ( $count ) = ( $output =~ /(\d+)/ );
> >
> > $output will be undef if there are no digits.
> >
> > Cheers,
> > Curtis Poe
> >
> > =====
> > Senior Programmer
> > Onsite! Technology (http://www.onsitetech.com/)
> > "Ovid" on http://www.perlmonks.org/
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Make international calls for as low as $.04/minute with
> > Yahoo! Messenger
> > http://phonecard.yahoo.com/
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]