[10523] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4115 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 30 22:07:05 1998

Date: Fri, 30 Oct 98 19:00:21 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 30 Oct 1998     Volume: 8 Number: 4115

Today's topics:
        0 - 1 toggling question junsc@sysic.hei.co.kr
    Re: 0 - 1 toggling question (Larry Rosler)
    Re: 0 - 1 toggling question (Matthew Bafford)
    Re: 0 - 1 toggling question <ljz@asfast.com>
        Can perl grab a file from another server? <webmaster@topproducer.com>
    Re: Can perl grab a file from another server? (Alastair)
    Re: CPAN problems - aghhhhh (Alastair)
    Re: CPAN problems - aghhhhh (Alan Young)
        How to copy files using system( ) in a Perl script <lfs97@tm.net.my>
    Re: Need help appending a string to a hash (Charles DeRykus)
    Re: Need help with OLE (Alastair)
    Re: Need help with OLE <chad@anlon.com>
    Re: Not to start a language war but.. (Dave Kirby)
    Re: Not to start a language war but.. <rra@stanford.edu>
    Re: Not to start a language war but.. <rra@stanford.edu>
    Re: Perl 5.004 install problem on Solaris 2.6 (Thad Floryan)
        perl and oracle <arm@home.net>
        perl art/puzzle (David Alan Black)
    Re: perl art/puzzle (David Alan Black)
    Re: perl news per Email? (John Stanley)
    Re: psychology of language choice (was Re: language war <mstachow@mit.edu>
    Re: Regex Explaination... (brian d foy)
        SSI Random Image (Newbie??) <jh943@bellsouth.net>
    Re: Subroutine question (Charles DeRykus)
    Re: Syntactic flexibility (was: Re: psychology of langu (Dave Kirby)
    Re: Syntactic flexibility (was: Re: psychology of langu <mstachow@mit.edu>
        Testing Perlscript at home <a9609339@unet.univie.ac.at>
        the way to change directory in Perl script junsc@sysic.hei.co.kr
        Unix to NT compatibility <arm@home.net>
    Re: Using system( ) command to copy files <ludlow@us.ibm.com>
    Re: Very Large DBM file: Finding Number of keys <rra@stanford.edu>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Sat, 31 Oct 1998 01:25:29 GMT
From: junsc@sysic.hei.co.kr
Subject: 0 - 1 toggling question
Message-Id: <71doub$cnq$1@nnrp1.dejanews.com>

Hi, All

I recently found out that negating a variable that has "1" does change its
value to null, not "0". How can I easily change its value to "0". the
operators "!", "not" and "~" all seem to change the value to null.

Any information would be greatly appreciated.

Thanks in advance.

Sungchun

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 30 Oct 1998 18:01:30 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: 0 - 1 toggling question
Message-Id: <MPG.10a40f57897d2abb9898f7@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <71doub$cnq$1@nnrp1.dejanews.com> on Sat, 31 Oct 1998 
01:25:29 GMT, junsc@sysic.hei.co.kr <junsc@sysic.hei.co.kr> says...
> I recently found out that negating a variable that has "1" does change its
> value to null, not "0". How can I easily change its value to "0". the
> operators "!", "not" and "~" all seem to change the value to null.
                            ^ That one certainly doesn't!

Simply add 0 to the result of the negation.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 30 Oct 1998 21:11:35 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: 0 - 1 toggling question
Message-Id: <MPG.10a43bd978cdedad9896f5@news.scescape.net>

In article <<71doub$cnq$1@nnrp1.dejanews.com>>, junsc@sysic.hei.co.kr 
(junsc@sysic.hei.co.kr) pounded the following:
=> Hi, All

Hi, Sungchun

=> I recently found out that negating a variable that has "1" does change its
=> value to null, not "0". How can I easily change its value to "0". the
=> operators "!", "not" and "~" all seem to change the value to null.

One option that comes to mind is (anything not 0 is changed to 0):

    $var = !$var+0;

Not exactly pretty, but it works...

You could do something like:

    sub toggle($) { $_[0] = !$_[0]+0; }

    $var = 1;
    toggle $var;

But it seems kinda silly to define a subroutine for such a simple 
thing.

=> Any information would be greatly appreciated.
=> 
=> Thanks in advance.

HTH,

=> Sungchun

--Matthew
Who is anxiously awaiting a 'better' way. :)


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

Date: 30 Oct 1998 21:11:58 -500
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: 0 - 1 toggling question
Message-Id: <ltk91hqy35.fsf@asfast.com>

junsc@sysic.hei.co.kr writes:

> Hi, All
> 
> I recently found out that negating a variable that has "1" does change its
> value to null, not "0". How can I easily change its value to "0". the
> operators "!", "not" and "~" all seem to change the value to null.
> 
> Any information would be greatly appreciated.

Here's one way to do it:

  my $x = 1;  # or anything that will evaluate to `true'
  my $y = (! $x) + 0;



-- 
 Lloyd Zusman   ljz@asfast.com
 perl -le '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x"'


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

Date: Fri, 30 Oct 1998 15:27:46 -0800
From: "Alistair Calder" <webmaster@topproducer.com>
Subject: Can perl grab a file from another server?
Message-Id: <71dhui$j71$1@supernews.com>

Here is a question I have been wondering about for some time.  I have tried
a few methods myself, but I had no success:

Our site currently has some news items that come from another site on
another server.  The pages are marked up slightly differently than the way I
mark them up, so I physically surf to the page, download it to my system,
alter it and then upload it to my server.

Is there a way that I can have Perl grab the file from the remote server and
save it to my local one?  I know how to edit the page within a script, but
not how to get it.

Thanks for any help,
Alistair Calder




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

Date: Fri, 30 Oct 1998 23:58:35 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Can perl grab a file from another server?
Message-Id: <slrn73koea.5p.alastair@calliope.demon.co.uk>

Alistair Calder <webmaster@topproducer.com> wrote:
>Here is a question I have been wondering about for some time.  I have tried
>a few methods myself, but I had no success:
>
>Our site currently has some news items that come from another site on
>another server.  The pages are marked up slightly differently than the way I
>mark them up, so I physically surf to the page, download it to my system,
>alter it and then upload it to my server.
>
>Is there a way that I can have Perl grab the file from the remote server and
>save it to my local one?  I know how to edit the page within a script, but
>not how to get it.

You can do this using the LWP module available on CPAN.

HTH.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Sat, 31 Oct 1998 00:05:39 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: CPAN problems - aghhhhh
Message-Id: <slrn73kori.5p.alastair@calliope.demon.co.uk>

Alan Young <alany@2021.com> wrote:
>Hello.
>
>I've finally managed to get perl and CPAN installed and working on my
>shell account at work (HPUX 9.something) and am slowly whittling away
>problems here and there.
>
>I've run into a problem I can't seem to get past.
>
>When I try to install anything that has a tar.gz extension I get the
>following error message:

What do you mean 'installed CPAN'? Using the CPAN module a la ;

perl -mCPAN -e shell ?

Is the 'tar' program in your search path - as the user you are when you install?
What does ;

which tar

return?

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Sat, 31 Oct 1998 00:42:06 GMT
From: alany@2021.com (Alan Young)
Subject: Re: CPAN problems - aghhhhh
Message-Id: <36455cd1.82816363@news.supernews.com>

On Fri, 30 Oct 1998 20:57:46 GMT, alany@2021.com (Alan Young) wrote:

>I've run into a problem I can't seem to get past.

Well, I've gotten past those two problems ... sort of.  I turned off
shared libraries (didn't really want to, but apparently HPSUX has a
bug in ld) and I was able to get past the invalid loader fixup needed
error message.  Does anyone know of a fix for this?  I can't find
anything.

As for the other problem (needing gzip and tar) I just reconfigured
CPAN and it seems to have gotten beyond that.

Now I'm getting the following error:

ld: No $UNWIND_END$ subspace has been defined (probably missing
/lib/crt0.o)

I checked, /lib/crt0.o does indeed exist.  I can't find any
documentation on where to set this variable or flag or whatever or how
I should set it up.  Does anyone have any info for me?


Alan Young
Technical Support
2021.Interactive, LLC


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

Date: 31 Oct 1998 09:02:28 +0800
From: "Liew Fook Sin" <lfs97@tm.net.my>
Subject: How to copy files using system( ) in a Perl script
Message-Id: <01be4629$697f33a0$53b6bcca@tm.net.my>

Hai,
I need to copy a file from a particular location to another location using
a cgi written in Perl.
I have tried the following command but it didn't work

#! /usr/bin/perl

$filename = "/path/some_filename";
$destination_filename = "/path/another_filename"
system (cp $filename $destination_filename);


Can anyone, please help.
Thanks a lot

Liew
exit;


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

Date: Sat, 31 Oct 1998 00:21:06 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Need help appending a string to a hash
Message-Id: <F1o0z6.4Iw@news.boeing.com>

In article <3638F1B9.3652DAC5@dsp.sps.mot.com>,
Gary Jackson  <garyj@dsp.sps.mot.com> wrote:
>#!/usr/local/bin/perl
>%Fail_Vec = ();
>while (<>) {
>    chomp;      # strip record separator (pesky newline)
>(/^(\d+)\.\s+\S+\s+\S+\s+\S+\s+(\d+)\,\s+(\d+)\,.*PATTERNS(\S+).*/) {
>               if ($Fail_Vec{$2} == 0) {
>                 push( @{$Fail_Vec{$2}}, $4 ); # SAVE THE STRING AT END
>OF ROW
>               }
>             $Fail_Vec{$2}++; # INCREMENT THE NUMBER OF FAILS
>         }
>}
> ....

something more like this probably;

(my $key,my $pattern) = /^your regex/;
unless ( $Fail_Vec{$key} ) {
      push(@$Fail_Vec{$key}, [1,$pattern]);
} else { 
      $Fail_Vec{$key}[0]++;
}

count is $Fail_Vec{$key}[0]; pattern as $Fail_Vec{$key}[1] 


perldoc -f perllol or perldsc for background. 

hth,
--
Charles DeRykus


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

Date: Sat, 31 Oct 1998 00:01:49 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Need help with OLE
Message-Id: <slrn73kokc.5p.alastair@calliope.demon.co.uk>

Chad Moston <chad@anlon.com> wrote:
>I have searched extensively to find documentation on the web about OLE
>and have come up short.  Can anyone send me some URL's of some good
>sites to get me started with this?
>
>I appreciate the help.

I went to one of the big search engines and typed in 'OLE' and found '248050'
web pages. 

What has this got to do with Perl?

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Fri, 30 Oct 1998 18:49:54 -0600
From: Chad Moston <chad@anlon.com>
To: alastair@calliope.demon.co.uk
Subject: Re: Need help with OLE
Message-Id: <363A5EB2.578FE0FD@anlon.com>

It allows you to use applications such as excel and word.

Alastair wrote:

> Chad Moston <chad@anlon.com> wrote:
> >I have searched extensively to find documentation on the web about OLE
> >and have come up short.  Can anyone send me some URL's of some good
> >sites to get me started with this?
> >
> >I appreciate the help.
>
> I went to one of the big search engines and typed in 'OLE' and found '248050'
> web pages.
>
> What has this got to do with Perl?
>
> --
>
> Alastair
> work  : alastair@psoft.co.uk
> home  : alastair@calliope.demon.co.uk





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

Date: Sat, 31 Oct 1998 00:47:17 GMT
From: dkirby@see.sig.for.addr (Dave Kirby)
Subject: Re: Not to start a language war but..
Message-Id: <363b56a7.3421523@read.news.global.net.uk>

On Fri, 30 Oct 1998 15:41:03 -0500, John Porter <jdporter@min.net>
wrote:

>Dave Kirby wrote:
>> 
>> Zenin <zenin@bawdycaste.org> wrote:
>> >John Porter <jdporter@min.net> wrote:
>> >: 'package' doesn't actually relate to Perl's OO in any special way;
>> >: it just changes the default namespace for any following unqualified
>> >: declarations.
>> >
>> > It also affects the single argument form of bless() in ways that
>> > will make the above example fail:
>> 
>> Doesnt the fact that two (presumably) experienced perl programmers can
>> disagree on this blow the foot off your assertion that creating a
>> class in perl is as easy as creating one in python?
>
>Maybe it would, except for the fact that we don't disagree.
>As I have already said, the point of my little code snippet
>was to show that the 'package' word is not required to get
>classes in Perl.  I should have given some non-constructor
>method, like
>	sub Widget::popup { my $self = shift; }
>
>John Porter

OK, "disagree" was a poor chice of words - "got it wrong" would have
been better. Surely you can see why the fact that 

	sub Widget::new { bless {} }
 is wrong but 
	sub Widget::new { bless {}, shift }
is right is not exactly obvious and is the kind of thing that puts
people (ok, me) off using perl OO.

If someone who has little or no experience of perl looks at a module
file it is not obvious at all that a class is being declared. I would
go as far as saying that a total novice would not have a hope in hell
of understanding what is going on without a careful reading of the
docs.  With python it is immediately apparent that a class is being
created even to someone who has never seen the language before.

I used perl for years for the creation of various utilities and I cant
remember ever using classes in production code - it simply wasnt in my
perl mindset. This may have been partly a result of starting with
perl4 so never getting into the habit, but also because the process is
unnecessarily complicated. For most of that time I was programming in
C++ as my main language so was familiar with the benefits of OO
techniques, and had played around with classes when I first got perl5
so I knew how to do it, but when it came to the crunch I would still
write perl procedurally.  When I started using python I found creating
and using classes to be so simple that I would do it without a second
thought, making my python code better structured than my perl.

I may be unusual in this regard, but from what others have written in
c.l.py I dont think I am.

	Dave
--------------------------------------------------
All great ideas start as heresy and end as dogma.

dkirby@   <-figure this out, spambots!
bigfoot.   My opinions are my own,
com        but I'm willing to share.


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

Date: 30 Oct 1998 17:12:43 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Not to start a language war but..
Message-Id: <yl7lxh356c.fsf@windlord.stanford.edu>

In comp.lang.perl.misc, John Porter <jdporter@min.net> writes:
> Uri Guttman wrote:

>> even though i can make my editor wider than 80 columns i fnd that is a
>> good width to keep for reading and writing anything including
>> code. long code lines even when visible and not wrapped are annoying to
>> me to read.

> That is a good point, and reminds of the fact that newspapers long ago
> discovered that reading speed is higher for narrower columns (to a
> point, I assume).  Too much horizontal eye motion is
> difficult|stressful|slow.

The problem, as I understand it, is that your eye has a limited ability to
track what line it was on when it returns to the left side of the text.
If the text is too long, you lose track of what line you just read each
time you move to the next line and take a millisecond to figure out your
place again.  It slows reading speed and hurts concentration when that
happens.

Easy experiment to clearly see the effects of this:  Open a page with a
lot of text in a web browser and make the web browser window very wide.
Read a paragraph or two.  Now resize the browser so that it's only 40 or
50 columns (of your default font) wide, and read a few more paragraphs.
The difference is pretty noticeable.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 30 Oct 1998 17:33:15 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Not to start a language war but..
Message-Id: <ylvhl11pno.fsf@windlord.stanford.edu>

In comp.lang.perl.misc, Jason Orendorff <jorendorff@ixl.com> writes:

> The corresponding Python for this admittedly inane little routine would
> be something like:

>   import os

>   def blah(dir):
>       os.chdir(dir)
>       for file in os.listdir('.'):
>           stats = os.stat(file)
>           f = open(file, 'r')
>           f.seek(stats[7]-2)
>           x = f.read(2)
>           if x == '\001\002':  os.remove(file)
>           f.close()

> Arguably, there's less to screw up here; you don't check return codes at
> all.  But under the hood, the system does it anyway, and automatically
> throws exceptions on errors.

There's a problem with this argument.  How much information are you losing
by relying on the exception?  I would, when coding the above in Perl (and
likely in Python as well) specifically say *what* I was doing that failed
in each case, not just say something generic like "open failed".  I want
the file name, the operating system error code, and (this is the hard
part) the conceptual piece of work the program was attempting to do at the
same time.

If I can't get all that automagically from exceptions, I have to throw my
own exceptions that include the information that I want.  Which takes us
back to what Perl does.

Keep in mind that Perl was designed around the notion that you may not
care if the operation fails.  I find that that's usually the wrong
assumption for most of my code, but I'm not quite willing to assume that
for all applications.  I know there are plenty of cases where it's true,
and I take advantage of the fact that Perl can silently discard errors in
those cases.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 31 Oct 1998 01:17:32 GMT
From: thad@thadlabs.com (Thad Floryan)
Subject: Re: Perl 5.004 install problem on Solaris 2.6
Message-Id: <363a652c$0$29743@nntp1.ba.best.com>

cracraft@rice-chex.ai.mit.edu (Stuart Cracraft) wrote:
| 
| Doing a standard Perl 5.004 compile on a Solaris 2.6 Sparc-5,
| I got this when doing the make (after the Configure and
| make depend):
| [...]
| /usr/local/gnu/sun4m-SunOS-55-1/lib/gcc-lib/sparc-sun-solaris2.5/2.7.2/ ...
| [...]
| *** Error code 1
| make: Fatal error: Command failed for target `miniperlmain.o'
| 
| Any ideas about this?
| 
| I'm Perlless.

Best advice would be to get the latest Perl and gcc versions.

The gcc-2.7.2 is circa January 1996; the latest version is 2.8.1 which works
very well on Solaris 2.6

Perl is up to version 5.005_<something or other>

gcc 2.8.1 compiles perl 5.005* without any problems on Solaris 2.6

Thad


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

Date: Sat, 31 Oct 1998 00:34:07 GMT
From: Alan Melton <arm@home.net>
Subject: perl and oracle
Message-Id: <363A5946.14FD61F8@home.net>

Is there any active link yet between perl 5 and 
oracle or is oraperl only applicable for perl 4.

Alan Melton


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

Date: 30 Oct 1998 21:27:16 -0500
From: dblack@pilot.njin.net (David Alan Black)
Subject: perl art/puzzle
Message-Id: <71dsi4$be5$1@pilot.njin.net>

Hello -

Here follows a working program which also has a nice little
piece of perl art.

Puzzlewisely, the goal would be to write a useful program which
completed the fourth side of the rectangle - though I do rather like
the quasi-Escheresque effect.


#!/usr/local/bin/perl -w

print <<EOM;

Hello.  Enter a comma-separated list of numbers
and I will condense them into ranges.

Example:
   you type this:     1,3,4,5,10,12,13,20
   I output this:     1,3-5,10,12-13,20

EOM

print "Numbers please: ";
                                    ############
                                    #          #
                                    #          #
                                    #          #
                     print(join'',do{@n=<STDIN>#=~/([^,]+)/gx
                 =~/([^,]+)/gx;map{my$r="";$_<$#n&&$n[$_]+1==$
              n[$_+1]&&($n=$n||$n[$_])||($r.=$n#?"$n-$n[$_]"
                    ?"$n-$n[$_]":$n[$_])&&($_<$#n)&&($r.=',')
                           &&(undef$n);$r}(0..$#n)})
                                    #          #
                                    #          #
                                    #          #
                                    ############



__END__


David Black
dblack@pilot.njin.net




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

Date: 30 Oct 1998 21:31:03 -0500
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: perl art/puzzle
Message-Id: <71dsp7$bf6$1@pilot.njin.net>

dblack@pilot.njin.net (David Alan Black) writes:

P.S. Yes, it is sort of cheating that only 3/5 of the right-hand
ones are "real".  Artistic license :-)  And of course the perfect
solution to the puzzle would have to be "real" all the way
around.


>                                    ############
>                                    #          #
>                                    #          #
>                                    #          #
>                     print(join'',do{@n=<STDIN>#=~/([^,]+)/gx
>                 =~/([^,]+)/gx;map{my$r="";$_<$#n&&$n[$_]+1==$
>              n[$_+1]&&($n=$n||$n[$_])||($r.=$n#?"$n-$n[$_]"
>                    ?"$n-$n[$_]":$n[$_])&&($_<$#n)&&($r.=',')
>                           &&(undef$n);$r}(0..$#n)})
>                                    #          #
>                                    #          #
>                                    #          #
>                                    ############




David Black
dblack@pilot.njin.net




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

Date: 30 Oct 1998 23:54:44 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: perl news per Email?
Message-Id: <71djk4$k76$1@news.NERO.NET>

In article <363A0C2E.6EA33AB4@compuserve.com>,
Dmitri Levitin  <dmitri@compuserve.com> wrote:
>I don4t have a possibility to read perl news directly, so I would like
>to become comp.lang.perl.misc,
>comp.lang.perl.tk and perl.lang.perl.module per Email. How can I do it?

perl-users-request@ruby.oce.orst.edu




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

Date: 30 Oct 1998 15:52:15 -0500
From: Maciej Stachowiak <mstachow@mit.edu>
Subject: Re: psychology of language choice (was Re: language war ...)
Message-Id: <v8whfwlu60w.fsf@huis-clos.mit.edu>



> python types always talk about rigid structure, fixed indenting,
> consistant forms. this is a very academic view going back to the purest
> (in the minimalist way) language, lisp.

You must be on crack if you think _any_ dialect of lisp has "rigid
structure". Actually, the extremely simple syntax of lisp-like
languages offers some of the same kinds of benefits as perl's highly
complex and context-sensitive syntax, namely supporting many
programming idioms well. Perl does this by just having enough syntax
to support a bunch of them, Lisp does it by having using the simple
syntax to enable sufficient metalinguistic abstraction facilities to
express new idioms.

 - Maciej

-- 
guile -c '(define c call-with-current-continuation)(define(f s)(lambda(o)(let
((n(c(lambda(x)(o x)x))))(let p((n n)(l(string->list s)))(cond((not (null? l)
)(display(car l))(p(c n)(cdr l))))))))((f"Js nte ul akr")(f"utAohrGieHce\n"))'


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

Date: Fri, 30 Oct 1998 18:41:05 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Regex Explaination...
Message-Id: <comdog-ya02408000R3010981841050001@news.panix.com>

In article <363a1ca3.1393873764@nntp.cts.com>, gosdpads@yahoo.com (Danny Groppo) posted:

> I was hoping you can try to explain this for me.  When I run:
> 
> $string = "12385";
> @zips = $string =~ m/(?:\d)(\d)/; 
> print "Value of \$1: $1\n";
> for (@zips) { print "$_\n"; }
> 
> I get:
> 
> Value of $1:
> 1   

are you sure that's what you get with that peice of code?  which
version of perl is this?

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Sat, 31 Oct 1998 00:57:52 GMT
From: Jim Haney <jh943@bellsouth.net>
Subject: SSI Random Image (Newbie??)
Message-Id: <363A6060.3136@bellsouth.net>

Greetings All,

I am a CGI Newbie, so be gentle with me...

I have a problem and I hope I can express my problem correctly.


I have placed a SSI Random Image script on my server.  It seems to be
working fine because I can type in the url to the ssi_rand_image.pl  and
the images will cycle correctly when I hit reload, so I assume
everything in the cgi-bin is correct.

here is my problem, how do I tag the html to access the cgi-bin (random
image) file?

I have tried to read everything I can but it all seems to be written for
someone who understands CGI better than myself.

I have attempted this:

<img src="http://www.(my dns
here).com/cgi-bin/rotate/ssi_rand_image.pl">

but all I get is the broken icon, I can click "view image" and then it
will show me the image.

I thank you for your time and consideration to my problem.


Jim Haney


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

Date: Fri, 30 Oct 1998 23:43:12 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Subroutine question
Message-Id: <F1nz80.24v@news.boeing.com>

In article <36371BBF.76001D4F@hal.ddntl.didata.co.za>,
Mark Fergusson  <mferg@hal.ddntl.didata.co.za> wrote:
>Hello,
>
>I have some code which needs to be external to a main program. Only on
>rare occasions will this code need to be run as if it was part of the
>main program. What is the best way to do this, so that I avoid it being
>loaded, every time the program is run ?
>
>If the routine is used, only then must it fetch the code, and run it, as
>if it was tagged on to the program in the first place, with access to
>all the programs variables.
>
>Please can someone point me in the right direction.
>

perldoc -f require , e.g.

if ($condition) {
    require "/path/program_with_code"; 
    ....
}



hth,
--
Charles DeRykus


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

Date: Sat, 31 Oct 1998 00:47:15 GMT
From: dkirby@see.sig.for.addr (Dave Kirby)
Subject: Re: Syntactic flexibility (was: Re: psychology of language choice (was Re: language war ...))
Message-Id: <363a5297.2381251@read.news.global.net.uk>

On Fri, 30 Oct 1998 06:14:30 GMT, Daniel Grisinger
<dgris@rand.dimensional.com> wrote:

>Lyn A Headley <laheadle@boguscs.uchicago.edu> writes:
>
><snip perl debugger only works on single lines>
>
>> maybe I'm missing something, but...
>> 
>>   DB<1> sub hello {
>> Missing right bracket at (eval 6) line 4, at end of line
>> syntax error at (eval 6) line 4, at EOF
>
>$perl -de8
>
>Loading DB routines from perl5db.pl version 1.0401
>Emacs support available.
>
>Enter h or `h h' for help.
>
>main::(-e:1):	8
>  DB<1> sub hello {                            \
>  cont:     print qq.Hello, world\n.;          \
>  cont: }
>
>  DB<2> hello
>Hello, world

I just tried the following on my Win95 system (perl 5.004_2):

  DB<1> sub hello{ \
  cont: print "hello world\n"; \
  cont: }
Got signal SEGV

C:\>

The same thing happened when I used qq. instead of ". What gives?

Also it wont let you go back and edit what you are inputing, which is
especially annoying when you forget one of those backslashes at the
end of the line.  

The python interactive mode will detect the start of a function,
class, conditional block etc and handle the continuation lines for you
- no need for the backslashes.  It also acts as a calculator and will
automatically print the value of the expression you type in, unless it
returns None (the python equivalent of a null value).

	Dave K
--------------------------------------------------
All great ideas start as heresy and end as dogma.

dkirby@   <-figure this out, spambots!
bigfoot.   My opinions are my own,
com        but I'm willing to share.


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

Date: 30 Oct 1998 16:22:28 -0500
From: Maciej Stachowiak <mstachow@mit.edu>
Subject: Re: Syntactic flexibility (was: Re: psychology of language choice (was Re: language war ...))
Message-Id: <v8wg1c5u4mj.fsf@huis-clos.mit.edu>


dkirby@see.sig.for.addr (Dave Kirby) wrote:
> I dont know Scheme or Guile, but you can certainly add new language
> constructs to TCL or FORTH. In his book Ousterhout gives an example of
> adding a completely new looping construct to TCL, and most of FORTH is
> written in FORTH. However my recollection of those languages is that
> this ability is easily abused and can lead to unreadable &
> unmaintainable code, though there are times when it can be useful.

You certainly can add new syntactic constructs in Scheme or other
dialects of Lisp. Scheme just has a different surface syntax than Tcl
or Forth. Tcl's surface syntax constists of whitespace-separated words
terminated by an unescaped newline or a semicolon; Scheme's consists
of s-expressions, which are lists of words prefixed by an open paren
and terminated by a close paren (to a first-order
approximation). Neither of these surface syntax aspects can be
changed, but within those limitations you can add arbitrary syntactic
constructs. 

Here is a trivial example of adding a new conditional syntax. Suppose
instead of writing the normal Scheme

  (if TEST CONSEQUENT ALTERNATIVE) 

where the single statement CONSEQUENT gets executed if TEST is true,
otherwise the statement ALTERNATIVE

I wanted to write 

  (unless TEST STATEMENT1 STATEMENT2 ...)

which would perform all the STATEMENTn's only when TEST is false. I'd
just write a macro like this:

(define-syntax unless
  (syntax-rules ()
		((unless TEST STATEMENT1 STATEMENT2 ...)
		 (if (not TEST)
		     (begin 
		       STATEMENT1
		       STATEMENT2
		       ...)))))

This is a trivial example of defining a new keyword though, you can
define keywords that do very complicated things, like protect a code
block with a mutex, define a completely different sublanguage where
normal Scheme constructs have no relevance, and so on.

Scheme (and other Lisps), Tcl and Forth are all nice in that they
allow you to define your own syntax this way.

 - Maciej Stachowiak
> I dont know Scheme or Guile, but you can certainly add new language
> constructs to TCL or FORTH. In his book Ousterhout gives an example of
> adding a completely new looping construct to TCL, and most of FORTH is
> written in FORTH. However my recollection of those languages is that
> this ability is easily abused and can lead to unreadable &
> unmaintainable code, though there are times when it can be useful.

You certainly can add new syntactic constructs in Scheme or other
dialects of Lisp. Scheme just has a different surface syntax than Tcl
or Forth. Tcl's surface syntax constists of whitespace-separated words
terminated by an unescaped newline or a semicolon; Scheme's consists
of s-expressions, which are lists of words prefixed by an open paren
and terminated by a close paren (to a first-order
approximation). Neither of these surface syntax aspects can be
changed, but within those limitations you can add arbitrary syntactic
constructs. Suppose instead of writing the normal Scheme 

  (if TEST CONSEQUENT ALTERNATIVE) 

where the single statement CONSEQUENT gets executed if TEST is true,
otherwise the statement ALTERNATIVE

I wanted to write 

  (unless TEST STATEMENT1 STATEMENT2 ...)

which would perform all the STATEMENTn's only when TEST is false. I'd
just write a macro like this:

(define-syntax unless
  (syntax-rules ()
		((unless TEST STATEMENT1 STATEMENT2 ...)
		 (if (not TEST)
		     (begin 
		       STATEMENT1
		       STATEMENT2
		       ...)))))

This is a trivial example of defining a new keyword though, you can
define keywords that do very complicated things, like protect a code
block with a mutex, define a completely different sublanguage where
normal Scheme constructs have no relevance, and so on.

Scheme (and other Lisps), Tcl and Forth are all nice in that they
allow you to define your own syntax this way.

 - Maciej Stachowiak

- 

guile -c '(define c call-with-current-continuation)(define(f s)(lambda(o)(let
((n(c(lambda(x)(o x)x))))(let p((n n)(l(string->list s)))(cond((not (null? l)
)(display(car l))(p(c n)(cdr l))))))))((f"Js nte ul akr")(f"utAohrGieHce\n"))'


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

Date: Sat, 31 Oct 1998 00:23:14 +0100
From: "Hakan Kilic" <a9609339@unet.univie.ac.at>
Subject: Testing Perlscript at home
Message-Id: <71dhpp$9200$1@www.univie.ac.at>

Hello!

Can I test my self written Perl at home, without sending it to the server.

I tried "perl -c .." but it didn't tell the truth.

And I had trouble with the debugger, because I wanted to evaluate a form of
mine.

Is there a way to test html-forms in connection with my perl cgi at home,
without sending it to the server?

Thanks

Hakan




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

Date: Sat, 31 Oct 1998 01:57:26 GMT
From: junsc@sysic.hei.co.kr
Subject: the way to change directory in Perl script
Message-Id: <71dqq6$f8m$1@nnrp1.dejanews.com>

Hi, All

I want to notify a directory change to a script that manipulate some files in
the directory prior to initiate any operation in order to use the script
anywhere without worry about the path-related problems. At the first sight, I
think the following statement would do the job, but the script simply exit
quietly without any operation.
$ENV{'PWD'} = someWorkDir;

How can I notify correctly the work directory to the script?
One more thing, is there any PERL compilation option similar to "csh
-fxv".[Verbose step by step execution]

Any information would be greatly appreciated.

Thanks in advance.

Sungchun

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Sat, 31 Oct 1998 00:32:57 GMT
From: Alan Melton <arm@home.net>
Subject: Unix to NT compatibility
Message-Id: <363A58FE.D792DA91@home.net>

I have multiple perl programs that execute well
on all unix servers but are not functioning on a Windows NT
server that currently  has perl\5.00502 installed.

Also one statement to open a datafile under Unix
dbmopen(%DB, "sku", 0644);  is it applicable under NT?

Are there any changes to be made to the perl programs to allow
them to function with NT.

Alan Melton


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

Date: Fri, 30 Oct 1998 17:00:37 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Using system( ) command to copy files
Message-Id: <363A4515.A01D8C0F@us.ibm.com>

Liew Fook Sin wrote:
> 
> Hai,
> The task I wish to perform is to get Perl to copy files from one
> location/directories to another.
> I have tried using the command system( ) . The command I issued was
> 
> #! /usr/bin/perl

Always, always, always use -w.

> $path = "/home/lfs/public_html"
                                 ^
No semicolon?  One thing that you can do to catch errors like this is to
run perl with the -c switch.  It will check the syntax of your script
for you.
%perl -c -w foo.pl

> $filename = "somefilename";
> system( cp $path/$filename  /home/httpd/doc/$distinationfilename);

Better check the documentation for system again.  The system function
expects a list to be passed to it.  Also, where have you defined
$distinationfilename?  Using -w will warn you about this.

> exit;
> 
> Somehow it just didn't work. It seems to have a multiple of errors > > reproted

You're pretty close to getting this right.  I think that with a little
more reading of the docs, you'll have this down with no problem.  Also,
the FAQ that came with your distribution of Perl will be of use to you. 
You can also access the FAQ at www.perl.com.  

Good luck.

-- 
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)


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

Date: 30 Oct 1998 17:07:43 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Very Large DBM file: Finding Number of keys
Message-Id: <ylaf2d35eo.fsf@windlord.stanford.edu>

Mark-Jason Dominus <mjd@op.net> writes:

> In tied hashes, someone has to count them all over again.  You could
> follow Russ' suggestion:

> 	while ($key = each %hash) {
> 	  if (! $seen{$key}++) {
> 	    $total++;
> 	  }
> 	}

Um, that wasn't my solution....

> or some such, but I bet a nickel that that takes a lot longer than
> letting Perl count them using `keys':

> 	while ($key = each %hash) {
> 	  $seen{$key}++;
> 	}
> 	$total = keys %hash;

That depends on what you want to be fast.  "Takes a lot longer" isn't that
meaningful in this case, since the time penalty is being incurred in two
different places.

My solution is to store a total *in the hash*, using a distinguished key,
and update it each time you add something to the hash.  In other words,
you slow down (slightly) each entry into the hash, but retrieval of the
total number of keys in the hash then becomes an O(1) operation.  My
understanding of keys on tied hashes, even in a scalar context, is that
it's still an O(n) operation (as opposed to using keys on Perl native
hashes, which is probably O(1)).

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 4115
**************************************

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