[12755] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 165 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 16 11:07:22 1999

Date: Fri, 16 Jul 1999 08:05:10 -0700 (PDT)
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, 16 Jul 1999     Volume: 9 Number: 165

Today's topics:
    Re: About "reverse" command <nick.sanders@lineone.net>
    Re: die ? (John Borwick)
    Re: die ? (Brian Pontz)
    Re: Every morning at 6.00 am on a NT-box... <nick.sanders@lineone.net>
    Re: Future of Perl (Walter Tice USG)
    Re: Future of Perl (I R A Aggie)
    Re: Future of Perl (I R A Aggie)
    Re: Help!: trying to compile my scripts ftidev@fhb.clickcharge.com
        how to extract gzipped file into a list <mika.stahlberg@dlc.fi>
    Re: how to extract gzipped file into a list <swiftkid@bigfoot.com>
        I hate to do this <ion@preferred.com>
    Re: Installing Modules Locally Help!!! (I R A Aggie)
    Re: Linux - Apache - Perl (I R A Aggie)
    Re: long explanations wearying (was Re: Top 10 response <revjack@radix.net>
    Re: loop problems ?? (Tad McClellan)
    Re: Newbie requires help in Perl please <hove@ido.phys.ntnu.no>
    Re: Newbie requires help in Perl please <chris@inta.net.uk>
    Re: Perl and MS Access DBs <kbandes@home.com>
    Re: Perl before Swine? (Walter Tice USG)
    Re: perl's edge -- a beginner's question <revjack@radix.net>
    Re: Remove leading zeros from a string (Andreas Fehr)
    Re: Remove leading zeros from a string (elephant)
    Re: Remove leading zeros from a string <tchrist@mox.perl.com>
    Re: Remove leading zeros from a string <swiftkid@bigfoot.com>
    Re: Remove leading zeros from a string (Andreas Fehr)
    Re: Resolution (elephant)
        search script <fast_styx@hotmail.com>
    Re: search script <tracker@home.com>
    Re: set up hash using variables not yet defined (Christian M. Aranda)
    Re: Simple Question: How do I call a subroutine in a di (Bart Lateur)
    Re: Simple Question: How do I call a subroutine in a di <tchrist@mox.perl.com>
    Re: Statistics for comp.lang.perl.misc (Walter Tice USG)
    Re: Tiny error in perlfaq5 (M.J.T. Guy)
    Re: Tiny error in perlfaq5 (M.J.T. Guy)
    Re: Tiny error in perlfaq5 (John Stanley)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Fri, 16 Jul 1999 15:01:25 +0100
From: Nick Sanders <nick.sanders@lineone.net>
Subject: Re: About "reverse" command
Message-Id: <378F3B34.7A8DE44C@lineone.net>

It should be
@arr = reverse(@arr);

Nick

scientiaXXX wrote:

> Hello
>
> I solved my problem in another way, without using reverse(@array),
> however I do not understand why it does not work.
>
> So what I am writing now is not important.
>
> If someone wants to try:
>
> #!/usr/bin/perl
> print "Content-type:text/html\n\n";
> $a="one.two.three.four.five.six";
> @arr=split(/\./,$a);
> reverse(@arr);
> print "$arr[0]<br>\n";
> print "$arr[1]<br>\n";
> print "$arr[2]<br>\n";
>
> It should write
> six
> five
> four
> but it writes
> one
> two
> three
> If I delete the line with reverse(@arr), the result is the same.
>
> Fabrizio



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

Date: Fri, 16 Jul 1999 12:50:38 GMT
From: John.Borwick@sas.com (John Borwick)
Subject: Re: die ?
Message-Id: <379b2a16.88799607@newshost.unx.sas.com>

On Fri, 16 Jul 1999 11:41:15 +0100, Ian Mortimer
<ianmorty@nortelnetworks.com> wrote:

>I open the file using -

>open (CHANGED ,">$copy_file") || die "Couldn't open $copy_file \n";

>What happens when there is a problem with that file ? - all I get is the
>html stopping at the point of the open() line.  Does the die() command
>only output the error message when perl is executed from the command
>line ?

You could
use CGI::Carp qw(fatalsToBrowser);
to print Carp messages to STDOUT in HTML format.

The die message is probably going to your web server error log right
now.

-- 
John Borwick


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

Date: Fri, 16 Jul 1999 14:36:25 GMT
From: pontz@channel1.com (Brian Pontz)
Subject: Re: die ?
Message-Id: <378f4257.74111581@news2.channel1.com>

On Fri, 16 Jul 1999 11:41:15 +0100, Ian Mortimer
<ianmorty@nortelnetworks.com> wrote:
I'm still new but if I'm writing a cgi script and I want the error
messages to get spit out to the browser I use something like this.

open(LOG, ">>$log") || &Error("Couldnt open $log: $!");

The &Error sub looks like this.

sub Error { 
 my ($mesg)=@_;
print "Content-type: text/html\n\n";
print <<"end_print";
 <HTML><HEAD><TITLE> Error </TITLE></HEAD>
<BODY BGCOLOR="#000000">
Error:$mesg
</BODY>
</HTML>
end_print
exit 0;
}

Brian Pontz


>I open the file using -
>
>open (CHANGED ,">$copy_file") || die "Couldn't open $copy_file \n";
>



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

Date: Fri, 16 Jul 1999 14:59:07 +0100
From: Nick Sanders <nick.sanders@lineone.net>
Subject: Re: Every morning at 6.00 am on a NT-box...
Message-Id: <378F3AAB.83E3F099@lineone.net>

Use AT commands - type AT into help and it will tell you what to do

Nick

Abigail wrote:

> Henri Schomäcker (hschomae@rz-online.de) wrote on MMCXLIII September
> MCMXCIII in <URL:news:378c847d.9394296@news.rhein-zeitung.de>:
> ==
> == [ How to do cron on a silly OS ]
> ==
> == - Is there a possibility to let the perl-script do the control of time
> ==   and starting the actions every morning without any NT-Services?
> ==   Eg by a Win32::? Module?
>
> Unlikely, unless you want it to run all the time.
>
> Abigail
> --
> perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
>
>   -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
>    http://www.newsfeeds.com       The Largest Usenet Servers in the World!
> ------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----



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

Date: 16 Jul 1999 12:18:18 GMT
From: tice@hunch.zk3.dec.com (Walter Tice USG)
Subject: Re: Future of Perl
Message-Id: <7mn7ua$va7@zk2nws.zko.dec.com>

In article <slrn7otcu4.c9j.abigail@alexandra.delanet.com> abigail@delanet.com writes:
>Jeffrey (Jeffrey@ix.netcom.com) wrote on MMCXLIV September MCMXCIII in
><URL:news:3795bd45.37232960@news.giganews.com>:

>^^ How long is Perl going to be around?

>Till May 19, 2001. That's when the license that NASA granted Larry expires.
>*All* perl binaries have a self destruct function that test the date, and
>erase Perl and any Perl programs from your hard disk if you start Perl after
>May 19, 2001.

Oh crap! better switch to Python quick! LOL

>^^ I want to know if I'm wasting my time learning it.

>Yes. Don't bother learning it. Even if Perl would be around after May 19,
>2001, learning a new langauge is often a waste of time. After all, the 
>language might suddenly no longer be around, and all your programs stop
>working. That's why there's no Cobol code around anymore; all Cobol code
>was replaced by C in the early '70s.

Yeah, and Fortran 66 + 77 are long gone as well..

>^^ Some say Java will replace Perl.

>Oh yes. Java will rapidly replace Perl. After all, Java is crossplatform,
>backwards compatible between versions, open source, and mainly, it isn't
>hyped, were Perl is. Java is the true glue language of the future, with
>it's abilities to interact with the environment - something that's missing
>in Perl. And Java's buildin hashes and its regex capabilities outshine Perl.

LOL - Honestly, Java may be more overhyped then anything M$ has ever
come up with (or appropriated), which is actually a chilling thought.

>^^ I just
>^^ don't want to spend time learning something that's going to be of no
>^^ marketable value in the near future.

>Don't judge programming languages on their usefullness, judge them on
>their marketable value! That'll increase the quality of code and will
>bring us closer to world peace.

What refreshing candor... or was it blatant greed - I forget already.


>Abigail
 
>perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
>.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
>.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
>%$^U;$^V/=$^U}while$^V!=$^W'

W


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

Date: 16 Jul 1999 13:40:06 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Future of Perl
Message-Id: <slrn7oudlu.fai.fl_aggie@thepentagon.com>

On 15 Jul 1999 23:24:02 -0500, Abigail <abigail@delanet.com>, in
<slrn7otcu4.c9j.abigail@alexandra.delanet.com> wrote:

+ Till May 19, 2001. That's when the license that NASA granted Larry expires.
+ *All* perl binaries have a self destruct function that test the date, and
+ erase Perl and any Perl programs from your hard disk if you start Perl after
+ May 19, 2001.

You know, there ought to be a law requiring subject warnings. If I had been
drinking [coke|tea|coffee], you'd owe me a new [computer|monitor|keyboard]
depending on where I spewed...

James


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

Date: 16 Jul 1999 13:41:14 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Future of Perl
Message-Id: <slrn7oudo3.fai.fl_aggie@thepentagon.com>

On 16 Jul 1999 12:18:18 GMT, Walter Tice USG <tice@hunch.zk3.dec.com>, in
<7mn7ua$va7@zk2nws.zko.dec.com> wrote:

+ Yeah, and Fortran 66 + 77 are long gone as well..

Not true! I can write fortran in perl!

James - fortran programmers can write fortran in *any* language...


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

Date: Fri, 16 Jul 1999 14:36:51 GMT
From: ftidev@fhb.clickcharge.com
Subject: Re: Help!: trying to compile my scripts
Message-Id: <7mng22$h02$1@nnrp1.deja.com>

First of all, this not merely a matter of reading the FAQ or following
instructions in building perl.

There are problems in the makefile you have overcome in order
to build a byteperl, but even if you succeed the result may not
be of any use to you.

The implementation of the B module is incomplete.
Applications using XS modules (like CGI, DBI, etc.) will not run as
compiled byteperl.

See Tom Christiansen's thread "install bug: byteperl" from 4/16/99
in perl-porters.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Fri, 16 Jul 1999 16:18:00 +0300
From: "MS" <mika.stahlberg@dlc.fi>
Subject: how to extract gzipped file into a list
Message-Id: <7mnbdb$53d@idefix.eunet.fi>

The subject says it about all. File is gzipped text file. Didn't find any
examples about this and being newbie in perl...

Thanks in advance!

Mika




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

Date: Fri, 16 Jul 1999 18:50:58 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: how to extract gzipped file into a list
Message-Id: <7mogm0$46e5@news.cyber.net.pk>

MS <mika.stahlberg@dlc.fi> wrote in message
news:7mnbdb$53d@idefix.eunet.fi...
: The subject says it about all. File is gzipped text file. Didn't find any
: examples about this and being newbie in perl...

you mean:

$content = `gunzip -c blah.gz`;

# extracted contents in $content, blah.gz remains unchanged...





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

Date: Fri, 16 Jul 1999 10:04:43 -0400
From: "Ion Pro" <ion@preferred.com>
Subject: I hate to do this
Message-Id: <378f3c00@news5.newsfeeds.com>

I'm a "newbie" to Perl, and I'm trying to write a script to randomly change
wallpaper (on a *nix system). I got it randomly changing-- but it cannot
repeat any image until all are used. Now, it does repeat any image-- it just
stops working when all of them are used, and I cannot figure out why. There
is no error output-- it just sits there spinning away until I manually end
task. Also, did I mention I was coding this in Windoze? a little hard to
test....
Anyway, most of this is Perl4-- I've read the infamous Llama book, but
nothing else, really.

Any help would be appricated :)



#!/usr/bin/perl -w

#Script to randomly change wallpaper.  Very nice indeed.
#xv syntax: xv -root -quit -maxpect filename

#open directory, get listing of files
opendir CWD, "." || die "Can't open current directory $!";
@files = readdir CWD;
close CWD;


#start logfile section
&init; #initalize logfile vars and filehandles

if ($numFiles==$count) {
 unlink "logfile";
 &init;
 my %h = map { $_ => 1 } @log;
 @unused =  grep { !$h{$_} } @files;
 $numFiles=(scalar @unused);
}
&pick_wallpaper;
print LOGFILE "$wallpaper\n"; #send wallpaper name to logfile

close LOGFILE;
close READLOG;

#end logfile section

#actually do what this whole program was trying to accomplish
system("/usr/X11R6/bin/xv -root -quit -maxpect $wallpaper");

#for debugging purposes only
#open(DEBUG,">>debugit");
#print DEBUG "$wallpaper\n";

#start subroutine defs
sub pick_wallpaper {


 $fnumber=0;
 $wallpaper="";
 srand(time()^($$+($$<<15))); #initalize random number generator

 while ( ($fnumber<2) or ($fnumber >= $numFiles) or $wallpaper=~/change/ or
$files[$fnumber]=~m[\.(pl|log|sh)$]) {
 #We can't use the first or second directory entry, as they're ./ and ../
  $fnumber=(int(rand $numFiles));
  $wallpaper=$unused[$fnumber];
 }
}

sub init {
 $logentries=0; #initalize vars used later on
 open LOGFILE,">>logfile" || die "Can't open a file for writing $!"; #open a
file for writing
 open READLOG,"logfile" || die "Can't open logfile for reading $!"; #open a
file for reading
 chomp(@log=<READLOG>); #read the logfile into an array

 #this'll determine how long the array is (how many entries...)
 $logentries=(scalar @log);
 #make @unused = @files-@log
 my %h = map { $_ => 1 } @log;
 $count = 0;
 @unused =  grep { !$h{$_} } @files;
 $numFiles=(scalar @unused);
 foreach (@files) {
  $count++ if (m[\.(pl|log|sh)$]);
 }
}
-------------------------
LeeR
ion@preferred.xxx.nospam.com




  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 16 Jul 1999 13:45:00 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Installing Modules Locally Help!!!
Message-Id: <slrn7oudv5.fai.fl_aggie@thepentagon.com>

On Thu, 15 Jul 1999 22:40:51 GMT, Jonathan Chum <jchum@jps.net>, in
<378e632a.9265932@news.jps.net> wrote:

+ I have telnet access, but the ISP don't let users have access to the
+ root to install new modules. How can I install modules locally? How
+ can I setup my CGI scripts to access them?

Take a look at perlfaq8:

How do I install a CPAN module?
How do I keep my own module/library directory?
How do I add the directory my program lives in to the module/library search 
    path?

James


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

Date: 16 Jul 1999 13:54:17 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Linux - Apache - Perl
Message-Id: <slrn7ouegh.fai.fl_aggie@thepentagon.com>

On Fri, 16 Jul 1999 11:40:44 GMT, JT <jett1not@homedot.com>, in
<37921821.72972188@24.2.0.71> wrote:

+ I agree with you, but if it's a question that can be easily answered
+ in a one-liner, what's the huge deal?

Because then he'll be back for another question. Perhaps that one will
take a paragraph. Then he'll be back for another, and maybe that one
will require a short essay. Then he'll be back, and this time it will
require a small book.

Where do *you* draw the line?

Pointing them to the appropriate newsgroup sans answer is useful for
other reasons: there will be a better probability of finding someone
there who *can* answer *correctly*.

+ If anyone's gonna bother
+ replying, why not throw in the answer along with "Read the FAQ, or
+ RTFM". That way the poster would learn 2 things.

Because it would also reward the poster for inappropiate laziness, and
unchecked, might lead to inappropriate hubris.

James


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

Date: 16 Jul 1999 14:23:12 GMT
From: revjack <revjack@radix.net>
Subject: Re: long explanations wearying (was Re: Top 10 responses)
Message-Id: <7mnf8g$orr$2@news1.Radix.Net>
Keywords: Hexapodia as the key insight

Abigail explains it all:

:Remember comp.unix.wizards. People asking stupid FAQs, or off-topic
:questions will not ask them in perl.newbie, but in perl.professional.
:Not only do they think they have a unique question that can only
:be answered by professionals, they themselves are "professional web
:designers" - a rare and elite breed of critters for which only the best
:of the best is good enough.

But that's the genius of this cunning plan - all the professionals can
hide in .newbie, and the newbies will never find them. I wish I'd thought
of it.


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

Date: Fri, 16 Jul 1999 03:48:24 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: loop problems ??
Message-Id: <84omm7.i2n.ln@magna.metronet.com>

stu7@usa.net wrote:

: but inside an if loop, 


   What is an "if loop"?


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 16 Jul 1999 16:09:11 +0200
From: Joakim Hove <hove@ido.phys.ntnu.no>
Subject: Re: Newbie requires help in Perl please
Message-Id: <k0nu2r4n0u0.fsf@ido.phys.ntnu.no>

arpith@hotmail.com writes:

> Okay, I want to run the Pl scripts through Dos/Windows, so I am using
> Perl Win32. So is there anyway of passing command line paramaters ? Like

Well, maybe I'm not quite understanding at the moment, but getting
commandline arguments into the program is simple. By starting the
program as:

perl file.pl arg1 arg2 arg3

The three arguments arg1, arg2 and arg3 will be in the array @ARGV.

#/usr/bin/perl -w

if (@ARGV) {
   print("You started me with the arguments @ARGV \n");
}
 
> perl file.pl?title=asdasdsd&url=http:L///asd/etc

This packing of command-line arguments is the CGI way, and is of no
use if you are building a stand-alone program.

> Also, what would be the best way to learn perl ? I don't have access to
> unix or any custom cgi web hosting service. Should I install some free
> Web server on my computer or install Unix ??

I strongly suggest bying a book. I would very much recommend "Learning
Perl" by Randal Schwartz from O'Reilly (www.ora.com), there is an
edition targeting Win32 programmers. When you know the very basics you
can learn a lot from the online documentation which came with your
perl distribution (perldoc).  
Installing a Unix version to learn perl is certainly not necessary,
however bying a Linux or FreeBSD CD is cheap, this can be installed in
addition to Win32, so you can the best of both worlds.


> Correct me if I am talking nonsense, 'cause I'm really new to this.. :)

Well if it's nonsense is up to others to decide, but you seem to be
very hooked on web properties, there is absolotely _no_ need for cgi
web hosting service to try out and learn the programming language
perl. Perl is general purpose programming language, like C, Pascal or
Java. It is by _no_ means intrinsically attatched to the web. However
lot's of people find perl very useful for web (i.e. CGI) purposes.

Good luck with Perl


Joakim
-- 
=== Joakim Hove    www.phys.ntnu.no/~hove/     ======================
# Institutt for fysikk  (735) 93637 / 352 GF  |  Skøyensgate 10D    #
# N - 7034 Trondheim    hove@phys.ntnu.no     |  N - 7030 Trondheim #
=====================================================================


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

Date: Fri, 16 Jul 1999 15:32:09 +0100
From: "Chris Denman" <chris@inta.net.uk>
Subject: Re: Newbie requires help in Perl please
Message-Id: <7mnfva$2nlp$1@news2.vas-net.net>

Try OMNIHTTPD by OMNICRON at http://www.omnicron.ab.ca/

Omnicron is a http server for windows95.  Once it is running the browser
sees your machine as just another web server.  It runs from your local IP
address (or 127.0.0.1), so your webpage address would be something like to
following: http://127.0.0.1/index.html

HTH

Chris

arpith@hotmail.com wrote in message <7mn9rj$eaf$1@nnrp1.deja.com>...
>
>
>> This can be accomplished by using CGI. (Common Gateway Interface - a
>> protocol for communicating between a browser and the server.) Perl is
>> much used for CGI purposes, try the module CGI.pm.
>>
>
>Opps.. Sorry, I didnt explain myself clearly...
>
>Okay, I want to run the Pl scripts through Dos/Windows, so I am using
>Perl Win32. So is there anyway of passing command line paramaters ? Like
>
>perl file.pl?title=asdasdsd&url=http:L///asd/etc
>
>Also, what would be the best way to learn perl ? I don't have access to
>unix or any custom cgi web hosting service. Should I install some free
>Web server on my computer or install Unix ??
>
>Correct me if I am talking nonsense, 'cause I'm really new to this.. :)
>
>Arpith.
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.




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

Date: Fri, 16 Jul 1999 10:04:33 -0400
From: Ken Bandes <kbandes@home.com>
Subject: Re: Perl and MS Access DBs
Message-Id: <378F3BF1.2ACCB6E8@home.com>

You can do MS-Access through ADO.  There's some stuff about this in the
Win32 Perl Resource Kit.  This is what you'd use in Active Server Pages
anyway.  And by the way, PerlScript works perfectly well with Active
Server Pages, no need to resort to VBScript just because you're working in
Windows.

There's no special module for ADO because it's a COM interface.  You just
need the Win32::OLE modules.  Again, the best discussion I know of is in
the Win32 PRK.

There's also a Win32::ODBC module, which is another way to get at Access
data.  Check out The Perl Journal, Issue #9 (Spring 1998) for an article
on this module.

Ken Bandes

Stephen Aze wrote:

> The message <7mlcg5$uu6$1@menelao.polito.it>
>   from  "Fredi Agolli" <f.agolli@studenti.to.it> contains these words:
>
> > I'm looking for Perl modules which manage MS Access Databases.
> > May you give me some information about this?
>
> If you're going to do it the Microsoft way, you may as well go all
> the way: Forget Perl and do it with Active Server Pages on an NT
> server - ASP's designed to work with Access databases.



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

Date: 16 Jul 1999 11:10:42 GMT
From: tice@hunch.zk3.dec.com (Walter Tice USG)
Subject: Re: Perl before Swine?
Message-Id: <7mn3vi$t0j@zk2nws.zko.dec.com>

In article <378E3BDE.1AA8CE34@lucent.com> Burton Kent <burton@lucent.com> writes:
>How do I make Perl grab/conserve all the memory it can?	
>My program needs a lot more memory for recursion...
>
>Burton

Perl is an unconstrained memory hog unless you set limits (i forget
the command), or your code isn't fast, or it doesn't do much,
there are several short scripts over at:

http://www.c-lab.de/~sb/Perl-Limericks.html#Pipes

which demonstrate how much and how quikly Perl can monopolize memory.

another aspect of your question can be answered by running the script
in Unix as root like so "nice -20 mykillerscript.pl"  this will give
your process(s) the highest priority over everything else, but be
careful, such a tool is easily blunted by misuse, or if you share a
system with other people, they may take up arms!

W


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

Date: 16 Jul 1999 14:09:32 GMT
From: revjack <revjack@radix.net>
Subject: Re: perl's edge -- a beginner's question
Message-Id: <7mnees$orr$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight

David Christensen explains it all:

:The example that I found memorable was a random text generator
:using Markov chains -- the C implementation was several pages, C++
:was shorter, Awk was one or two pages, and Perl was about 2/3 of a
:page.

Mine fits in my .sig.

-- 
perl -e 'while(<>){$f.= $_}@l=split(/\s+/, $f);for($i=0;$i<@l-1;$i++){$W{$l[$i]
}.=" ".$l[$i+1];}sub a{$w=$l[1]}&a;sub b{print "\n"}while($w){if(!($W{$w})){&b;
&b;&a;last if ($q++>3);}print"$w ";@p=split(/ /,$W{$w});$c=@p;until($s=int(rand
($c))){1}$w=$p[$s]}&b' big_text_file




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

Date: Fri, 16 Jul 1999 13:24:02 GMT
From: backwards.saerdna@srm.hc (Andreas Fehr)
Subject: Re: Remove leading zeros from a string
Message-Id: <378f312e.28786042@news.uniplus.ch>

On Fri, 16 Jul 1999 13:45:45 +0100, "Simon Kerr" <skerr@ryder.co.uk>
wrote:

>I have a string, such as '00001234'.  All I want to do is remove the leading
>zeros.  The length of the string can vary, so I can't just chop off the
>first n characters.
>
>Can anyone help, or point me in the right direction.  If it's in perldoc,
>then I can't find it!
>

My solution (there might be others):

$n = '000001234';
print $n + 0;


Andreas


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

Date: Fri, 16 Jul 1999 23:25:41 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: Remove leading zeros from a string
Message-Id: <MPG.11f9dddcf0a7b4b4989b3f@news-server>

Simon Kerr writes ..
>... All I want to do is remove the leading zeros. ...
>
>... If it's in perldoc, then I can't find it!

you're not looking closely enough

  perldoc perlre

-- 
 jason - remove all hyphens for email reply -


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

Date: 16 Jul 1999 07:40:36 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Remove leading zeros from a string
Message-Id: <378f3654@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    "Simon Kerr" <skerr@ryder.co.uk> writes:
:I have a string, such as '00001234'.  All I want to do is remove the leading
:zeros.  The length of the string can vary, so I can't just chop off the
:first n characters.
:
:Can anyone help, or point me in the right direction.  If it's in perldoc,
:then I can't find it!

You didn't look very hard.

Use a search and replace, of course.

--tom
-- 
    X-Windows: It could be worse, but it'll take time.
	--Jamie Zawinski


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

Date: Fri, 16 Jul 1999 18:51:31 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Remove leading zeros from a string
Message-Id: <7mogn3$69j1@news.cyber.net.pk>

: $n = '000001234';
: print $n + 0;

print int $n;
?




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

Date: Fri, 16 Jul 1999 14:31:16 GMT
From: backwards.saerdna@srm.hc (Andreas Fehr)
Subject: Re: Remove leading zeros from a string
Message-Id: <378f4215.1687085@news.uniplus.ch>

On Fri, 16 Jul 1999 18:51:31 +0500, "Faisal Nasim"
<swiftkid@bigfoot.com> wrote:

>: $n = '000001234';
>: print $n + 0;
>
>print int $n;
>?

I need only 2 chars, you need 3 ;)

Andreas


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

Date: Fri, 16 Jul 1999 23:32:42 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: Resolution
Message-Id: <MPG.11f9df85da3293c7989b40@news-server>

Scott Pritchett writes ..
>I need to get Perl to resolve this reference, my code which does not work is
>:-

try

  print eval('"' . $_ . '"');

which tells perl to evaluate the string "$::sp is good" and then print 
the resulting string

eval is a good mechanism - but do yourself a favour and read up on it 
because it can create huge security holes if used with unmoderated input

-- 
 jason - remove all hyphens for email reply -


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

Date: Fri, 16 Jul 1999 08:07:05 -0500
From: "Jody Thigpen" <fast_styx@hotmail.com>
Subject: search script
Message-Id: <932130256.997.95@news.remarQ.com>

I'm relatively new to Perl, but not actually a beginner, and I'm working on
what will be my first website search script.  Does anyone have or know where
I could find an example of just such a thing designed to search through a
site that I might use as a refernce?  I'd like to compare and see where I'm
making my mistakes.

Thanks,

Jody Thigpen
jthigpen@socket.net




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

Date: Fri, 16 Jul 1999 14:57:06 GMT
From: "Grant Peel" <tracker@home.com>
Subject: Re: search script
Message-Id: <6LHj3.22503$ml3.412087@news2.rdc1.on.home.com>

Do a search on a proggy called SWISH ( Simple Webpage Indexing System for
Humans). . It has one compiled module and some scripting. It might be a
start. There are also a few CGI developement companies out there that offer
freebies, you may ant to take a look at them.

-Grant

Grant W. Peel - tracker@home.com
The Net Now Internet Services - grant@thenetnow.com
Member:
HTML Writers Guild - http://www.hwg.org
International Webmasters Association - http://www.iwanet.org


Jody Thigpen <fast_styx@hotmail.com> wrote in message
news:932130256.997.95@news.remarQ.com...
> I'm relatively new to Perl, but not actually a beginner, and I'm working
on
> what will be my first website search script.  Does anyone have or know
where
> I could find an example of just such a thing designed to search through a
> site that I might use as a refernce?  I'd like to compare and see where
I'm
> making my mistakes.
>
> Thanks,
>
> Jody Thigpen
> jthigpen@socket.net
>
>




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

Date: Fri, 16 Jul 1999 14:32:52 GMT
From: christianarandaOUT@OUTyahoo.com (Christian M. Aranda)
Subject: Re: set up hash using variables not yet defined
Message-Id: <378f4237.585531@news.bmc.com>


[snip]
>
>Obvious suggestion, I know, but why don't you put this in a subroutine,
>and call it whenever the variables DO mean something ?

[snip]

>
>Have fun,
>
>Michel.


It was late and I guess I was over thinking the problem.  What is the
overhead in allocating a hash every time I need the values from it?
----------------------------------------
Christian M. Aranda
Performance Consultant
BMC Software - Waltham, MA


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

Date: Fri, 16 Jul 1999 13:32:01 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Simple Question: How do I call a subroutine in a different file?
Message-Id: <379033df.2312781@news.skynet.be>

Tom Christiansen wrote:

>:and it is as if the subs are simply pasted into your script.
>
>Well, modulo the unrelated lexical scope.

You mean the file-level my'ed variables? Yes, I had forgotten about
those. my'ed variables inside subs, or other (bare) blocks, behave just
the same.

	Bart.


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

Date: 16 Jul 1999 08:20:44 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Simple Question: How do I call a subroutine in a different file?
Message-Id: <378f3fbc@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    bart.lateur@skynet.be (Bart Lateur) writes:
:You mean the file-level my'ed variables? Yes, I had forgotten about
:those. my'ed variables inside subs, or other (bare) blocks, behave just
:the same.

That's not true.  If "tmp.pl" contains "print $var", then when fred()
is called:

    $var = "dynamic";
    sub fred {
	my $var = "lexical";
	eval `cat tmp.pl`;
    } 

will say "lexical", but

    $var = "dynamic";
    sub fred {
	my $var = "lexical";
	do "tmp.pl";
    } 

will say "dynamic".  That's because "do" confers an unrelated,
not a nested, lexical scope.

--tom
-- 
"Incrementing C by 1 is not enough to make a good object-oriented language."
(M. Sakkinen, in "On the Darker Side of C++", ECOOP'88)


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

Date: 16 Jul 1999 11:28:22 GMT
From: tice@hunch.zk3.dec.com (Walter Tice USG)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <7mn50m$uq6@zk2nws.zko.dec.com>

In article <37902c0a.182995353@news.supernews.com> grussell@hushmail.com (Gabriel Russell) writes:
>On Tue, 22 Jun 1999 02:20:31 -0500, rlb@intrinsix.ca (Lee) wrote:

>>In article <slrn7mu48j.k1b.abigail@alexandra.delanet.com>,
>>abigail@delanet.com (Abigail) wrote:

>>>Do you really think I make mistakes like that?

>>Come, now, Abigail. You *are* human.

>>Aren't you?

>>Lee

>Hmm, I can't see a single article by Abigail here on SuperNews.
>Does she get filtered off some servers?

What a horrible thought!  Not only are her posts full of interesting
technical truth, but the way in which it is frequently given is so
wonderfully arch!  Heck, the newbie skewers alone are priceless.
"newbie skewers" I like that...

"Inconceivable!" "I do not think that word means what you think it means."
- Princess Bride

W


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

Date: 16 Jul 1999 13:53:54 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Tiny error in perlfaq5
Message-Id: <7mndhi$go3$1@pegasus.csx.cam.ac.uk>

John Borwick <jobosw@unx.sas.com> wrote:
>
>Also, how often will rand(1000) actually return zero?  Is this a one
>in sizeof double case?  If I could hazard a guess, I'd say that an
>error occurs consistently over 2**16 (65536) iterations.

Assuming your rand() is exactly uniformly distributed (which most
implementations seem to be, despite their grottiness in other ways),
rand(x) will return zero once in every 2**RANDBITS calls on average,
irrespective of the value of x (err.. if x is nonzero and not otherwise silly).

Since many platforms have RANDBITS == 15, this will give an error
one time in 32768.


Mike Guy


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

Date: 16 Jul 1999 14:33:53 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Tiny error in perlfaq5
Message-Id: <7mnfsh$itt$1@pegasus.csx.cam.ac.uk>

John Stanley <stanley@skyking.OCE.ORST.EDU> wrote:
>
>Although pp.c will allow the use of a function other than the system
>rand() function, Configure does not consider this. It tells the user
>what it thinks the answer to "randbits" is based on using rand(). I'm
>sure there must be a way to procide the appropriate -D option to the
>build, but perhaps Configure should look for drand48 and use it if it
>is there by default.

This will happen by default in perl5.006:

        % perl5.005_03 -V:randbits
        randbits='15';
        % perl5.005_57 -V:randbits
        randbits='48';


Mike Guy


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

Date: 16 Jul 1999 14:40:38 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Tiny error in perlfaq5
Message-Id: <7mng96$3f6$1@news.NERO.NET>

In article <7mndhi$go3$1@pegasus.csx.cam.ac.uk>,
M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote:
>irrespective of the value of x (err.. if x is nonzero and not otherwise silly).

As of 5.005_something, rand(x) tests for x=0 and uses x=1;





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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

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 V9 Issue 165
*************************************


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