[12413] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6013 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 16 08:18:19 1999

Date: Wed, 16 Jun 99 05:00:30 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 16 Jun 1999     Volume: 8 Number: 6013

Today's topics:
    Re: $_ and $@ - What are they? (Abigail)
    Re: $_ and $@ - What are they? (Bart Lateur)
        'and' problem <steven@*REMOVE*filipowicz.com>
    Re: 'and' problem <spike1965@worldnet.att.net>
    Re: Accessing characters in a string? <gellyfish@gellyfish.com>
    Re: Afraid to ask about Y2K! <flavell@mail.cern.ch>
    Re: Afraid to ask about Y2K! (Abigail)
    Re: Can anyone explain this behavior? (Bart Lateur)
    Re: Can't load DBI modul under SCO UNIX <gellyfish@gellyfish.com>
    Re: Cant make PPM work. <gellyfish@gellyfish.com>
        cpan modules marshaling <Claude.Aubrie@inria.fr>
    Re: csv database w/ PERL <simon@profero.com>
    Re: date formats <gellyfish@gellyfish.com>
    Re: date formats (Abigail)
    Re: exclusive open (Stefano Ghirlanda)
    Re: exclusive open (Bart Lateur)
        expire a https session  <kevin@synergysa.com.au>
    Re: FEAR FAD <gellyfish@gellyfish.com>
    Re: File Processing (Bart Lateur)
    Re: Fix this uglyness <garethr@cre.canon.co.uk>
        How to distribute a script? <thomas@bibsyst.no>
    Re: How to distribute a script? (Andrew Johnson)
    Re: How to scan a directory and put all the files and t <gellyfish@gellyfish.com>
    Re: Is it better perl than awk ? (Bart Lateur)
        is there any function to spell out words? smnayeem@my-deja.com
    Re: is there any function to spell out words? (Marcel Grunauer)
        Location <bie@connect.ab.ca>
        Multi line match help <pai@cadence.com>
    Re: net::ftp (Marcel Grunauer)
    Re: Opening a file exclusively <xpalo03@vse.cz>
    Re: Opening a file exclusively <gellyfish@gellyfish.com>
        Perl and Interrupt (BIOS) Programming (CompSci90)
    Re: Perl and Interrupt (BIOS) Programming <gellyfish@gellyfish.com>
    Re: perlie tree <gellyfish@gellyfish.com>
    Re: regexp trouble.. (Abigail)
    Re: removing $array[$i]Many Thank (Abigail)
    Re: separate file <gellyfish@gellyfish.com>
    Re: sprintf padding with zeroes (Abigail)
    Re: SQL statement in Perl <eyounes@aol.com>
        Unix carriage returns? <nospam-dbown@sequent.com>
    Re: user IP (Bart Lateur)
    Re: What is functional difference between .pm and .pl? (Abigail)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 15 Jun 1999 19:52:43 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: $_ and $@ - What are they?
Message-Id: <slrn7mdtr6.do2.abigail@alexandra.delanet.com>

R.Joseph (streaking_pyro@my-deja.com) wrote on MMCXIV September MCMXCIII
in <URL:news:7k6do0$17b$1@nnrp1.deja.com>:
~~ I have been seeing the two varibles $_ and $@ in alot of scripts that I
~~ have been reading lately, and I was wondering what they are and what
~~ they do?  Are they related?  Thanks for any help!


They are related, but only by marriage. Now, what exactly $_ and $@ is
a secret. That's why there's no documentation about Perl available, and
certainly not an entire manual explaining all special variables.

The best way to find out is to consult the intestines of a M$ developer.


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: Wed, 16 Jun 1999 11:47:54 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: $_ and $@ - What are they?
Message-Id: <376f8ec8.14146757@news.skynet.be>

Abigail wrote:

>The best way to find out is to consult the intestines of a M$ developer.

Abigail, your wacky humor gets wackier all the time.

I like it.

	Bart.


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

Date: Wed, 16 Jun 1999 12:23:06 +0200
From: Steven Filipowicz <steven@*REMOVE*filipowicz.com>
Subject: 'and' problem
Message-Id: <7k7to9$i29$1@news.worldonline.nl>

Hi All,

I have this code :

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

if (length ($form_data{'name'}) == 0 )
   { 
    if (length ($form_data{'more_info'}) == 0 )
    { 
     &error_html_query_form;
     exit;
    } 
   }
---------------------------------------

As you can see it check the length of the field 'name' that comes from a
HTML form, if the length is 0
it checks the length of 'more_info' if zero output Error HTML.


I was wondering if there is a different way of writing this code
something like :

---------------------------------------
if (length ($form_data{'name'}) == 0 )  and (length
($form_data{'more_info'}) == 0 )
   {
   &error_html_query_form;
   exit;
   }
---------------------------------------

Thanks!


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

Date: Wed, 16 Jun 1999 07:26:46 -0400
From: Terry Mealy <spike1965@worldnet.att.net>
Subject: Re: 'and' problem
Message-Id: <376789F6.7C8AF5F3@worldnet.att.net>

** Newbie Alert!  Newbie Alert! **
I am still a novice w/Perl but I'd like to take a stab at this.  I'm
sure experts will correct me if I'm wrong.

How about this?

use CGI qw(standard);

my $name = param('name');
my $more_info = param('more_info');

if(length($name) eq 0 && length($more_info) eq 0){
	&error_html_query_form;
	exit;
}

You can put multiple conditions in an "if" statement, but I understand
that you might not always want to do so.  I believe that if you nest the
conditional the innermost ones aren't tested if the outermost is false. 
This can allow "short-circuting" and can save on processing if not
compilation time.  You just have to experiment & benchmark to find which
is the fastest method.

I used the CGI module because it's easy to use and pre-loaded the form
field into vars which I would test in the conditional.  
Using "$form_data{'name'}" implies that you are testing hashes, and I
suspect that that's not what you're trying to do.  


Steven Filipowicz wrote:
> 
> Hi All,
> 
> I have this code :
> 
> ---------------------------------------
> 
> if (length ($form_data{'name'}) == 0 )
>    {
>     if (length ($form_data{'more_info'}) == 0 )
>     {
>      &error_html_query_form;
>      exit;
>     }
>    }
> ---------------------------------------
> 
> As you can see it check the length of the field 'name' that comes from a
> HTML form, if the length is 0
> it checks the length of 'more_info' if zero output Error HTML.
> 
> I was wondering if there is a different way of writing this code
> something like :
> 
> ---------------------------------------
> if (length ($form_data{'name'}) == 0 )  and (length
> ($form_data{'more_info'}) == 0 )
>    {
>    &error_html_query_form;
>    exit;
>    }
> ---------------------------------------
> 
> Thanks!


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

Date: 16 Jun 1999 09:49:53 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Accessing characters in a string?
Message-Id: <37676531@newsread3.dircon.co.uk>

John L. Allen <allen@gateway.grumman.com> wrote:
> In article <7jsl8h$p25$1@links.magenta.com>,
> SMS/Christian Fowler <sms@links.magenta.com> wrote:
>>Alan Petersen (alan@ultra.finchcomputer.com) wrote:
>>:
>>: substr EXPR,OFFSET,LEN
>>: 
>>: For example:
>>:   $c = substr $myString,$n,1;
>>
>>Thanks! I did find this but figured for sure there had to be a better way
>>if you only wanted just one character! oh well.
> 
> Here's another way
> 
> 	$c = unpack P, pack N, $n + unpack N, pack P, $myString;
> 
> Hardly what I'd call "better" though, but feel free to use it in japhs :-)
> 

Well if you're going to be like that I'll raise you a:

   
   $string = "ABCDEFGHIJKLMNOPQ";

   print +($string =~ /(.)/g)[0];

/J\
-- 
"You've got to remember it was the 1980s. There were a lot of people
alive back then who died in the Second World War" - This Morning with
Richard Not Judy


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

Date: Wed, 16 Jun 1999 12:00:58 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Afraid to ask about Y2K!
Message-Id: <Pine.HPP.3.95a.990616115611.4708D-100000@hpplus01.cern.ch>

On 15 Jun 1999, Tom Christiansen wrote:

>     "J|rgen Exner" <juex@my-dejanews.com> writes:
> :And 12:00 of course means noon, it can't be midnight
> 
> I'm sorry, but you're wrong.  It's not your fault though, because
> you're probably not a native speaker of English. 

I think you're confusing "US English" with "English".  I would not make
such definite claims for "English" in general.

> But it simply
> doesn't work that way.  The clock strikes twelve twice a day.
> It never strikes 0.  It never strikes 24.  See also "Big Ben"
> for a live demo.

Big Ben does not "strike 12:00" (i.e midday). It strikes 12 o'clock -
noon and midnight. 




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

Date: 15 Jun 1999 19:58:28 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Afraid to ask about Y2K!
Message-Id: <slrn7mdu5v.do2.abigail@alexandra.delanet.com>

Tom Christiansen (tchrist@mox.perl.com) wrote on MMCXV September MCMXCIII
in <URL:news:3766e8ec@cs.colorado.edu>:
"" 
"" I'm sorry, but you're wrong.  It's not your fault though, because
"" you're probably not a native speaker of English.  But it simply
"" doesn't work that way.  The clock strikes twelve twice a day.
"" It never strikes 0.  It never strikes 24.  See also "Big Ben"
"" for a live demo.


My clock strikes 0 every day, at 18:36.



Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


  -----------== 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: Wed, 16 Jun 1999 10:05:34 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Can anyone explain this behavior?
Message-Id: <376d7590.7690653@news.skynet.be>

Bob Minnick wrote:

>($var1, $var2)=split(/ /,$arrary[$index],2);
>
>According to my documentation (camel book) split should split the array
>into the two variables where it finds the space (contained between the
>slashes), but what is happening is $var2 is getting the second value,
>but it also contains a trailing space.

Which probably means that $arrary[$index] (what a bizarre spelling)
contains a trailing space.

	$_= 'Text with some spaces...   ';
	($var1,$var2) = split / /,$_,2;
	print "\$var1 = '$var1'\n\$var2 = '$var2'\n";
__END__
$var1 = 'Text'
$var2 = 'with some spaces...   '

Nothing surprising there.

	Bart.


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

Date: 16 Jun 1999 10:33:09 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Can't load DBI modul under SCO UNIX
Message-Id: <37676f55@newsread3.dircon.co.uk>

Boris Bakulin <bakulin@eximb.kiev.ua> wrote:
> Error at the 'make test' time
> 

<snip>

That error message doesnt refer to DBI - can you be a bit more explicit
about what you are doing ...

/J\
-- 
"I want to be like Oprah" - Sarah, Duchess of York


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

Date: 16 Jun 1999 12:05:12 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Cant make PPM work.
Message-Id: <376784e8@newsread3.dircon.co.uk>

pj durai <pjdurai@my-deja.com> wrote:
> greetings.
> 
> I am trying to use ActiveStates PPM to install some packages. It always
> craps out with the following error.
> 
> [I dont have an NT. So I cant compile CPAN Stuff myself. I have to rely
> on Zipped modules from ActiveState.]
> 
> bash$ ppm.bat install XML-Parser.ppd
> 

I'm not surprised that you get an error when you try to install
XML::Parser because it is actually used by PPM itself (although I
get a different error when I try ).  It is installed already
anyhow - does this happen with other modules ?

/J\
-- 
"The Spice Girls don't care if I like them or not because I'm not twelve"
- Germaine Greer


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

Date: Wed, 16 Jun 1999 11:39:47 +0200
From: Claude Aubrie <Claude.Aubrie@inria.fr>
Subject: cpan modules marshaling
Message-Id: <376770E3.AFB7499A@inria.fr>



Data Type Marshaling (converting to/from strings) and Persistent Storage

FreezeThaw      bdpf Convert arbitrary objects to/from strings    ILYAZ
Persistence::
::Object        adpO Store Object definitions with Data::Dumper   VIPUL
+
Storable        bdcr Persistent data structure mechanism          RAM
Marshal::
::Dispatch      cdpO Convert arbitrary objects to/from strings    MUIR
::Packed        cdpO Run-length coded version of Marshal module   MUIR
::Eval          cdpO Undo serialization with eval                 MUIR
Tangram         bupO Object persistence in relational databases  
JLLEROY

Data::
::Check         cdpO Checks values for various data formats      
KENHOLM
::DRef          adph Nested data access using delimited strings   EVO
::Dumper        RdpO Convert data structure into perl code        GSAR
::Flow          RdpO Acquire data based on recipes                ILYAZ
::Locations     RdpO Handles nested insertion points in your data STBEY
::Reporter      RdpO Ascii Report Generator                       RVAZ

Tree::
::Base          cdpO Defines a basic binary search tree          
MSCHWERN
::Fat           adcO Embeddable F-Tree Algorithm Suite            JPRIT
::Smart         cdpO Sorted hash-ish, becomes faster with use    
MSCHWERN
::Trie          bdpO An implementation of the Trie data structure AVIF

DFA::
::Command       Mdpo Discrete Finite Automata command processor  
RSAVAGE +
::Kleene        R    Kleene's Algorithm for DFA                   STBEY
+
::Simple        cdpO An "augmented transition network"            RANDYM
+
-- 
 Claude Aubrie                    | http://www-rocq.inria.fr
 Inria - Domaine de Voluceau      | Tel: +33 01 39 63 52 41
 BP 105 - 78153 Le Chesnay Cedex  | Fax: +33 01 39 63 55 96
 France                           | Email: Claude.Aubrie@inria.fr


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

Date: Wed, 16 Jun 1999 11:17:05 +0100
From: Simon Wistow <simon@profero.com>
Subject: Re: csv database w/ PERL
Message-Id: <376779A1.A89E91E0@profero.com>

Try 
	http://www.astray.com/VCS/

it may or may not help but
it's worth a try.

> I have a csv database file that I am trying to interface with my PERL
> script.  
-- 

Simon
Wistow                     
Developement
simon@profero.com                 
Profero Ltd
Phone:0171 700 9960       
Fax:  0171 700 9961


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

Date: 16 Jun 1999 12:01:05 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: date formats
Message-Id: <376783f1@newsread3.dircon.co.uk>

Emily Brock Latham <eblatham@unity.ncsu.edu> wrote:
> 
> I have a user putting in a date of several different styles of input,
> and I have to convert it to numerical month and day stuff.  I also have
> to find from the date what the day of the week is?  Is there an easier
> way than loads of if/else statements?  and I have no idea where to begin
> getting the day of the week info?
> 

You might look at 

<http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=488359640&fmt=text>

In which is discussed a method of calculating the day of the week
from the day of the month , month and year - You are responsible
for splitting the date up into the bits that you want.

You might also want to consider one of the Date::* modules for
manipulating dates.

/J\
-- 
"Report accuses Royal Opera House of 'arrogance and elitism'. Report
further alleges that Pope is Catholic. Report further claims that bears
may well indeed defecate in the woods" - Private Eye


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

Date: 15 Jun 1999 20:06:03 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: date formats
Message-Id: <slrn7mduk2.do2.abigail@alexandra.delanet.com>

Emily Brock Latham (eblatham@unity.ncsu.edu) wrote on MMCXIV September
MCMXCIII in <URL:news:3766E038.175AF95E@unity.ncsu.edu>:
^^ Thank you for your input, but I was hoping that there was some function
^^ that would do a bit more of the work for me, you know?  the only way I
^^ see to use localtime() to do what i need is to get the current day, then
^^ find the difference in today's date and the date entered by the user.  
^^ 
^^ I was also trying to take in dates of multiple formats (4/21 and  apr 21
^^ and convert them all to numerical m/d format).
^^ 
^^ It's not just current day stuff.  I was hoping that I didn't have to do
^^ all the calculating between the current day and the date entered by the
^^ user.
^^ 
^^ Is there just NO EASIER WAY?


Did you check out the various Date:: modules? Or did you stop reading
the faq after struggling with the word 'localtime'?



Abigail
-- 
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))


  -----------== 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 Jun 1999 09:24:08 GMT
From: stefano@rerumnatura.zool.su.se (Stefano Ghirlanda)
Subject: Re: exclusive open
Message-Id: <slrn7mfkge.67t.stefano@rerumnatura.zool.su.se>

On Tue, 15 Jun 1999 23:09:33 +0200, Oreg Dixie <maistro@swi.hu> wrote:

>I wrote a complete forum in perl, but I've got one problem with it: When two
>or more users write to it simultaneously, then there'll be some garbage in
>the log file. How Can I open the forum's log file exclusively? 

You can have *all* your functions that write to the log file honor file
locking, e.g.:

use Fcntl ':flock';
use POSIX;

sysopen FILE, $filename, O_WRONLY|O_APPEND;
flock $filename, LOCK_EX; # this _blocks_ until a lock is obtained
syswrite FILE $logline;
close FILE; # this unlocks the file and makes it available to others

Don't forget to populate with "or die" stuff!
Note that this might not be very well portable, especially in non-Unix
environments. I have found it more reliable to use the sys* functions
rather than open and print (but my experience is limited). You could also
have a look at your flock(2) or similar.

You might also want to autoflush the FILE.

Note that this will not work if the logfile is used by some other
application that does not honor locks. You are safer using a dedicated
logfile.

> And what'll
>happen when someone locked the file (the script is writing the message into
>the log file) and another request comes from another user? It would be nice
>to keep the other users wait till the writing procedure ends.

This is exactly what will happen with the code above. If someone asks for
the lock when the file is locked, the flock() call blocks until the lock
can be granted. At that point you are sure that no other process (that
honors file locking) will be able to write to the file until the lock is
released.

Good luck,
Stefano

-- 
 Stefano Ghirlanda, Zoologiska Institutionen, Stockholms Universitet
    Office: D554, Arrheniusv. 14, S-106 91 Stockholm, Sweden
Phone: +46 8 164055, Fax: +46 8 167715, Email: stefano@zool.su.se
   Support Free Science, look at: http://rerumnatura.zool.su.se


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

Date: Wed, 16 Jun 1999 09:55:36 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: exclusive open
Message-Id: <376c7417.7313044@news.skynet.be>

Oreg Dixie wrote:

> wrote a complete forum in perl, but I've got one problem with it: When two
>or more users write to it simultaneously, then there'll be some garbage in
>the log file. How Can I open the forum's log file exclusively?

First open the file, then flock() it. See "perldoc -f flock" for example
code (sub lock is nice), except:

DO NOT EVER unlock the file! Just close() the file as soon as you're
done!

   HTH,
   Bart.


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

Date: Wed, 16 Jun 1999 21:29:07 +0930
From: "Kevin Read" <kevin@synergysa.com.au>
Subject: expire a https session 
Message-Id: <376790eb.0@kastagir.senet.com.au>

Hi

I'm trying to work out away to expire a https session via perl from the
client side.

The user would...

Click on a button, calling the script and their https session will be
invalidated (cleared) and they would be redirected to a new URL - outside of
the https site.

Should they wander/surf back into the secure site they must be asked to
login/authenticate again.

I've no problems with the redirect etc using CGI but invalidating the
session and clearing the credentials seems impossible to find.

Any assistance would be appreciated.

Kevin





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

Date: 16 Jun 1999 11:37:23 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: FEAR FAD
Message-Id: <37677e63@newsread3.dircon.co.uk>

David Cassell <cassell@mail.cor.epa.gov> wrote:
> sean-whitestone wrote:
>> 
>> Y2K MILLENNIUM BUG:THE LATEST  FEAR FAD "I sought the Lord and He answered
>> [BIG SNIP]
> 
> Why do I have this awful temptation to give this guy Jocelyn's
> e-mail address?  And _vice_versa_?
> 

Dont worry she'll be along in a while - I figure she greps her newsfeed
from 'Y2K' :

"You see, this is exactly my point another case of programmer denial ..."

/J\
-- 
"I sign my paintings Vincent because people can't pronounce Van Gough"
- Vincent Van Gough


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

Date: Wed, 16 Jun 1999 09:48:51 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: File Processing
Message-Id: <376860d9.2387974@news.skynet.be>

ericho@sehk.com.hk wrote:

>What puzzled me is the difference between
>
>local($r) = <f>;
>
>and
>
>local($r);
>$r = <f>;
>
>I'm pondering Bart's reply.

OK. This may help even more.

	local($r) = scalar <f>;
	
	Bart.


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

Date: Wed, 16 Jun 1999 09:12:11 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: Fix this uglyness
Message-Id: <sibteg33x0.fsf@cre.canon.co.uk>

Alan <alanp@unixpower.org> wrote:
> system("cat /var/log/wtmp | uuencode wtmp.`date +%m-%d` | mail $WTMPBACK");

1. You don't need `cat'.
2. Percent is a shell metacharacter.
3. This should have been asked in comp.unix.shell.

-- 
Gareth Rees


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

Date: Tue, 15 Jun 1999 22:48:08 +0200
From: Thomas Weholt <thomas@bibsyst.no>
Subject: How to distribute a script?
Message-Id: <3766BC08.4BFFA0FE@bibsyst.no>

Hi,

Is there any script that can help in making a script easier to
install? I know there is h2xs to make Makefiles etc. for modules, but I
was wondering if there are any similar tools for making Makefiles for
scrits? for instance, I need to check which modules are installed, which
perl version, if some GNU utils are installed on the current platform
etc.

Thanks!

Thomas Weholt,
Norway



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

Date: Wed, 16 Jun 1999 10:08:44 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: How to distribute a script?
Message-Id: <MIK93.4033$9P4.77126@news2.rdc1.on.home.com>

In article <3766BC08.4BFFA0FE@bibsyst.no>,
 Thomas Weholt <thomas@bibsyst.no> wrote:
! Hi,
! 
! Is there any script that can help in making a script easier to
! install? I know there is h2xs to make Makefiles etc. for modules, but I
! was wondering if there are any similar tools for making Makefiles for
! scrits? 

Randy Kobes wrote a script called 'sdist' (available on CPAN)
that mimics h2xs functionality for scripts --- in fact, Randy
has an article presenting the sdist code in our upcoming first
issue of a new free perl newsletter. (the newsletter is called
PUBcrawl, and we hope to finally have it ready by this weekend...
stay tuned).

regards
andrew



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

Date: 16 Jun 1999 11:31:18 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How to scan a directory and put all the files and their size to a text file
Message-Id: <37677cf6@newsread3.dircon.co.uk>

Lauren Smith <laurens@bsqaure.com> wrote:
> Dariush_news wrote in message <7k6c2q$c1r$1@clio.net.metrotor.on.ca>...
>>Hi Everyone;
>>
>>I need to scan a directory and input all the file namse in to a text file
>>with thier respecitve size.
>>
> Here's a very OS dependent script that can do that:
> 
> #!/usr/bin/perl -w
> use strict;
> 
> system ("dir /a-d > foo.txt");
> 
> open (FOO, "foo.txt");
> open (OUT, ">out.txt");
> 

You really should check the success of thes opens :

open(OUT,">out.txt") || die "Cant open out.txt - $!\n";

You can also do away with the temporary file by using the backticks:

@files = `dir /a-d`;

while(@files)
{
>    if (/^\s/) {
>       next;
>    } else {
>       /^.{17}(.*)/;
>       print OUT "$1\n";
>    }
> }
> 

However, Perl has the inbuilt functionality to get at directory entries
and the size of files - see for instance :

<http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=489070440&fmt=text>

This could be adapted to find the size of the files instead of the
modification time - see the perlfunc manpage entry for stat().

> Don't try this on a non-Windows OS.
> 

Using opendir/readdir is portable.

/J\
-- 
"Most big companies don't like you very much, except hotels, airlines
and Microsoft, which don't like you at all" - Bill Bryson


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

Date: Wed, 16 Jun 1999 09:48:53 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Is it better perl than awk ?
Message-Id: <376a6369.3043449@news.skynet.be>

Tom Christiansen wrote:

> Henry Churchyard writes:
>:Actually, Microsoft refers to it as "Windows ANSI" or "Code page 1252"
>
>Well, I hardly expected them to call refer to it as Illegal MS-ASCII. :-)

ASCII is the character set with character codes from 0 to 127 inclusive.
Anything beyond that (character codes 128 to 255) is not Ascii. Ansi,
yes, ISO-Latin-1, yes.

Windows uses a superset of that, i.e. it uses some originally unused
character codes for characters that were missing, including fancy quotes
and the French "OE" ligature.

>:The quasi-accepted solution here is to use HTTP headers such as:
>:Content-Type: text/plain;charset=windows-1252
>
>That's an interesting approach.  For some reason, I don't
>seem to see it used.  

The fact that users' software usually doesn't allow adding custom
headers, doesn't help.


Urm... do I have anything useful to add to the original thread? Maybe
this: if this is all you need to do, Awk may be the way to go.  Perl is
a general power tool, far more general than awk, so if you expect to do
far more, and more fancy stuff, in the near future, I would go for Perl.
Also, if you're already somewhat familiar with programming, Perl may
look more familiar.

	Bart.


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

Date: Wed, 16 Jun 1999 08:23:27 GMT
From: smnayeem@my-deja.com
Subject: is there any function to spell out words?
Message-Id: <7k7mts$euo$1@nnrp1.deja.com>

Is there nay function in Perl which would spell out numbers for me? say
like 1175 would return one thousand one hundred seventy five.
thanks in advance.
smnayeem
smnayeem@agni.com


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


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

Date: Wed, 16 Jun 1999 09:53:33 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: is there any function to spell out words?
Message-Id: <3769732e.3519410@enews.newsguy.com>

On Wed, 16 Jun 1999 08:23:27 GMT, smnayeem@my-deja.com wrote:

>Is there nay function in Perl which would spell out numbers for me? say
>like 1175 would return one thousand one hundred seventy five.
>thanks in advance.

Lingua::En::Numbers

HTH

Marcel



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

Date: Wed, 16 Jun 1999 00:06:21 -0600
From: Tim <bie@connect.ab.ca>
Subject: Location
Message-Id: <37673EDD.4D82@connect.ab.ca>

Hello,


How can I make user go right now a page, without going to a page, then
redirected. 

Is there a cgi scalar that will let me do this?


example:

if ($page = "one") {
GO RIGHT TO PAGE ONE
}
else {
go to default right away
}


Tim
-- 

-------------------------------------------------------
| TBE: http://tbe.virtualave.net                      |
| * 3:2 Ratio + 100 Free credits! *                   |
| Tim's Chat Doors: http://www.connect.ab.ca/~mundy/  |
-------------------------------------------------------


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

Date: Wed, 16 Jun 1999 17:26:17 +0531
From: "Narasimha G. Pai" <pai@cadence.com>
Subject: Multi line match help
Message-Id: <376790A5.8BE2CCEE@cadence.com>

Hi friends ,

    I have a problem in perl pattern matching and only someone here
can help .

I have a file in the following format :

12:12:96 : Updated test1 . Writing test2.
01:10:97 : test2 done . Started test3.
                test4 PLANNED .

Now I have to get the date for which test4 was planned .
I suppose this requires a multiline match .

so what I am doing is setting $/ to nothing . I read the entire file
in $_ and then try to do a match .

I tried :

if(/([0-9][0-9]).*PLANNED) /) and guess what it gave me :


12:12 in $1 .

Now what i need is 01:10.

Any ideas on how I can reduce my search to the last possible
match and not the first possible .

to summarise : what I need to do is to find a date after which
there some text and then the word PLANNED . There can be
multiple lines between the date and the word PLANNED . but
there would be no date between them .


help !



--
|======================================================================|
|Kanwarpreet Singh Grewal                  | email: kanwar@cadence.com |
| Cadence Design Systems (India) Pvt. Ltd.,| Home address: E-217       |
| SDF # B-8, Noida Export Processing Zone, | Ram Vihar                 |
| Noida, UP - 201305, India                | Sector : 30               |
| Tel: +91-11-8562842                      | Noida, UP India           |
|======================================================================|





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

Date: Wed, 16 Jun 1999 09:29:37 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: net::ftp
Message-Id: <37676d68.2041094@enews.newsguy.com>

On Tue, 15 Jun 1999 21:45:39 -0700, davidk <davidk@netscape.com>
wrote:

>> Quick question.  Does Active Perl Build 517 include Net::FTP?  If not,
>> where do I find it?  Thanks.
>
>no and CPAN

Use the PPM (ActiveState's Perl Package Manager) to install libnet,
which contains Net::FTP (amongst other things). Just open a command
wndow, type "ppm", and then, within the ppm, type "install libnet".

HTH

Marcel



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

Date: Wed, 16 Jun 1999 10:58:49 +0200
From: Ondrej Palkovsky <xpalo03@vse.cz>
Subject: Re: Opening a file exclusively
Message-Id: <37676749.4A38FBC1@vse.cz>

Oreg Dixie wrote:

> the log file. How Can I open the forum's log file exclusively? And what'll
> happen when someone locked the file (the script is writing the message into
> the log file) and another request comes from another user? It would be nice
> to keep the other users wait till the writing procedure ends.
perldoc -f flock

Ondrej Palkovsky
-- 
Nature, to be commanded, must be obeyed.
		-- Francis Bacon


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

Date: 16 Jun 1999 10:24:38 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Opening a file exclusively
Message-Id: <37676d56@newsread3.dircon.co.uk>

Oreg Dixie <maistro@swi.hu> wrote:
> Hi!
> 
> I wrote a complete forum in perl, but I've got one problem with it: When two
> or more users write to it simultaneously, then there'll be some garbage in
> the log file. How Can I open the forum's log file exclusively? And what'll
> happen when someone locked the file (the script is writing the message into
> the log file) and another request comes from another user? It would be nice
> to keep the other users wait till the writing procedure ends.
> 


You will want to use flock() which is described in the perlfunc manpage.

/J\
-- 
"I'm about to say a naughty word so if you're easily offended you can
fuck off now" - Daisy Donovan, The 11 O'Clock Show


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

Date: 16 Jun 1999 09:04:45 GMT
From: compsci90@aol.com (CompSci90)
Subject: Perl and Interrupt (BIOS) Programming
Message-Id: <19990616050445.28993.00000080@ng-cj1.aol.com>

Hello!

I'm trying to find a way in which I can do interrupt (BIOS) programming in
Perl.

One way that comes to mind is the way in which interrupt (BIOS) programming is
done in C (i.e., inline assembly programming).

Is there a way in which I can do inline assembly programming in Perl?

If not, is there *any* way in which I can do interrupt (BIOS) programming in
Perl?

Any help will be appreciated.
Thank you.

Regards,
Alex K.



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

Date: 16 Jun 1999 11:41:08 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl and Interrupt (BIOS) Programming
Message-Id: <37677f44@newsread3.dircon.co.uk>

CompSci90 <compsci90@aol.com> wrote:
> Hello!
> 
> I'm trying to find a way in which I can do interrupt (BIOS) programming in
> Perl.
> 

Right ...

> One way that comes to mind is the way in which interrupt (BIOS) programming is
> done in C (i.e., inline assembly programming).
> 
> Is there a way in which I can do inline assembly programming in Perl?
> 

Nope ...

> If not, is there *any* way in which I can do interrupt (BIOS) programming in
> Perl?
> 

I suppose you *could* do it by creating an XS module in C that provided
a Perl interface to your systems interrupt mechanism - check out the
perlxstut manpage and see if that will be any good for you ..

/J\
-- 
"They're called Virgin Trains because they don't go all the way" -
Simon Hoggart, The Guardian


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

Date: 16 Jun 1999 11:45:48 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: perlie tree
Message-Id: <3767805c@newsread3.dircon.co.uk>

cwt <eng80386@nus.edu.sg> wrote:
> Hallo all , below is a scripts that would go into a directory , search for
> files with a target string and write to a log file the line that the string
> occurs.
> Can anyone suggest ways to make it a recursive algorithm such that it would
> go
> into the directory and execute the process from the parent into the
> sub-directories downwards like a tree ??

You would probably be better of using the module File::Find - however you
insist on doing this yourself you might see for instance 

<http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=477150865&fmt=text>


/J\
-- 
"I thought homogenous culture was a kind of yogurt used to alleviate
thrush" - Ben Elton


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

Date: 15 Jun 1999 20:10:55 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: regexp trouble..
Message-Id: <slrn7mduta.do2.abigail@alexandra.delanet.com>

Bastiaan S van den Berg (office@asc.nl) wrote on MMCXIV September
MCMXCIII in <URL:news:7k5nu7$4ea$1@zonnetje.NL.net>:
 .. i get the error :[ cookiesite.cgi: /3020 103 3020\w+)/: unmatched () in
 .. regexp ]
 .. 
 .. the regexp that causes the error is :
 .. $HTML =~ s/$(\w+)/$\1/g;


Wasn't this discussed recently?

$( is a variable.


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'


  -----------== 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: 15 Jun 1999 20:12:16 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: removing $array[$i]Many Thank
Message-Id: <slrn7mduvr.do2.abigail@alexandra.delanet.com>

bernd1615@my-deja.com (bernd1615@my-deja.com) wrote on MMCXIV September
MCMXCIII in <URL:news:7k5v9s$qr3$1@nnrp1.deja.com>:
[] Dear Participants,
[] 
[] I know there is the substitution operator in Perl.
[] But is there also a delete operator ?
[] 
[] foreach (@array) {
[] 		   if ( $_ =~ /#matches something/ ) {
[]                    # delete $array[$i] }
[] 		  }


splice, but in this case, you want grep.



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


  -----------== 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 Jun 1999 11:50:10 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: separate file
Message-Id: <37678162@newsread3.dircon.co.uk>

Leonid Goltser <leonid76@erols.com> wrote:
> I tried to use several files for my program. I use
> "require "filename";
> 
> but I got message that says that structure does not return true.
> What does it mean and how to fix it?
> 

You need to put

'I am the lord of hell fire';

as the last line in your required file

/J\
-- 
"We've even been asked to review a luxury hotel. I can't think why" -
Neil Hamilton


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

Date: 15 Jun 1999 20:14:47 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: sprintf padding with zeroes
Message-Id: <slrn7mdv4i.do2.abigail@alexandra.delanet.com>

Paul Wood (john.wood@diamond.co.uk) wrote on MMCXIV September MCMXCIII in
<URL:news:7k6jfd$a1g$1@nclient3-gui.server.ntli.net>:
%% Ah, thanks for that. I work in Windows (I know, I know), so I don't have
%% access to the man pages.


Bullshit.


Abigail
-- 
perl  -e '$_ = q *4a75737420616e6f74686572205065726c204861636b65720a*;
          for ($*=******;$**=******;$**=******) {$**=*******s*..*qq}
          print chr 0x$& and q
          qq}*excess********}'


  -----------== 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: Wed, 16 Jun 1999 11:01:51 +0200
From: "Ysteric's" <eyounes@aol.com>
Subject: Re: SQL statement in Perl
Message-Id: <7k7p77$7be@news.vtcom.fr>

why don't you use DBI and DBD::ODBC modules, it's very easy ...

look the folowing example :

use DBI;

print "connexion ...";
$dbh = DBI->connect('dbi:ODBC:Secu') || die('$DBI::errstr');
#                                                        ^^^^^ this is your
DSN

print "...connexion OK";

$sth = $dbh->prepare(qq{select * from testrg});
$sth->execute || die('$DBI::errstr');

$cnt = 0;
print qq{<font face="Arial,Helvetica" width=600><table>
};
$no_secu =~ s/ /+/g;
if( @rows = $sth->fetchrow_array) {
    foreach $x (@rows) {
        print "$x<br>"; #for example !!!
    }
} else {
 print qq{
  <table width="400" border=0 bgcolor="#000000">
    <th><font face="Arial, Helvetica" color="#FFFFFF"
size="5"><center><b>Fiche employ&eatute;<br>&nbsp;</b></center></font></th>
    <tr>
      <td><hr><font face="Arial, Helvetica, sans-serif"
color="#FFFFFF"><b>Sorry, no records found !</b></font><hr></td>
    </tr>
  </table>
 };
}

$sth->finish;
$dbh->disconnect;

Hope that it will be useful for you

Eric - FRANCE


paulm@dirigo.com a icrit dans le message <7k669f$ts0$1@nnrp1.deja.com>...
>Does anyone have any familiarity with writing SQL statements in Perl?
>
>I have a script that's using Win32 OLE and calling a System DSN.  The
>call to the system DSN is working, but the script is failing when
>running the SQL statement.  I'm attempting to grab info from an Access
>97 database.  It looks as follows:
>
>my $db = new Win32::ODBC( $dsn ) || die "Error: " . Win32::ODBC::Error
>();
>$stmt = "SELECT ALL * FROM [Forecast]";
>
>I've tried multiple combinations of the SQL.  It's attempting to grab
>the data from the Forecast table and print it, but it keeps erring out.
>
>Does this have something to do with Access 97?
>Any help would be largely appreciated.
>
>Thanks in advance.
>
>--
>Paul R. Mesker
>System Engineer
>Dirigo Inc.
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.




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

Date: 16 Jun 1999 10:58:24 GMT
From: "David Bown" <nospam-dbown@sequent.com>
Subject: Unix carriage returns?
Message-Id: <01beb7e7$269cef20$c976549e@w-skefford.uk.sequent.com>

Do perl scripts need unix carriage returns to function properly.

any help gratefully received!


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

Date: Wed, 16 Jun 1999 09:48:48 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: user IP
Message-Id: <37675c68.1250093@news.skynet.be>

Leonid Goltser wrote:

>I want my script can recognize IP of a user who call it.

If for CGI, experiment with these:

	$ENV{REMOTE_USER}
	$ENV{REMOTE_HOST}
	$ENV{REMOTE_ADDR}
	$ENV{REMOTE_PORT}

Your server probably won't support them all, but you'll soon find out
which ones are usable.

	Bart.


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

Date: 15 Jun 1999 20:24:14 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: What is functional difference between .pm and .pl?
Message-Id: <slrn7mdvm8.do2.abigail@alexandra.delanet.com>

Tom Christiansen (tchrist@mox.perl.com) wrote on MMCXIV September
MCMXCIII in <URL:news:3766c356@cs.colorado.edu>:
??      [courtesy cc of this posting mailed to cited author]
?? 
?? In comp.lang.perl.misc, Scratchie <upsetter@ziplink.net> writes:
?? :Some people use .pl to represent a perl script. It makes it very easy to
?? :do things like
?? :
?? :	grep <some pattern> *.cgi *.pl
?? 
?? For various reasons, that really doesn't make much sense.  Sorry.  
?? I cannot think of any time I've ever wanted to do that, and 
?? I've been hacking at this quite a long time, you know.


I use .pl because that makes my editor jump into the appropriate mode. :)

Of course, I could use .plx or .^^^^ or .### as well, but I like .pl.



Abigail
-- 
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
         ${qq$\x5F$} = q 97265646f9 and s g..g;
         qq e\x63\x68\x72\x20\x30\x78$&eggee;
         {eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'


  -----------== 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: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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