[16403] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3815 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 26 21:10:22 2000

Date: Wed, 26 Jul 2000 18:10:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <964660214-v9-i3815@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 26 Jul 2000     Volume: 9 Number: 3815

Today's topics:
        printing big numbers with comma(s) <hxshxs@my-deja.com>
    Re: printing big numbers with comma(s) <lauren_smith13@hotmail.com>
    Re: printing big numbers with comma(s) (Andrew Johnson)
    Re: return value of `eval "use lib"' (Sweth Chandramouli)
        shifting strings <david.t.liu@intel.com>
    Re: shifting strings (Marcel Grunauer)
    Re: shifting strings <lauren_smith13@hotmail.com>
        ssh in cgi's <mwatters@cobaltgroup.com>
    Re: ssh in cgi's <mwatters@cobaltgroup.com>
    Re: This is driving me crazy!! (Logan Shaw)
    Re: trapping INT signal on system call (Charles DeRykus)
        Watch sockets <ztinky@linux.nu>
    Re: Watch sockets (Logan Shaw)
    Re: Why won't  "use strict;"  work? <bart.lateur@skynet.be>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 26 Jul 2000 22:27:26 GMT
From: Howard <hxshxs@my-deja.com>
Subject: printing big numbers with comma(s)
Message-Id: <8lnok8$an4$1@nnrp1.deja.com>

I am trying to print out big numbers,

e.g.  2345084324
         2234532

in the following format:

      2,345,084,324
          2,234,532

there are many of them and values vary. Is there any way to print them
in a simple way in PERL? Thanks.


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Wed, 26 Jul 2000 16:01:51 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: printing big numbers with comma(s)
Message-Id: <8lnqiv$d87$1@brokaw.wa.com>


Howard <hxshxs@my-deja.com> wrote in message
news:8lnok8$an4$1@nnrp1.deja.com...
> I am trying to print out big numbers,
>
> e.g.  2345084324
>          2234532
>
> in the following format:
>
>       2,345,084,324
>           2,234,532
>
> there are many of them and values vary. Is there any way to print them
> in a simple way in PERL? Thanks.

RTFFAQ

perlfaq5: How can I output my numbers with commas added?

Lauren





------------------------------

Date: Wed, 26 Jul 2000 23:29:29 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: printing big numbers with comma(s)
Message-Id: <tvKf5.12631$k5.162034@news1.rdc1.mb.home.com>

In article <8lnok8$an4$1@nnrp1.deja.com>,
 Howard <hxshxs@my-deja.com> wrote:
> I am trying to print out big numbers,
> 
> e.g.  2345084324
>          2234532
> 
> in the following format:
> 
>       2,345,084,324
>           2,234,532
> 
> there are many of them and values vary. Is there any way to print them
> in a simple way in PERL? Thanks.

please see the faq on this issue:

perlfaq5
    How can I output my numbers with commas added?

You can read perlfaq5 with the perldoc utility:

    perldoc perlfaq5

Afterwards, try these:

    perldoc perldoc
    perldoc perl
    perldoc perlfaq

regards,
anrew

-- 
Andrew L. Johnson   http://members.home.net/andrew-johnson/
      Reality is that which, when you stop believing in 
      it, doesn't go away.
          -- Philip K. Dick


------------------------------

Date: Wed, 26 Jul 2000 23:48:50 GMT
From: sweth+perl@gwu.edu (Sweth Chandramouli)
Subject: Re: return value of `eval "use lib"'
Message-Id: <CNKf5.14233$eS6.244702@news1.rdc1.md.home.com>

In article <puo07hkx.fsf@macforce.sumus.dk>,
Jakob Schmidt  <sumus@aut.dk> wrote:
>sweth+perl@gwu.edu (Sweth Chandramouli) writes:
>> In article <8lm51k$bpo$1@agate.berkeley.edu>,
>> Eric Kuritzky <kuritzky@math.berkeley.edu> wrote:
>> >
>> >use doesn't return a value, so eval doesn't, either.
>> 	Odd, since the Perl Cookbook has this example of how to
>> trap exceptions in use statements:
>> 
>> unless (eval "use $mod") {
>>    warn "couldn't load $mod: $@";
>> }
>
>That's either outdated or plain wrong as far as I can see. As it is use() runs
>during compiletime which to me makes it pretty obvious that it shouldn't return
>anything.
	Except that eval() changes the definition of compile-time
a little--inside of an eval(), the use() is executed not during compile-time
per se, but instead (as I understand it) during the compile-time phase of a
block of code that is called during run-time.  Given the fact that, according
to the docs, _anything_ that is a valid perl program can be run inside of an 
eval(), it would seem to be that there shouldn't be any statements that don't 
have a return value of some sort.  That's a philosophical question, though; it 
doesn't affect the current behaviour.

>The eval() is a way to defer compilation (and running) of a string of code
>'til sometime during the runtime of the surrounding code. And even if use()
>did retur some value - it still wouldn't be what eval() would return:
>
>When you program says eval "use Moof", the code "use Moof" will be compiled
>(at which time the use statement is evaluated) and after that executed. Now
>since it contains no executable (runtime) code, nothing happens and therefore
>the eval returns nothing. OK?
	There are three parts to this process, however--the evaluation 
of the code, the compilation of it, and then the execution.  The fact that the 
execution is a no-op doesn't mean that the eval() couldn't trap the failure of
the compilation and be smart enough to set its exit status accordingly.  (I'm
not saying that it does this, since from its behaviour it doesn't; I'm just
saying that functionally, the causal link between eval() being a deferral of
compilation, and eval not returning anything from a use(), isn't as obvious as
you might think it is.  In fact, I'd go so far as to say that returning a
false exit status for an eval-ed use() that failed to compile executable code
is exactly the sort of thing that Perl, which goes to great pains to do what
is _probably_ right, _should_ be doing, so the "obvious" answer would be the
exact opposite.)

>BTW, remember that require is executed during runtime - so there's no reason
>for eval() unless you want your program to tolerate a failure.
	Or unless the contents of the require() are being determined at 
runtime, as I indicated was the case for my code.

	-- Sweth.

-- 
Sweth Chandramouli ; <sweth@sweth.net>
<a href="http://www.sweth.net/legal/disc.html">*</a>


------------------------------

Date: Wed, 26 Jul 2000 16:30:00 -0700
From: "David T. Liu" <david.t.liu@intel.com>
Subject: shifting strings
Message-Id: <8lns9p$8jl@news.or.intel.com>

Hi,

suppose I had a string:

$str1 = "abcd";
$str2 = shift $str1; #str2 == "abc"

Is there a built-in function that can do what "shift" above does?




------------------------------

Date: Wed, 26 Jul 2000 23:31:02 GMT
From: marcel@codewerk.com (Marcel Grunauer)
Subject: Re: shifting strings
Message-Id: <slrn8nutg3.1jm.marcel@gandalf.local>

On Wed, 26 Jul 2000 16:30:00 -0700, David T. Liu <david.t.liu@intel.com>
wrote:

>$str1 = "abcd";
>$str2 = shift $str1; #str2 == "abc"
>
>Is there a built-in function that can do what "shift" above does?


perldoc -f chop


-- 
Marcel
sub AUTOLOAD{($_=$AUTOLOAD)=~s;^.*::;;;y;_; ;;print} Just_Another_Perl_Hacker();


------------------------------

Date: Wed, 26 Jul 2000 17:06:50 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: shifting strings
Message-Id: <8lnucq$f3r$1@brokaw.wa.com>


David T. Liu <david.t.liu@intel.com> wrote in message
news:8lns9p$8jl@news.or.intel.com...
> Hi,
>
> suppose I had a string:
>
> $str1 = "abcd";
> $str2 = shift $str1; #str2 == "abc"
>
> Is there a built-in function that can do what "shift" above does?

I don't understand how a string_shift() would shift the first 3 characters
off of another string.  Do you just want to retrieve all but the last letter
of $str1?

# Some badly commented code:

$tmp = $str1;                    # Store $str1 for later
$str2 = chop $str1;              # Get the first character of $str1
$str1 = $tmp;                    # Restore $str1
($str1, $str2) = ($str2, $str1); # Swap $str1, $str2


If you want to remove the first character of the string (like I imagine a
string_shift() should), check out this link:

http://x68.deja.com/getdoc.xp?AN=492050434&CONTEXT=964655833.1726808078&hitn
um=4  [1]

Lauren
[1] If that doesn't work, do a search for 'pohc Abigail' on deja.com.





------------------------------

Date: Wed, 26 Jul 2000 15:44:04 -0700
From: "Mark Watters" <mwatters@cobaltgroup.com>
Subject: ssh in cgi's
Message-Id: <8lnpl9$elv$1@pinto.cobaltgroup.com>

Perhaps someone has tried doing this:

I'm querying a db to post on the web.  The server(server1) that contains the
db is not a web server so to get to it, my first subroutine ssh's into it
from server2(the web server), queries the db and put's the result's into an
array, subroutine two then is supposed to post the results in html.  It
works fine and the html is perfect when I run it from the command line of
server2 but when I go through a browser, none of the data is posted in the
source or otherwise.  The webserver is Apache.  Is there some sort of
permissions problem with Apache and ssh?

So, I've been trying to come up with a way to call the Dbquery separately
from the cgi and return the data to the cgi to post(using a child parent
forking piping type arrangement).  Is this even possible or shall I try
something else?

--
Mark Watters





------------------------------

Date: Wed, 26 Jul 2000 16:51:42 -0700
From: "Mark Watters" <mwatters@cobaltgroup.com>
Subject: Re: ssh in cgi's
Message-Id: <8lntk4$g5a$1@pinto.cobaltgroup.com>

Fahgettaboutit.

"Mark Watters" <mwatters@cobaltgroup.com> wrote in message
news:8lnpl9$elv$1@pinto.cobaltgroup.com...
> Perhaps someone has tried doing this:
>
> I'm querying a db to post on the web.  The server(server1) that contains
the
> db is not a web server so to get to it, my first subroutine ssh's into it
> from server2(the web server), queries the db and put's the result's into
an
> array, subroutine two then is supposed to post the results in html.  It
> works fine and the html is perfect when I run it from the command line of
> server2 but when I go through a browser, none of the data is posted in the
> source or otherwise.  The webserver is Apache.  Is there some sort of
> permissions problem with Apache and ssh?
>
> So, I've been trying to come up with a way to call the Dbquery separately
> from the cgi and return the data to the cgi to post(using a child parent
> forking piping type arrangement).  Is this even possible or shall I try
> something else?
>
> --
> Mark Watters
>
>
>




------------------------------

Date: 26 Jul 2000 18:18:11 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: This is driving me crazy!!
Message-Id: <8lnrjj$mkg$1@provolone.cs.utexas.edu>

In article <slrn8nthpe.5ls.tim@degree.ath.cx>,
Tim Hammerquist <tim@degree.ath.cx> wrote:
>>ivolla@my-deja.com wrote:
>>> I am using windows 98, Perl 5
>
>Here is your first problem... ;)  To be honest tho, I have Win98
>installed on my PC. That drive is divided into three parts:
>
>1) data that can be accessed with any app. (mostly just MP3s nowadays)
>2) apps that can run under wine (and usually aren't run anyway)
>3) apps that can't run under wine (and haven't been run for months)

But isn't it a waste of space to leave the second part empty?

:-)

  - Logan


------------------------------

Date: Wed, 26 Jul 2000 23:02:19 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: trapping INT signal on system call
Message-Id: <FyBunv.B9@news.boeing.com>

In article <8ll7om$en4$1@nnrp1.deja.com>,  <michaelgartlan@my-deja.com> wrote:
>HI ,
>
>I am relatively new to the perl world of IPC
>so all advice/contstructive crticism welcome.
>
>Please read below to see the program which
>I am strugling with - it describes what I'm
>trying to do and the problem I have
>with trapping the INT signal while
>"system" is executing (I am aware that
>system cmd blocks INT signal but hoping to
>find a clever work around).
>..
>Want to be able to detect an INT signal (e.g. CTRL-C
>or LSF bkill command) in my application so that I can
>put error message in log file to indicate failure and
>so I can perform clean-up (moving/deleting files
>from temp directory)
>
>...
>sub ctrl_c_handler {
>   open(LOG_FILE, ">>$LOG_FILE") or die "couldnt open LOG_FILE: $! \n" ;
>   syswrite LOG_FILE, "INT signal detected - e.g. CTRL-C -- ouch
>!!!!!!\n";
>   exit;
>}
> ...
>system("stdmsg.pl") == 0 or die "ERROR - stdmsg.pl did not succesfully
>complete";
>

Just check the system return value for signal termination:

my $rc = system("stdmsg.pl"); 
if ($rc) { 
   $rc >>= 8 if $rc > 255;   
   if (($rc & 127) == 2) {    # SIGINT termination 
      # log, etc.
   }
   if ($rc & 128) {         # core dump 
      # cleanup
   }
   die "system failed: $rc\n";
} 
   
SIGINT is usually 2. (signal.h to verify)

--
Charles DeRykus


------------------------------

Date: Thu, 27 Jul 2000 00:20:27 +0200
From: "Johan" <ztinky@linux.nu>
Subject: Watch sockets
Message-Id: <0tJf5.20720$rH5.47755@nntpserver.swip.net>

Hi.
How do I do to read from several sockets all the time and check if they
contain a message?




------------------------------

Date: 26 Jul 2000 18:45:44 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Watch sockets
Message-Id: <8lnt78$mmv$1@provolone.cs.utexas.edu>

In article <0tJf5.20720$rH5.47755@nntpserver.swip.net>,
Johan <ztinky@linux.nu> wrote:
>How do I do to read from several sockets all the time and check if they
>contain a message?

Well, if they're sockets that are used to access TCP streams, they
won't contain a literal message, but they will be read to allow you to
read (or write) some bytes.

In any case, "perldoc IO::Select".

Also, you may want to set your sockets for non-blocking IO.  Do a
"perldoc IO::Handle" and have a look at the "blocking" method.

  - Logan


------------------------------

Date: Wed, 26 Jul 2000 22:10:02 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Why won't  "use strict;"  work?
Message-Id: <paouns4gnpplvh5aun0kbg2ihg39v8jfv7@4ax.com>

BUCK NAKED1 wrote:

>I have a problem stopping
>until something is almost perfect. Not good, IMO, as too much time is
>spent that should probably be put into other venues with higher
>priorities.

Not really. It looks like you'll have learnt a lot more than you
anticipated, and not much of it having to do with a counter. "use
strict;" and file locking are pretty important concepts.
 
-- 
	Bart.


------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 3815
**************************************


home help back first fref pref prev next nref lref last post