[7492] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1118 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 3 01:07:46 1997

Date: Thu, 2 Oct 97 22:00:24 -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           Thu, 2 Oct 1997     Volume: 8 Number: 1118

Today's topics:
     Re: "Unreading" an input line (Eric Bohlman)
     Debuging the CPAN module <dexterp@acay.com.au>
     Re: Emmulating MORE in Perl? <rra@stanford.edu>
     Flakey - My scripts works sometimes not others... help! <nathan@cyberservices.com>
     Help with redirect script (Eric Blessner)
     hex display for large integer <minhn@newbridge.com>
     hex display for large integer <minhn@newbridge.com>
     Installing CGI.pm question <barry@megaspace.com>
     Is there a Newsgroup for "Perl for NT and/or IIS"? <nathan@cyberservices.com>
     Need Help for Perl with MS Access Database (Robert Ferenc)
     Re: new@cgi (Klaus Krtschil)
     Re: new@cgi (Klaus Krtschil)
     nmake not making <robbin@interactive.-not-.net>
     Re: NT 4 and PERL <lanceb@microsoft.com>
     Re: Number of Emails? <kjj@pobox.com>
     Re: Number of Emails? <kjj@pobox.com>
     Re: Performing Subroutines from a string of text (Mike Stok)
     Re: Performing Subroutines from a string of text (Eric Bohlman)
     Re: PERL 5.003 and the _STDC_ variable <bholzman@mail.earthlink.net>
     rmdir and rmtree not working. <emil.granstrom@era.ericsson.se>
     Re: Using Perl Format <IggieBee@worldnet.att.net>
     using split on URL's?? (Kenneth Blinco)
     Re: using split on URL's?? <aas@sn.no>
     XPUSHi <aas@sn.no>
     XS & variable-length <thalerk@vrinet.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 3 Oct 1997 00:38:34 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: "Unreading" an input line
Message-Id: <ebohlmanEHG9sA.39s@netcom.com>

Danilo Unite (danilo@acme.nsc.com) wrote:
: I am trying to parse input from a socket connection to a daemon process.
: I have a function that reads this input a line at a time. I am using
: this function in a recursive manner such that in some instances I want
: to put the line that I just read back into the input stream so that the
: same line is available to a subsequent call to this function. The
: following snippet of code illustrates what I am trying to do:

You're probably best off writing a couple subs, one to "get new line" and 
one to "push back line" (and possibly one to check if any lines are 
available) that share an array used as a pushback buffer.

: local($STATE) = 0;
: while(!eof($fh)){

You may need to replace the eof() with a call to one of your subs.

:     $attr = &_readAttr($fh);
:     if(ref($attr) ne "Error"){
:         $attrlist->add($attr);
:     }
:     else{
:         $return $attr;
:     }
: }
: .
: .
: sub _readAttr{
:     $line = <@_>;

You'd replace this with a call to your "get line" sub.

:     if($STATE == 0){
:     .......
:         $STATE = 1;
:         &_readAttr(@_);
:     }
:     else{
:     .....
: # push $line back onto input stream

You'd call your "pushback" sub here.

:     }
: }



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

Date: Fri, 03 Oct 1997 12:47:37 +0000
From: Dexter Plameras <dexterp@acay.com.au>
Subject: Debuging the CPAN module
Message-Id: <3434E969.18BF227E@acay.com.au>

HELLO

I am tring to Use CPAN that came with Perl5.004_01 to obtain and
automatically
install new perl modules.

The error I get when using 'perl -MCPAN -e shell' is 
	
	cpan>install <MODULE>
	.
	.
	.
	.
	CPAN: MD5 loaded successfully
	perl: can't resolve symbol 'Perl_safemalloc'

(Then it takes me back to the bash shell.

MY SYSTEM

	Linux (Kernel 2.1.25)
	Perl 5.004_01
	CPAN 1.30 or CPAN 1.31 or CPAN 1.3.101
	
	NB. note I have taken perl 5.003 off my system.

Any Ideas 
Regards Dexter Plameras


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

Date: 02 Oct 1997 16:59:30 -0700
From: Russ Allbery <rra@stanford.edu>
To: turnerj@cliffy.lmtas.lmco.com (Jim Turner )
Subject: Re: Emmulating MORE in Perl?
Message-Id: <m3g1qj1ztp.fsf@windlord.Stanford.EDU>

[ Posted and mailed. ]

Jim Turner <turnerj@cliffy.lmtas.lmco.com> writes:

> Help!  I am needing to emmulate the behavior of "more" using Perl.  My
> problem is that I am piping in a file, command results, etc. into STDIN,
> but need to be able to pause and input a character directly from the
> terminal in the same program.  Anyone have any ideas how to do this?

Why not just pipe it through more?  (Or better, $ENV{PAGER} || 'more').
People have different preferences in pagers, might want less instead of
more, might have different options that they want (I, for example, utterly
despise reading scrolling text), and so on.  No need to reinvent the
wheel.

-- 
#!/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: Thu, 02 Oct 1997 19:31:33 +0000
From: Nathan Stanford <nathan@cyberservices.com>
Subject: Flakey - My scripts works sometimes not others... help!
Message-Id: <3433F694.CF59254A@cyberservices.com>

It does not work every time some times I put in no password on the form
and it lets me still get the web page help why does it work sometimes
and not other?


#############################################################################

#  My Perl file below
#############################################################################



$passwordfile="pass.txt";
$bad=0;
$firstname="bad";
$lastname="news";
$password="bears";
$userid=1;
$Rfirstname="bad1";
$Rlastname="news1";
$Rpassword="bears1";
$userid=0;

$background='<BODY TEXT="#FFFFFF" BGCOLOR="#004200" LINK="#FFFF00"
VLINK="#C0C0C0" ALINK="#C0FFC0">';



#############################################################################

# Body
#############################################################################

&getinfo;
&splitinfo;
&passwordfile;
&content;

#############################################################################

# incorrect - the web page when the password is incorrect.
#############################################################################

sub incorrect
{
print <<"eop";

<HTML><title>Error</title>$background
<H1><CENTER>Bad Password</CENTER></H1>


</body></html>

eop
}



#############################################################################

# content - This line tells the browser to expect a text/html file.
#############################################################################

sub content
{
print "Content-type: text/html\n\n";
}

#############################################################################

# getinfo
#############################################################################

sub getinfo
{
if ($ENV{'REQUEST_METHOD'} EQ 'POST') {
        read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
        @pairs=split(/&/, $buffer);
 }
}


#############################################################################

# splitinfo - This is the Name-Value pair splitter.. Put into $FORM
array
#############################################################################

sub splitinfo
{

        foreach $pair (@pairs)
 {

                ($name,$value)=split(/=/,$pair);
                $value=~tr/+/ s/;

$value=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
                $FORM{$name}=$value;
 }

        $firstname=$FORM{firstname};
        $lastname=$FORM{lastname};
 $userid=$FORM{userid};
        $password=$FORM{password};

}

#############################################################################

# correct - get the html file to print out.
#############################################################################

sub correct
{
 $html="html";
 $htmlfile=$firstname.$lastname.$userid;
 open (HTMLFILE, "$htmlfile.html");
 undef $/;
 $body=<HTMLFILE>;
 $/="\n";
 print "\n\n".$body;
 close(HTMLFILE);

}



#############################################################################

# passwordfile - get the password file.
#############################################################################

sub passwordfile
{
 open (PSSWRD, "$passwordfile");

         while ($line=<PSSWRD>)
 {

 ($Rfirstname, $Rlastname, $Ruserid, $Rpassword)=split(':',$line);
 if (($Rfirstname=~/^$firstname/i) && ($Rlastname=~/^$lastname/i) &&
{$Ruserid=~/^$userid/i} && ($Rpassword=~/^$password/i))
  {
  &correct;
  exit;
  } else {
  $bad="1";

  }

 }

 if ($bad="1")
 {
 &incorrect;
 }

}



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

Date: Thu, 2 Oct 1997 21:39:44
From: edb105@psu.edu (Eric Blessner)
Subject: Help with redirect script
Message-Id: <edb105.2.0015AA32@psu.edu>

I want to redirect a url from a html page.   I used this

echo Location: http://www.sample.com
echo

This works but my problem is it does not regster in my stats output as being 
accessed (which is the whole reason I put it out there.)   What do I need 
to do to get it to register.   Can anyone help me with this, I would be 
greatful.  

My isp uses wwwstat-2.0 


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

Date: Thu, 02 Oct 1997 18:31:24 -0700
From: Minh Nguyen <minhn@newbridge.com>
Subject: hex display for large integer
Message-Id: <34344AEC.A69EEBF1@newbridge.com>

Hello,

Does anyone know if you can display large decimal values (greater than
32 bits) in perl? When  I use printf "%lx",  an incorrect hex value is
displayed because the high bits are chopped off.

Minh




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

Date: Thu, 02 Oct 1997 18:43:02 -0700
From: Minh Nguyen <minhn@newbridge.com>
Subject: hex display for large integer
Message-Id: <34344DA5.E8B2EB80@newbridge.com>

Hello,

Does anyone know if you can display large decimal values (greater than
32 bits) in perl? When  I use printf "%lx",  an incorrect hex value is
displayed because the high bits are chopped off.

Minh




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

Date: Thu, 02 Oct 1997 20:37:09 -0400
From: Barry Kaplan <barry@megaspace.com>
Subject: Installing CGI.pm question
Message-Id: <34343E35.AD879903@megaspace.com>

I'm trying to install the latest CGI.pm-2.37b5 on my ISP's unix box.
When I run "perl Makefile.PL", I get the following error message:

web: {5} % perl5 Makefile.PL
Can't locate Carp.pm in @INC at ExtUtils/MakeMaker.pm line 13.
BEGIN failed--compilation aborted at ExtUtils/MakeMaker.pm line 13.
BEGIN failed--compilation aborted at Makefile.PL line 1.

I've tried placing Carp.pm in an ExtUtils subdirectory and but it still
yeilds the same results.

Has anyone ever seen this before?





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

Date: Thu, 02 Oct 1997 19:40:14 +0000
From: Nathan Stanford <nathan@cyberservices.com>
Subject: Is there a Newsgroup for "Perl for NT and/or IIS"?
Message-Id: <3433F89E.E8D269E1@cyberservices.com>

 Is there a Newsgroup for "Perl for NT and/or IIS"?



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

Date: 1 Oct 1997 16:08:07 GMT
From: R-O-B@t-online.de (Robert Ferenc)
Subject: Need Help for Perl with MS Access Database
Message-Id: <60tsh7$irf$1@news01.btx.dtag.de>

hi all!
i have following problem: i wanna create a database for the internet in
perl. but it must also be available for an MS access database. i heard
that exists a c program that could help. please give me some information
where i can get it or mail me!
thanx rob	

R-O-B@t-online.de


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

Date: 30 Sep 1997 19:58:22 GMT
From: Klaus.Krtschil@t-online.de (Klaus Krtschil)
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: new@cgi
Message-Id: <60rlku$4vn$1@news02.btx.dtag.de>

Hi,

it seems that your web-server does not have the rights to write to that
directory but you as a user has the rights. That explains why the script
works at the prompt but not with the browser.

Klaus

Tom Phoenix wrote:
> 
> On Tue, 30 Sep 1997, Victoria Hawkins wrote:
> 
> > If I execute the script at the unix prompt, SEQUENCE appears in the
> > directory, and inside is the sequence. If I use the browser to execute
> > the program, then SEQUENCE doesn't get created.
> 
> When you're having trouble with a CGI program in Perl, you should first
> look at the please-don't-be-offended-by-the-name Idiot's Guide to
> solving such problems. It's available on the perl.com web pages.
> 
>    http://www.perl.com/perl/
>    http://www.perl.com/perl/faq/
>    http://www.perl.com/perl/faq/idiots-guide.html
> 
> > open(OUT, ">SEQUENCE"); # open SEQUENCE file for writing
> 
> Even when your script is "just an example" (and perhaps especially in that
> case!) you should _always_ check of the return value after opening a
> file.
> 
> Hope this helps!
> 
> --
> Tom Phoenix           http://www.teleport.com/~rootbeer/
> rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
> Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
>               Ask me about Perl trainings!


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

Date: 30 Sep 1997 19:59:13 GMT
From: Klaus.Krtschil@t-online.de (Klaus Krtschil)
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: new@cgi
Message-Id: <60rlmh$4vn$2@news02.btx.dtag.de>

Hi,

it seems that your web-server does not have the rights to write to that
directory but you as a user has the rights. That explains why the script
works at the prompt but not with the browser.

Klaus

Tom Phoenix wrote:
> 
> On Tue, 30 Sep 1997, Victoria Hawkins wrote:
> 
> > If I execute the script at the unix prompt, SEQUENCE appears in the
> > directory, and inside is the sequence. If I use the browser to execute
> > the program, then SEQUENCE doesn't get created.
> 
> When you're having trouble with a CGI program in Perl, you should first
> look at the please-don't-be-offended-by-the-name Idiot's Guide to
> solving such problems. It's available on the perl.com web pages.
> 
>    http://www.perl.com/perl/
>    http://www.perl.com/perl/faq/
>    http://www.perl.com/perl/faq/idiots-guide.html
> 
> > open(OUT, ">SEQUENCE"); # open SEQUENCE file for writing
> 
> Even when your script is "just an example" (and perhaps especially in that
> case!) you should _always_ check of the return value after opening a
> file.
> 
> Hope this helps!
> 
> --
> Tom Phoenix           http://www.teleport.com/~rootbeer/
> rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
> Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
>               Ask me about Perl trainings!


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

Date: Thu, 02 Oct 1997 20:22:47 -0400
From: Robbin Carlson <robbin@interactive.-not-.net>
Subject: nmake not making
Message-Id: <34343AD7.7911E9EA@interactive.-not-.net>

I'm trying to build perl 5.004_1 on NT 4.0 with VC 5.0.  I'm guessing
that the config.h file gets modified and triggers nmake to start over.
When it starts over it again changes config.h which causes it to start
again.  I let it go for an hour but it continues to build miniperl over
and over.

Here's a snippet:

        cl.exe -c -nologo -W3 -I.\include -I. -I.. -DWIN32 -D_CONSOLE
-DPERLDLL
 -Od -MD -DNDEBUG -Fowin32sck.obj win32sck.c
win32sck.c
        link.exe -subsystem:console -out:..\miniperl.exe
@C:\TEMP\nma00113.
   Creating library ..\miniperl.lib and object ..\miniperl.exp
        ..\miniperl.exe -I..\lib config_sh.PL "INST_DRV=c:"
"INST_TOP=c:\perl"
"cc=cl.exe" "ccflags=-MD -DWIN32"  "cf_email=" "libs=oldnames.lib
kernel32.lib u
ser32.lib gdi32.lib  winspool.lib comdlg32.lib advapi32.lib shell32.lib
ole32.li
b  oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib
version.lib
 odbc32.lib odbccp32.lib"  "libpth=C:\Program Files\DevStudio\VC\lib"
"libc=msvc
rt.lib"  config.w32 > ..\config.sh
        cd .. && miniperl configpm
        if exist lib\* xcopy /f /r /i /e /d lib\*.* ..\lib\
        xcopy /f /r /i /d ..\*.h ..\lib\CORE\*.*
0 File(s) copied
        xcopy /f /r /i /d *.h ..\lib\CORE\*.*
0 File(s) copied
        xcopy /f /r /i /e /d include ..\lib\CORE\*.*
0 File(s) copied
        ..\miniperl.exe -I..\lib config_h.PL || nmake -nologo CCTYPE=
RUNTIME=-
MD CFG= ..\lib\Config.pm
config.h has changed
        cl.exe -c -nologo -W3 -I.\include -I. -I.. -DWIN32 -D_CONSOLE
-DPERLDLL
 -Od -MD -DNDEBUG -Fo..\miniperlmain.obj ..\miniperlmain.c
miniperlmain.c


I tried removing config.h from the dependencies list and it got much
further but when it got to the Socket code I get the following:

        cl.exe -c -nologo -W3 -I.\include -I. -I.. -DWIN32 -D_CONSOLE
-DPERLDLL
 -Od -MD -DNDEBUG -Foperlglob.obj perlglob.c
perlglob.c
        link.exe -nologo oldnames.lib kernel32.lib user32.lib gdi32.lib
winspoo
l.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib  oleaut32.lib
netapi32.lib
 uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib odbc32.lib
odbccp32.lib -re
lease -machine:I386 -out:..\perlglob.exe -subsystem:console perlglob.obj
setargv
 .obj
        cd ..\ext\Socket
        ..\..\miniperl -I..\..\lib Makefile.PL INSTALLDIRS=perl
Writing Makefile for Socket
        nmake -nologo
"Makefile out-of-date with respect to Makefile.PL"
"Cleaning current config before rebuilding Makefile..."
        NMAKE -f Makefile.old clean > NUL || rem

Microsoft (R) Program Maintenance Utility   Version 1.62.7022
Copyright (C) Microsoft Corp 1988-1997. All rights reserved.

        ..\..\miniperl "-I..\..\lib" "-I..\..\lib" Makefile.PL
"INSTALLDIRS=perl
"
Writing Makefile for Socket
"==> Your Makefile has been rebuilt. <=="
"==> Please rerun the make command.  <=="
        false
The name specified is not recognized as an
internal or external command, operable program or batch file.
NMAKE : fatal error U1077: 'false' : return code '0x1'
Stop.
NMAKE : fatal error U1077: '"C:\Program
Files\DevStudio\VC\BIN\NMAKE.EXE"' : return code '0x2'
Stop.


So I run it again and get the same results.  I bet I did something
wrong.  I did run the attribute command to undo any readonly flags.

Sign me Frustrated,
Robbin
robbin@interactive.net



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

Date: Thu, 02 Oct 1997 15:30:56 -0700
From: "Lance Bond" <lanceb@microsoft.com>
Subject: Re: NT 4 and PERL
Message-Id: <01bccf82$73fe6040$5cd2379d@bond-mosama>

The virtual directory (defined in IIS) where your perl script lives must
have execute permissions or the script will be passed to the browser as
text.

Lance

Matt <mrc@pressroom.com> wrote in article
<01bccecd$0cad6900$198345c6@nt1>...
> I need help with something. 
> 
> I have NT 4.0 running IIS 3.0 and PERL, the latest build.  Everytime I
try
> to execute a pl file in a html document, the browser tries to download
the
> script.  The registry is perfect, I think.  I check all the settings that
> were in the FAQ.  
> 
> It would be cool if someone could help we with this.
> 
> thanks
> 
> 
> 


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

Date: 2 Oct 1997 18:15:01 -0700
From: Kevin Johnson <kjj@pobox.com>
Subject: Re: Number of Emails?
Message-Id: <m2oh57fxyh.fsf@pobox.com>

mickeyc@linc.cis.upenn.edu (R Chandrasekar (Mickey)) writes:
> brian d foy (comdog@computerdog.com) wrote:
> : so what happens with "From"'s embedded in the email text and happen to
> : be right after an $INPUT_RECORD_SEPARATOR?  $count will only be the 
> : greatest lower bound - not necessarily the number of email messages.

> Mailers are supposed to detect From's at the start of records
> in text and change them, usually to >From.

In some cases, the Content-Length field is used to allow /^From / in
message bodies without escaping it.

-- 
thx,
kjj@pobox.com   http://www.pobox.com/~kjj/


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

Date: 2 Oct 1997 18:36:00 -0700
From: Kevin Johnson <kjj@pobox.com>
Subject: Re: Number of Emails?
Message-Id: <m2n2krfwzf.fsf@pobox.com>

"Spencer Alewel" <salewel@ncfcomm.com> writes:
> I'm just starting to learn Perl and I was wondering if someone could pass
> some hints on as to how to count the number of emails that a particular
> individual or account has.

The correct answer is: 'It depends'.

Your environment might be simple enough that what I'm describing below
might seem like overkill, but it's a fairly accurate description of
the general problem.

The first problem is that you first need to know where all of the mail
folders for a particular user are stored.

First, there's the matter of a user's inbox.  Depending on the flavor
of unix (maybe that's an invalid assumption), it could be in
/usr/mail, /usr/spool/mail, /var/spool/mail, or even in their home
directory, or it could be somewhere totally different.

Then you have the question, 'Where are the other folders for a user
stored'.  Since this folder directory location is typically a
parameter that is configurable in the user's mail client package, it
could be anywhere the user has permission to write to, and it could be
named just about anything.  The most common location is probably a
Mail directory in the user's home directory.

Onto the messages themselves.

First there's the issue of what format the folders are in.  The most
common one is the traditional mailbox format that most have come to
love and hate.  There are other ones though.  Some of the other ones
that come to mind are MH, qmail, cyrus, tenex, mbx, but there are
others.

If you are talking about a traditional unix mailbox file, then a
simple count of all the lines that start with 'From ' will give the
number of messages in the folder.  However, if the folder uses the
Content-Length field, then /^From / can be anywhere in the message
bodies.  If that's the case, then a smarter routine is called for
because it eneds take the value of the Content-Length field and skip
forward that amount to find the next message.

The other folder formats have other ways of the storing messages, so
it varies from format to format.

In your situation, you might be able to ignore some of the variety
I've described.  Your mileage may vary.

In you run across it, I have a Mail::Folder module in CPAN that reads
a few folder format.  It's not very fast, so it probably isn't a good
tool to use for merely counting the number of messages in a file.  It
can give you the message count for a folder it has open, but opening
folders isn't very fast currently.  I've added a todo to include the
ability to talle messages in folders that it doesn't have open.  I
have no idea when I'll add the feature though.

-- 
thx,
kjj@pobox.com   http://www.pobox.com/~kjj/


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

Date: 3 Oct 1997 00:24:20 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Performing Subroutines from a string of text
Message-Id: <611dvk$fv1@news-central.tiac.net>

In article <875832678.25592@dejanews.com>,  <ads@websp.com> wrote:
>Does anyone know how to perform subroutines from a string of text?  This
>is what I am trying to do:
>
>I have a string that is : delimited.  For example:
>
>text a b c:next text:some more text:RQCVF
>
>The only thing I care about is the last field.  What I want to do is have
>some sort of if statement that (after doing a split -
>($parta,$partb,$partc,$partd) = split /:/, $string;) checks to see what
>letters are in $partd and then if there is a "R" it runs a certain
>subroutine, if there is a Q it runs a different subroutine.  I could have
>26 different subroutines and any combination would run only the ones
>specified.  If I listed 1, it would only run the one subroutine it
>corresponded to.  If I had 26, it would do all 26.  I hope this is clear.

If you already have the last field in the variable $partd then the most
direct way of doing this might seem to be

  if ($partd =~ /A/) {
    &routineForA;
  }

  if ($partd =~ /B/) {
    &routineForB;
  }

  etc.

It's possible to use if (index ($partd, 'A') >= 0) to see if $partd
contains 'A' as long as $[ is still 0, its default value.

You could build a dispatch table containing a mapping of letters to
routines e.g.

  $dispatch = (
     'A', 'routineForA',
     'B', 'routineForB',
     ...
  );

  foreach $char (split (//, $partd)) {
    $routine = $dispatch{$char};
    &$routine () if defined ($routine) && defined (&$routine);
  }

might be one way of marching through $partd a character at a time and
calling the appropriate routine.  Perl 5.xxx has the ability to store
references to code as the values in an associative array.  This method
would call the routines in an order determined by the order of the
characters in $partd.

The code above is untestetd, but I hope that it gives you some ideas.

Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Fri, 3 Oct 1997 00:42:31 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Performing Subroutines from a string of text
Message-Id: <ebohlmanEHG9yv.3nv@netcom.com>

ads@websp.com wrote:

: text a b c:next text:some more text:RQCVF

: The only thing I care about is the last field.  What I want to do is have
: some sort of if statement that (after doing a split -
: ($parta,$partb,$partc,$partd) = split /:/, $string;) checks to see what
: letters are in $partd and then if there is a "R" it runs a certain
: subroutine, if there is a Q it runs a different subroutine.  I could have
: 26 different subroutines and any combination would run only the ones
: specified.  If I listed 1, it would only run the one subroutine it
: corresponded to.  If I had 26, it would do all 26.  I hope this is clear.

Create a hash whose keys are the letters and whose values are references 
to the corresponding subroutines (if they're short, you can "inline" them 
with the anonymous subroutine composer).



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

Date: Thu, 02 Oct 1997 23:55:42 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Sarah Chase-Kruszewski <sarahck@planet.eon.net>
Subject: Re: PERL 5.003 and the _STDC_ variable
Message-Id: <34346CBE.37F6C528@mail.earthlink.net>

[posted & mailed]

> I'm installing and it claims that I need to compile Perl 5.003 such that
> _STDC_ is defined.  I can't see in
> the Perl distribution where I'm supposed to define _STDC_.

Hmm.  That seems a bit odd to me-- what compiler are you using?  In any
event, what it's asking you to do is re-configure perl, and when
Configure asks you for any extra flags to pass to cc, add '-D_STDC_'.
Or you could just add that to the 'ccflags' line in config.sh and run
'sh Configure -S' followed by the make.
Benjamin Holzman



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

Date: Fri, 03 Oct 1997 02:54:53 +0100
From: Emil Granstrom <emil.granstrom@era.ericsson.se>
Subject: rmdir and rmtree not working.
Message-Id: <3434506C.94AAEA6@era.ericsson.se>

Hi !

Can anyone help me ?
I am unable to remove a directory created with mkpath from the File
module.
	mkpath($Mydir);
	 ..
         .. 
	rmtree($Mydir);

rmtree removes all files in the directory but fails to remove the
directory itself.

I have tried to remove it with rmdir as well but this also fails.

Help please.

Best Regards
	Emil


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

Date: Thu, 02 Oct 1997 23:32:16 -0400
From: Ignacio Bustamante <IggieBee@worldnet.att.net>
Subject: Re: Using Perl Format
Message-Id: <611oe3$817@bgtnsc03.worldnet.att.net>

Eike,

Thanks for you rsponse,
> 
> Take a look at the 'perlform' manual page. It contains sample code
> showing how to do this ("Accessing Formatting Internals").
> 

I found two examples (as you pointed out), however, I am totally unable
to exeut them on a scrip. Could you please help me on this?

Example 1:

    $str = formline <<'END', 1,2,3;
    @<<<  @|||  @>>>
    END

    print "Wow, I just stored `$^A' in the accumulator!\n";

Example 2:

    use Carp;
    sub swrite {
        croak "usage: swrite PICTURE ARGS" unless @_;
        my $format = shift;
        $^A = "";
        formline($format,@_);
        return $^A;
    } 

    $string = swrite(<<'END', 1, 2, 3);
 Check me out
 @<<<  @|||  @>>>
 END
    print $string;

I know, my lack of knowledge on this is "pathetic", but I haven't been
able to find specific examples for this, on any of the books, and
manuals I have researched.

TIA,

Ignacio


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

Date: 3 Oct 1997 03:23:16 GMT
From: n1868683@droid.student.fit.qut.edu.au (Kenneth Blinco)
Subject: using split on URL's??
Message-Id: <611of4$s9d@dove.qut.edu.au>

hello,

I'm trying to write a utility which process log files for a proxy server (www).
my problem is this:

how do i split up a URL to to extract just the site name (without the path for the page being accessed.  i.e.

		http://www.someplace.com/index.html

how do i use split on this to just get www.someplace.com.
when i try to use the / as a pattern to search for i get compilation errors (when using split). (e.g. split(///, string) doesn't work).

any ideas???
thanks

ken 
--



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

Date: 03 Oct 1997 06:01:22 +0200
From: Gisle Aas <aas@sn.no>
Subject: Re: using split on URL's??
Message-Id: <m3zporpka5.fsf@furu.g.aas.no>

n1868683@droid.student.fit.qut.edu.au (Kenneth Blinco) writes:

> how do i split up a URL to to extract just the site name (without the path for the page being accessed.  i.e.
> 
> 		http://www.someplace.com/index.html
> 
> how do i use split on this to just get www.someplace.com.
> when i try to use the / as a pattern to search for i get compilation errors (when using split). (e.g. split(///, string) doesn't work).
> 
> any ideas???

How about:

  use URI::URL;
  $host = url("http://www.someplace.com/index.html")->host;

but this probably runs much faster:

  $_ = "http://www.someplace.com/index.html";
  ($host) = m,http://([^:/]+),;


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

Date: 03 Oct 1997 02:14:33 +0200
From: Gisle Aas <aas@sn.no>
Subject: XPUSHi
Message-Id: <m367rfr9cm.fsf@furu.g.aas.no>

I can't get XPUSHi (or PUSHi/PUSHn) to work in the PPCODE section of
an XSUB.  The compiler gives the following error message:

  Foo.xs: In function `XS_Foo_foo':
  Foo.xs:17: `targ' undeclared (first use this function)
  Foo.xs:17: (Each undeclared identifier is reported only once
  Foo.xs:17: for each function it appears in.)

All the examples I have found use XPUSHs(sv_2mortal(newSViv(int)))
instead, so is XPUSHi supposed to work?  I even tried adding dTARG to
the code but that only gave me a core dump.  I am using perl5.004.

void
foo()
   PPCODE:
      XPUSHi(42);  /* gives `targ' undeclared */
      XPUSHs(sv_2mortal( newSViv(42)));  /* ok */

Regards,
Gisle


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

Date: Thu, 02 Oct 1997 20:07:30 -0700
From: Kaylene Thaler <thalerk@vrinet.com>
Subject: XS & variable-length
Message-Id: <34346172.2E27@vrinet.com>

I am trying to use perl to access a C function, and have been
almost successful.  The prototype for the C function is:

extern void mlog(int severity, int msg_num, ...)

It uses the va_list, va_start, etc to deal with the unknown
number of parameters.

I have managed to create the dynamic library with the code, and the
 .xs file has the following:


void
mlog(severity, msg_num, ...)
        int severity
        int msg_num

(and that's it)

How do I get the additional arguments passed to my C function?  It seems
to be passing the 2 integer fields without problems, but not getting
any of the unknown number of others.

Kaylene Thaler


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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 V8 Issue 1118
**************************************

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