[17705] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5125 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 15 18:05:46 2000

Date: Fri, 15 Dec 2000 15:05:16 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <976921516-v9-i5125@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 15 Dec 2000     Volume: 9 Number: 5125

Today's topics:
    Re: <STDIN> vs. byte-by-byte editing <ayoungtechie@my-deja.com>
    Re: Ada feature borrowed for Perl?? <no@spam.net>
    Re: Ada feature borrowed for Perl?? <no@spam.net>
    Re: Ada feature borrowed for Perl?? (Tom Christiansen)
    Re: basic code -- why won't it work??!! <jdhunter@nitace.bsd.uchicago.edu>
    Re: basic code -- why won't it work??!! <ren.maddox@tivoli.com>
        Capturing text from a   task run by a perl script on Wi <Mike_Matteson@dg.com>
    Re: Errors in HTTP/Response & LWP/Response (BUCK NAKED1)
        get epoch seconds from "mm/dd/yyyy" <sfarris9@home.com>
    Re: get epoch seconds from "mm/dd/yyyy" <bart.lateur@skynet.be>
    Re: Help-Perl/Mysql problem <mbudash@sonic.net>
    Re: how to check if there is text in an input text fiel <mbudash@sonic.net>
    Re: Multiple ICMP Pings <cbah@chez.com>
    Re: My first JAPH.... <lmoran@wtsg.com>
    Re: My first JAPH.... <elijah@workspot.net>
    Re: Network <cbah@chez.com>
        Newbie question: IO::Socket::INET and select <wolfgang.fritz@gmx.net>
        One liner suggestions for the following <kereez@yahoo.com>
        One-Liner to Sum a Stack of Numbers? <revjack@revjack.net>
    Re: One-Liner to Sum a Stack of Numbers? <jeffp@crusoe.net>
    Re: One-Liner to Sum a Stack of Numbers? <ren.maddox@tivoli.com>
    Re: One-Liner to Sum a Stack of Numbers? (Tramm Hudson)
    Re: One-Liner to Sum a Stack of Numbers? (Tramm Hudson)
    Re: One-Liner to Sum a Stack of Numbers? <elijah@workspot.net>
    Re: One-Liner to Sum a Stack of Numbers? <revjack@revjack.net>
    Re: perl and apache process <cbah@chez.com>
        perl5 missing breakpoint tmorset@tus.ssi1.com
        PERLLIB,PERL5LIB - How to unset in perl script? <ekulis@apple.com>
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (John Stanley)
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <nospam.newton@gmx.li>
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (John Stanley)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 15 Dec 2000 21:13:27 GMT
From: A Young Techie <ayoungtechie@my-deja.com>
Subject: Re: <STDIN> vs. byte-by-byte editing
Message-Id: <91e1hf$jcb$1@nnrp1.deja.com>

In article <3A37CE9B.C9DD45EA@nowhereatall.com>,
  mothra <mothra@nowhereatall.com> wrote:
>
> type perldoc -q password
>

ActivePerl 5.00502 couldn't find anything in all 9 FAQs. What does the
page say?
--
nothing is ever too good to be true
- michael faraday


Sent via Deja.com
http://www.deja.com/


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

Date: Fri, 15 Dec 2000 20:56:43 GMT
From: "Misanthrope" <no@spam.net>
Subject: Re: Ada feature borrowed for Perl??
Message-Id: <fAv_5.10488$h67.675882@newsread1.prod.itd.earthlink.net>


Ada has two different keywords that deal with packages.

If you had a package called Foo, you would make it visible to your code via
the "with" statement.
The "use" statement merges the package interface into your namespace.
Without the "use", your code looks like this:

Foo.somemethod();





<gdemont@my-deja.com> wrote in message news:91cu9j$kkl$1@nnrp1.deja.com...
>
> > Does Ada use 'use' to use packages?
>
> Yep - Ada uses to use 'use' to use packages!
>
> Some sources on page below to take a look...
>
>   http://members.nbci.com/_XMCM/gdemont/gsoft.htm
>
> G.
>
>
> Sent via Deja.com
> http://www.deja.com/
>




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

Date: Fri, 15 Dec 2000 20:59:12 GMT
From: "Misanthrope" <no@spam.net>
Subject: Re: Ada feature borrowed for Perl??
Message-Id: <ACv_5.10494$h67.676806@newsread1.prod.itd.earthlink.net>


"Jeff Robertson" <jeff_robertson@yahoo.com> wrote in message
news:91d4kg$p5j$1@nnrp1.deja.com...
> In article <vRk_5.5127$UN1.489925@newsread2.prod.itd.earthlink.net>,
>   "Misanthrope" <no@spam.net> wrote:
> > >
> > > Packages ?
> > >
> >
> > I don't think so.  Ada took that idea from Pascal and/or Modula 2
> and/or
> > Clu.
> >
>
> Doesn't matter where Ada's designers got the idea. Ada still could have
> been the immediate inspiration for adding it to Perl.


I've always taken it that Larry was talking about new language features that
Ada had introduced.  The only thing I can think of that was new to Ada (so
far as I know) and also exists in Perl is the "elsif" keyword.  Most
languages allow "else if", but Ada and Perl are the only languages I can
think of with an "elsif".






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

Date: 15 Dec 2000 15:33:21 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: Ada feature borrowed for Perl??
Message-Id: <3a3a9c31@cs.colorado.edu>

In article <ACv_5.10494$h67.676806@newsread1.prod.itd.earthlink.net>,
Misanthrope <no@spam.net> wrote:
>I've always taken it that Larry was talking about new language features that
>Ada had introduced.  The only thing I can think of that was new to Ada (so
>far as I know) and also exists in Perl is the "elsif" keyword.  Most
>languages allow "else if", but Ada and Perl are the only languages I can
>think of with an "elsif".

Underscores in numbers.

--tom


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

Date: 15 Dec 2000 14:05:36 -0600
From: John Hunter <jdhunter@nitace.bsd.uchicago.edu>
Subject: Re: basic code -- why won't it work??!!
Message-Id: <1rvgslv4a7.fsf@video.bsd.uchicago.edu>

>>>>> "John" == John W <jwmsng@greatNOSPAMwebsolutions.com> writes:

    John> Appears Unix is executing some other file, somewhere else,
    John> by the same name as file1. No visible output.

Yep, that's a sneaky one.  I guess that's why it's good idea to be in
the habit of executing code as ./filename.

Cheers,
John


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

Date: 15 Dec 2000 12:58:42 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: basic code -- why won't it work??!!
Message-Id: <m33dfpa4v1.fsf@dhcp11-177.support.tivoli.com>

"John W" <jwmsng@greatNOSPAMwebsolutions.com> writes:

> BINGO! I think I found it.
> 
> I renamed file2 to file1. It no longer works.
> 
> Appears Unix is executing some other file, somewhere else, by the same name
> as file1. No visible output.

Out of curiosity, what name where you using for file1?  A common
mistake is to name a script "test", which is a shell builtin that will
be run instead -- unless you use ./test or similar.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Fri, 15 Dec 2000 14:47:11 -0500
From: "Mike Matteson" <Mike_Matteson@dg.com>
Subject: Capturing text from a   task run by a perl script on WinNT
Message-Id: <91dsib$otd$1@imas0002.us.dg.com>

Hi,
    I'm trying to run some perl on Win NT and capture the text that is
generated by a command that will run at the "dos prompt"...as in the
following:

# find the status of the service on the NT box, and do something as a result
of the service
# running or not running
$text = `c:\netsvc eventlog \\mysystem /query`;
    if ($text =~ "running){
            ...do something exciting here...
        }

 ...unfortunately, this doesn't give anything...nor does

`c:\netsvc eventlog \\mysystem /query > filename`;

 ..put the text into a file...which it will from a .bat file...

so...I have resorted to running a bunch of little .bat files to dump the
text into a filename, and then can open the file and look at/test the
results...but it is kludgy...and I'd like to run it all from the perl
script.
    Any guru's out there that have solved this??  ...or can point out my
stupid mistake, if that is the case??
    Thanks,
            --MikeM--
        Matteson_Mike@emc.com




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

Date: Fri, 15 Dec 2000 13:55:18 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Errors in HTTP/Response & LWP/Response
Message-Id: <13236-3A3A7726-34@storefull-248.iap.bryant.webtv.net>

I meant to say...

Are there errors in HTTP/Response 
and LWP/UserAgent? ...

And while I'm here, if someone could show me a way to grab a URL and
store it by using a socket, that'd be great since I'm having trouble
with the LWP library. I've reviewed IO::Socket and IO::Socket::INET and
can't figure out how?

Thanks again,

--Dennis



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

Date: Fri, 15 Dec 2000 21:33:27 GMT
From: steve farris <sfarris9@home.com>
Subject: get epoch seconds from "mm/dd/yyyy"
Message-Id: <3A3A8FA6.8DADF86@home.com>

There must be an easy way to do this because the reverse is easily done.
To get a date string from epoch seconds you do : $string =
localtime($seconds);

But how to get epoch seconds from a string??

  $seconds = str_to_sec($string); ??

original spanis guitar music at http://www.mindspring.com/~nlymbo



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

Date: Fri, 15 Dec 2000 22:37:49 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: get epoch seconds from "mm/dd/yyyy"
Message-Id: <v17l3tcjnv4hdqarnu2ombakp67417oml5@4ax.com>

steve farris wrote:

>There must be an easy way to do this because the reverse is easily done.
>To get a date string from epoch seconds you do : $string =
>localtime($seconds);
>
>But how to get epoch seconds from a string??

There's the standard module (as in: in every Perl installation by
default) Time::Local. Yes, that is a pun: timelocal() is the inverse of
localtime(), and timegm() is the inverse of gmtime(). Feed these the
values as you would get from localtime() in array context, and it will
efficiently look up the inverse function.

All you still need to do, is parse your string. Don't forget to subtract
1 from your month number. Use whatever time you like, for example
(0,0,0) for midnight.

-- 
	Bart.


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

Date: Fri, 15 Dec 2000 11:32:58 -0800
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Help-Perl/Mysql problem
Message-Id: <mbudash-D849A2.11325815122000@news.pacbell.net>

In article <3A39EC83.A31CC23@ub.uit.no>, ofuuzo <ofuuzo@ub.uit.no> 
wrote:

> Hello,
> I am new in the world of perl/Mysql. I wrote my first perl/mysql script
> where data are inserted  from an html form and  send it to a perl script
> that would write it to a mysql database. It is working.  When I view the
> data using mysql command, it shows the following:
> 
> mysql> select * from test;
> +------------------------------------+------+
> | Name                               | Age  |
> +------------------------------------+------+
> | . Test
>    . Testing testing
>       . test                              |  777 |
> +------------------------------------+------+
> 1 row in set (0.00 sec)
> 
> But when I call (view) the same data via perl on the browser, it appears
> on the same line like this;
> 
> Name                                                        Age
>  . Test . Testing testing . test                      777
> 
> I am not sure how to separate the data so that it would appear on the
> browser like this:
> 
> Name                                                       Age
>  . Test
>    . Testing testing
>       . test                                                   777
> 
> Thanks in advance!
> - Ofuuzo
> 

if i understand your problem, the 'Name' column contains:

 . Test
  . Testing testing
     . test

that is, there are 2 embedded newines, right? well, html interprets 
newlines as nothing more than whitespace and puts all the data on one 
line. so, in your script, before you write out the data, do this:

$Name =~ s/\n/<BR>/g;

this says "in the $Name variable, substitute *each* occurence of newline 
with the html tag to go to the next line (<BR>)".

hth-
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Fri, 15 Dec 2000 11:39:23 -0800
From: Michael Budash <mbudash@sonic.net>
Subject: Re: how to check if there is text in an input text field?
Message-Id: <mbudash-C7F019.11392315122000@news.pacbell.net>

In article <90jeon$iba$1@nnrp1.deja.com>, alazarev1981@my-deja.com 
wrote:

> In article <90jeh9$i6c$1@nnrp1.deja.com>,
>   alazarev1981@my-deja.com wrote:
> > Simple problem:
> >
> > I've got an html page with:
> > <input type="text" name="blah">
> >
> > The form is sent to the process.cgi file that gathers the form
> > information as such:
> > $text = cgi->param('text');
> >
> > Then I want to print that text to a new file if and only if that field
> > has text in it. So I wrote the following line:
> > if($text != "") {
> >   print NEW_FILE "Your new text is here: $text";
> > }
> >
> > Everything works except the if condition is never met. I know the
> $text
> > variable has the data in it because when i just print it out the text
> > is there, but my condition to check if the $text vaeiable is NULL must
> > not be right. Any answers?
> >
> > Thanks in advance,
> >
> > Alex Lazarevich
> > alazarev@itg.uiuc.edu
>
> Sigh...
> 
> I meant to say that my .cgi file reads like such:
> $text = $cgi->param('blah');
> not
> $text = $cgi->param('text);
> 
> So thats not the problem.
> 

no, it's not...

try:

if ($text ne "") {

or even:

if ($text) {

== and != are for numbers, eq and ne are for text...

hth-
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Fri, 15 Dec 2000 15:12:06 -0500
From: "Vladimir Silyaev" <cbah@chez.com>
Subject: Re: Multiple ICMP Pings
Message-Id: <91dtuc$k8s$1@slb7.atl.mindspring.net>


"Rodney Ramos" <rodneyra@my-deja.com> wrote in message
news:91d884$rtv$1@nnrp1.deja.com...
> Does anyone know how can I make a scrip to ping several hosts at same
> time? I mean, I want to ping several hosts without having to wait one
> finish to ping the next, because I have to do this in a short period of
> time and I have more than 1,000 hosts.
How about this:
open(PING1, "ping -c 1 hostname1|")
for all number of hosts what you like to ping simultaneosly
and after that you can use or 'select' and  for read output or call wat and
look for pid/return code.

--
Vladimir Silyaev
Brainbench MVP for Perl
http://www.brainbench.com





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

Date: Fri, 15 Dec 2000 14:52:33 -0500
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: My first JAPH....
Message-Id: <qitk3tkfnhmio21cn4kkpimungk0ud3sl6@4ax.com>

On Thu, 14 Dec 2000 18:53:54 GMT, Jeff Robertson
<jeff_robertson@yahoo.com> wrote wonderful things about sparkplugs:

--SNIP--
>> While that is Randal's rule, many others don't follow it.
>>
>
>Personally I like to mess with the definition of what a "japh" is:
>
>@q=split '',"|/\\_ \n";print map{$q[($r=ord($_)-32)/10].
>$q[ $r %10] } split '', q'ABLLLLLCHLIB>BH>KLB>B#LBLC4#$'
>.q;.HLHH$ >HL$ -HUARA$BLB$L#$KLKH.KLKRLH-HL$L$$-$#H8!B%;
>
>
applause applause!  Very nice.


>
>Sent via Deja.com
>http://www.deja.com/


lmoran@wtsgSPAM.com
print "\x{263a}"


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

Date: 15 Dec 2000 20:07:24 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: My first JAPH....
Message-Id: <eli$0012151504@qz.little-neck.ny.us>

In comp.lang.perl.misc, Lou Moran  <lmoran@wtsg.com> wrote:
> print "\x{263a}"

I doubt most people are going to have a suitable font installed
for that. \x{2639}

Elijah
------
has local copies of all the PDFs at <URL:http://www.unicode.org/charts/>


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

Date: Fri, 15 Dec 2000 15:27:31 -0500
From: "Vladimir Silyaev" <cbah@chez.com>
Subject: Re: Network
Message-Id: <91dupf$hi2$1@slb6.atl.mindspring.net>


"Rick Langschultz" <rickshaw@fast.net> wrote in message
news:t3j6vab06l7h45@corp.supernews.com...
> I have a windows and a linux server, one upstairs(linux) and windows
> downstairs, I want to set up a chat client so we don't have to yell down
to
> my mom when we need something. Or vice-versa. Can i do this with the
>
> IO::Socket
> IO::Select
>
> Thingers. I hope so, if you could lead me to great resources that would be
> cool, thx
The answer doesn't have any relations to perl, but:
login to Linux using telnet from WinXX and after that 'write username' for
pager functionality or 'talk username' for chat functionality.
See write(1) and talk(1) for more info.

--
Vladimir Silyaev
Brainbench MVP for Perl
http://www.brainbench.com





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

Date: Fri, 15 Dec 2000 21:03:08 +0100
From: Wolfgang Fritz <wolfgang.fritz@gmx.net>
Subject: Newbie question: IO::Socket::INET and select
Message-Id: <3A3A78FC.E1E2602@fritz38552.news.cis.dfn.de>

Hallo,

I have the following problem:

I create a socket with

    $vboxd = IO::Socket::INET->new (
				    Proto => "tcp",
				    PeerAddr => "gurke",
				    PeerPort => "vboxd",
				    ) or return 0;

The connection is successfully established.

I read from the socket with

# load_message (number_of_bytes_to_read)
sub load_message {
    
    my $have = 0;
    my $take;
    my $rc;
    my ($rin, $rout, $ein, $eout);
    my $buffer;
    my $timeout = 4;
    while ($_[0] - $have > 0) {
	# setup read vector
	$rin = "";
	vec ($rin, fileno ($vboxd), 1) = 1;
	$ein = $rin;
	$rc= select ($rout=$rin, undef, $eout=$ein, $timeout);
	print "load_message: size = $_[0], rc = $rc, have = $have";
	if ($rc > 0) {
	    # max 1024 bytes / read
	    $take = $rc;
	    if ($take > 1024) {
		$take = 1024;
	    }
	    print " take = $take\n";
	    if (sysread ($vboxd, $buffer, $take) == $take) {
		syswrite (TMP, $buffer, $take);
		# delay (only for testing)
		select (undef, undef, undef, 0.1);
		$have += $take;
	    } else {
		return -1;
	    }
	} else {
	    return -1;
	}
    }
    print "load_message: $have bytes read\n";
    return $have;
}

The problem is that I always get $rc == 1, regardless of the test delay
I inserted. So I do the transfer byte by byte which is very slow.
I used similar constructions in C, and the select call returned the
number of bytes ready for reading. Why does that not work in Perl?

BTW: This is my first Perl program > "Hallo world", and the "Programming
with Perl" has been ordered but not arrived up to now... 

Wolfgang


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

Date: Fri, 15 Dec 2000 19:05:32 GMT
From: iwjaph <kereez@yahoo.com>
Subject: One liner suggestions for the following
Message-Id: <3A3A6B6F.7060707@yahoo.com>

I want to process all the files in a directory and encrypt them with the 
module Crypt::RC4.  I then want to rename the encrypted file to 
something with a different file name or extension.  For example, 
original file:  data.txt		encrypted file: x_data.txt

That is the basic functionality.  An additional piece of info which 
would be nice is to have it only encrypt files that have not been 
encrypted already.  For example if the encrypted file x_data.txt is 
already there skip over that file.

I almost have it working as described, but I would be someone out there 
could make this a one-liner?!

JF



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

Date: 15 Dec 2000 20:36:59 GMT
From: revjack <revjack@revjack.net>
Subject: One-Liner to Sum a Stack of Numbers?
Message-Id: <91dvdb$pq3$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight

More and more I find myself having to take a stream of
numbers that comes from some process, like: 

1192
2
44039
334
22
0
3384

 ...and simply determine the sum of them. I have been doing
it like this: 


(process) | perl -wle 'while(<>){$x+=$_}print $x'

Is there a better|smarter|faster|more elegant way to produce
the sum of such output?

-- 
___________________
revjack@revjack.net



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

Date: Fri, 15 Dec 2000 16:09:59 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: One-Liner to Sum a Stack of Numbers?
Message-Id: <Pine.GSO.4.21.0012151609130.17632-100000@crusoe.crusoe.net>

[posted & mailed]

On Dec 15, revjack said:

>(process) | perl -wle 'while(<>){$x+=$_}print $x'

perl -nle 'END{print$sum}$sum+=$_'

-- 
Jeff "japhy" Pinyan     japhy@pobox.com    http://www.pobox.com/~japhy/
CPAN - #1 Perl Resource  (my id:  PINYAN)       http://search.cpan.org/
PerlMonks - An Online Perl Community          http://www.perlmonks.com/
The Perl Archive - Articles, Forums, etc.   http://www.perlarchive.com/



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

Date: 15 Dec 2000 14:50:52 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: One-Liner to Sum a Stack of Numbers?
Message-Id: <m3r9398l3n.fsf@dhcp11-177.support.tivoli.com>

revjack <revjack@revjack.net> writes:

> (process) | perl -wle 'while(<>){$x+=$_}print $x'
> 
> Is there a better|smarter|faster|more elegant way to produce
> the sum of such output?

Well, you could let Perl do the loop for you, but then you have to
have an END block, so it isn't that much shorter.  Whether it is
better or not is subjective.  And I doubt it is any faster.

(process) | perl -wnle 'END{print$x}$x+=$_'

(I put the END block at the beginning to save a semicolon.)

-- 
Ren Maddox
ren@tivoli.com


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

Date: 15 Dec 2000 21:15:47 GMT
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: One-Liner to Sum a Stack of Numbers?
Message-Id: <91e1m3$ath$1@sloth.swcp.com>
Keywords: Hexapodia has nothing to do with it.

[posted and cc'd to cited author]

revjack  <revjack@revjack.net> wrote:
> More and more I find myself having to take a stream of
> numbers that comes from some process, like: 
> ...and simply determine the sum of them. I have been doing
> it like this: 
>
>(process) | perl -wle 'while(<>){$x+=$_}print $x'

Use of command line switches saves some bytes, although END{} takes
almost as many.

             perl -ne '$s+=$_;END{print"$s\n"}'

but this is not the best golf score possible...  One modification to
the spec allows more than one number per line, with a few byte cost:

             perl -ane '$s+=$_ for@F;END{print"$s\n"}'

Tramm
-- 
  o   hudson@swcp.com                  hudson@turbolabs.com   O___|   
 /|\  http://www.swcp.com/~hudson/          H 505.323.38.81   /\  \_  
 <<   KC5RNF @ N5YYF.NM.AMPR.ORG            W 505.986.60.75   \ \/\_\  
  0                                                            U \_  | 


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

Date: 15 Dec 2000 21:27:54 GMT
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: One-Liner to Sum a Stack of Numbers?
Message-Id: <91e2cq$b81$1@sloth.swcp.com>
Keywords: Dictionary attacks on secret NSA cryptosystems are possible.

Following up my own posting with a few byte savings:

In article <91e1m3$ath$1@sloth.swcp.com>, Tramm Hudson <hudson@swcp.com> wrote:
> Use of command line switches saves some bytes, although END{} takes
> almost as many.
>
>             perl -ne '$s+=$_;END{print"$s\n"}'
              perl -lne'END{print$s}$s+=$_'

> but this is not the best golf score possible...  One modification to
> the spec allows more than one number per line, with a few byte cost:
>
>             perl -ane '$s+=$_ for@F;END{print"$s\n"}'
              perl -lane'END{print$s}$s+=$_ for@F'
      
I forgot about the -l newline processing switch, which saved four bytes
and realized that I could save another byte by putting the END{} block
first -- no ; required.  Then I also realized that -e could take the
expression on the same argument with no space required after the options.

Tramm
-- 
  o   hudson@swcp.com                  hudson@turbolabs.com   O___|   
 /|\  http://www.swcp.com/~hudson/          H 505.323.38.81   /\  \_  
 <<   KC5RNF @ N5YYF.NM.AMPR.ORG            W 505.986.60.75   \ \/\_\  
  0                                                            U \_  | 


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

Date: 15 Dec 2000 22:00:53 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: One-Liner to Sum a Stack of Numbers?
Message-Id: <eli$0012151656@qz.little-neck.ny.us>

In comp.lang.perl.misc, Jeff Pinyan  <japhy@pobox.com> wrote:
> [posted & mailed]
> 
> On Dec 15, revjack said:
> 
> >(process) | perl -wle 'while(<>){$x+=$_}print $x'
> 
> perl -nle 'END{print$sum}$sum+=$_'

You can make that shorter:

  perl -nle'END{print$s}$s+=$_'

But this is still shorter:

  (tr ^J +;echo 0)|bc

In my shell, the ^J can be entered with <backslash><return>,
using the same number of bytes as that conceptual rendering.

Elijah
------
didn't we just do this for two files the other day?


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

Date: 15 Dec 2000 22:39:37 GMT
From: revjack <revjack@revjack.net>
Subject: Re: One-Liner to Sum a Stack of Numbers?
Message-Id: <91e6j9$6v$3@news1.Radix.Net>
Keywords: Hexapodia as the key insight

Ren, Jeff, Tramm, thanks for your followups. 

And last but never least, Eli:

:   (tr ^J +;echo 0)|bc

I figured there was a nice shell way to do it, I'll try it.

: didn't we just do this for two files the other day?

Gack, I hope not. I do try and search for the answers first
before posting (which is why I rarely post here - I almost
always find them first :)

-- 
___________________
revjack@revjack.net



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

Date: Fri, 15 Dec 2000 15:38:54 -0500
From: "Vladimir Silyaev" <cbah@chez.com>
Subject: Re: perl and apache process
Message-Id: <91dvi8$57s$1@nntp9.atl.mindspring.net>


"entropy" <xuvetyn@my-deja.com> wrote in message
news:91dnt4$agd$1@nnrp1.deja.com...
> hey, i thought this would have already been done a million times, but i
> can't find anything on it.
> i need a script that checks to make sure that the apache process is
> running and if not, start it. before i spend too much time on this my
> self, i thought i'd check to see if it's already been done (no need to
> reinvent the wheel, right? =)
#!/bin/sh
kill -0 `cat /var/run/httpd.pid`  >/dev/null 2>&1 || apachectl start

But it doesn't have any relation to perl and make that on a perl it's an
overkill.

--
Vladimir Silyaev
Brainbench MVP for Perl
http://www.brainbench.com






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

Date: Fri, 15 Dec 2000 19:13:41 GMT
From: tmorset@tus.ssi1.com
Subject: perl5 missing breakpoint
Message-Id: <91dqgt$cql$1@nnrp1.deja.com>

I'm having a very strange problem with the perl5 debugger
not stopping at a set breakpoint (I'm using version
5.005_02 built for sun4-solaris).

I have two short foreach loops with the same control statement,
one after the other:

foreach $location ( @main::includeFilesAndDirectories )
{
   ...
}
foreach $location ( @main::includeFilesAndDirectories )
{
   ...
}

Both foreach statements are listed as breakable in the
debugger and the inside of each loop is executed (the list
isn't empty).  However, when I set a breakpoint on the first
foreach it never breaks. If I set a breakpoint on both of
these foreach statements or just the second foreach statement,
it will break.

It's easy to work around but I'm wondering what I'm missing
here.  Is this a bug?  I've looked around the FAQ and
previous posts but I can't find anything.  Any help would
be appreciated, thanks.

Tim Morse


Sent via Deja.com
http://www.deja.com/


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

Date: Fri, 15 Dec 2000 12:59:27 -0800
From: Ed Kulis <ekulis@apple.com>
Subject: PERLLIB,PERL5LIB - How to unset in perl script?
Message-Id: <3A3A862F.4622278E@apple.com>

Hi,

I'd like to unset PERLLIB and PERL5LIB within the perl script so that I
don't get the library mismatch error below.

>name_split.pl
Perl lib version (5.003) doesn't match executable version (5.006)
Compilation failed in require at
/home/vantive7/perl_dir/lib/diagnostics.pm line 5.
BEGIN failed--compilation aborted at
/home/vantive7/perl_dir/lib/diagnostics.pm line 5.
Compilation failed in require at name_split.pl line 42.
BEGIN failed--compilation aborted at name_split.pl line 42.


Our Unix environment is a little wild and I can't trust environment
variables, and I've written Korn shell defender scripts that unset all
non standard Korn shell variables so the environment completely
understood.

So, my problem is solved for Korn shell.

I'd like to run perl scripts without necessarily calling them from a ksh
wrapper.

I've tried 'no lib ' and I've tried deleting paths from @INC but it
seems that the perl script detects the library mismatch at the very
beggining of execution.

I did find the the -T (taint) option did unset the external lib
variables.  It's not practical for me to use the -T option because, I'm
training other developers in their first use of perl and they're just
not ready for the rigor of secure programming.

I also don't want to set the libraries explicitly. I want to rely on the
default locations of the libraries implicit from the shebang
#!/usr/local/bin/perl

You might think that I could just unset PERLLIB,PERL5LIB but I'm afraid
that it's not that simple.  As we rollout code it ends up in
environments where there are many people trying to "help" by presetting
various variables.

-ed




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

Date: 15 Dec 2000 21:55:55 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.1 $)
Message-Id: <91e41b$h5p$1@news.NERO.NET>

In article <flqj3tkfj60agk7n7k78c0s6oseo48otpl@4ax.com>,
Bart Lateur  <bart.lateur@skynet.be> wrote:
>My newsreader allows me to ignore WHOLE THREADS based upon the
>properties of just one post of one contribuant. The other posts are
>ignored by inference, based upon their "references" header.

So does mine. But it would require adding the message id by hand for
each repeat of the FAQ, which means I would have to see it and extract
the data. Oh, I suppose I could write something to do it automatically,
but isn't using a tag in the subject much easier?




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

Date: Fri, 15 Dec 2000 23:09:15 +0100
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.li>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.1 $)
Message-Id: <t8vk3t0kbcgr2eb1r9p7u12bcceckupfot@4ax.com>

On 14 Dec 2000 14:39:36 GMT, stanley@skyking.OCE.ORST.EDU (John Stanley) wrote:

> This isn't the Internet, it's USENET.

Why the caps?

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
If you're not part of the solution, you're part of the precipitate.


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

Date: 15 Dec 2000 22:27:06 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.1 $)
Message-Id: <91e5rq$hp7$1@news.NERO.NET>

In article <t8vk3t0kbcgr2eb1r9p7u12bcceckupfot@4ax.com>,
Philip 'Yes, that's my address' Newton <nospam.newton@gmx.li> wrote:
>On 14 Dec 2000 14:39:36 GMT, stanley@skyking.OCE.ORST.EDU (John Stanley) wrote:
>
>> This isn't the Internet, it's USENET.
>
>Why the caps?

Because there is a difference between "internet" as "a connection
between many networks" and "Internet", which is the particular
interconnected network that most people use.




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

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 5125
**************************************


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