[12733] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 143 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 14 14:17:15 1999

Date: Wed, 14 Jul 1999 11:05:12 -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           Wed, 14 Jul 1999     Volume: 9 Number: 143

Today's topics:
    Re: Anybody know how to to this? <swiftkid@bigfoot.com>
    Re: Anybody know how to to this? <toby@venice.cas.utk.edu>
        bug in vars.pm? <john@dlugosz.com>
    Re: C-like #define macros in Perl (Saku Ytti)
    Re: C-like #define macros in Perl <bivey@teamdev.com>
        Cgi question <mlopresti@bigfoot.com>
        Como ler un directorio... <rcortes@alumnos.utfsm.cl>
    Re: Como ler un directorio... (Saku Ytti)
        Database Question <jeremy140@hotmail.com>
    Re: document converter (Sitaram Chamarty)
        Encrypt/decrypt for Win32? laith1@my-deja.com
        eval() risky? (Sami Rosenblad)
        Generating Passwords <swiftkid@bigfoot.com>
    Re: getting the virtual host info... <pleduc@ca.ibm.com>
    Re: Getting very irregular single 'name' field into fir (Sitaram Chamarty)
    Re: Getting very irregular single 'name' field into fir (Sitaram Chamarty)
        HELP: FileHandle usage fails <brannon@quake.usc.edu>
    Re: Linux - Apache - Perl (JT)
    Re: Linux - Apache - Perl (I R A Aggie)
    Re: newbie question: how put files from dir in array <swiftkid@bigfoot.com>
    Re: newbie question: how put files from dir in array <stampes@xilinx.com>
    Re: Not able to write to file <swiftkid@bigfoot.com>
    Re: Not able to write to file (I R A Aggie)
    Re: Premature end of script headers? (Bart Lateur)
    Re: Premature end of script headers? (Bart Lateur)
    Re: Print an array into a table <leejk@cat.com>
        Rebol and Perl <anonymous@web.remarq.com>
        Secure UserAgent with Perl? <zzoo@zzoo.hostings.com>
    Re: Test if a File Exists? (Bart Lateur)
    Re: Test if a File Exists? <steff.w@gordian.co.uk>
        Using variable to modify regexp <snow@flinet.com>
    Re: Using variable to modify regexp <uri@sysarch.com>
    Re: What's faster: GDBM or Storable <stupid@pobox.com>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Wed, 14 Jul 1999 20:43:21 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Anybody know how to to this?
Message-Id: <7mjego$2a07@news.cyber.net.pk>

: So what I want to do is to replace all the separator (newline, carriage
: return or whatever) in the variable by <BR> using regular expressions.
:
: Here the problem arises:
: - what is that separator? When I use print to display the variable in UX
: shell, everything is fine, so there must be a sort of a separator at the
: end of each line

Yes, thats \n

: - How do I replace this separator with <BR> ?

If thats a scalar:
$mystring =~ s/\n/<br>\n/g;

If thats an array:
print join "\n" , @array;




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

Date: Wed, 14 Jul 1999 12:22:23 -0400
From: toby <toby@venice.cas.utk.edu>
Subject: Re: Anybody know how to to this?
Message-Id: <378CB93E.C41290B4@venice.cas.utk.edu>

I think you may want to split the variable into chunks and put them into an
array:

@blah = split /somedelimter/, $text;

foreach $blah (@blah) {

print $blah . '<br>';


}



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

Date: Wed, 14 Jul 1999 13:00:22 -0500
From: "John M. Dlugosz" <john@dlugosz.com>
Subject: bug in vars.pm?
Message-Id: <7B789B07FD525CC5.711B2B3B859894B3.B1B39525D462208B@lp.airnews.net>

In the standard pragmatic module vars.pm, I see:

    if ($sym =~ tr/A-Za-Z_0-9//c) {

now since the ordinal of 'a' is greater than the ordinal of 'Z' (lower-case
letters follow capitals), the range a-Z is empty.  From the context, I take
suppose this should have been a-z, not a-Z, in an effort to check for
strings containing anything that's not a letter number or underscore.

Also, what is the benifit of using tr/// with an empty replacement string
(which does nothing but returns a count of chars matching the source string)
instead of the more common s// ?  Is this a technique we should all be
using?

(I have ActivePerl build 518)

--John




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

Date: 14 Jul 1999 16:05:39 GMT
From: saku.news@ytti.net (Saku Ytti)
Subject: Re: C-like #define macros in Perl
Message-Id: <slrn7opdar.ghk.saku.news@ytti.net>

On Wed, 14 Jul 1999 15:38:24 GMT, TM Lehto <hiwi1krg@iitb.fhg.de> wrote:

>Can I define macros like in C language?

You can run script through C preprocessor before compilation. -P if I
remember correctly.

-- 
	--ytti - ::3585:0512:1378


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

Date: 14 Jul 1999 17:08:33 GMT
From: "William" <bivey@teamdev.com>
Subject: Re: C-like #define macros in Perl
Message-Id: <01bece1b$83a637e0$583c08cf@bill.jump.net>

TM Lehto <hiwi1krg@iitb.fhg.de> wrote in article
<378ca933.80071166@iitb>...
> I am trying to write a Perl script that can print messages in several
> languages. I have put all text strings to separate file (lang.pl). The
> text strings have parts that change in run-time. When I try to print
> them from my script, the variable part of the string either doesn't
> show at all or shows as "This is directory: $working_dir" depending of
> which combination of single and double quotes I use in every place.
> 
[...] 
> --- my non-working script ---
> #!/usr/local/bin/perl -w
> require 'lang.pl'; 
> $working_dir = 'some/directory';
> print $finmsg;
> print $engmsg;
> 
> 
> --- lang.pl ---
> $finmsg  = "Tämä on hakemisto: $working_dir"; # in finnish
> $engmsg  = "This is directory: $working_dir"; # in some other language

You're problem is that the strings in lang.pl are being interpolated
before the included variables are defined. It's doing exactly what
you told it to do, which is one of the worst characteristics of
computer languages today :-)

I bet this will look better:

#!/usr/local/bin/perl -w
$working_dir = 'some/directory';
require 'lang.pl'; 
print $finmsg;
print $engmsg;

Now the code in lang.pl should see something worth interpolating.
-Wm


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

Date: Wed, 14 Jul 1999 13:39:26 -0400
From: matt <mlopresti@bigfoot.com>
Subject: Cgi question
Message-Id: <378CCB4E.2785373F@bigfoot.com>

I am using perl build 517 for win32 and I'm also using Personal Web
Server to test my scripts. I am running into a problem when I call the
script from the form I am getting the following error:
405 Method Not Allowed

The method specified in the Request Line is not allowed for the resource
identified by the request. Please ensure that you have the proper MIME
type set up for the
resource you are requesting.
my script is test a script an d looks like:
print "Content-type: text/plain","\n\n";
I have also tried  .....:text/html, got the same results

print "TEST";
Any ideas?
I have used PWS before for a perl BB and had no problems.
-Matt





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

Date: Wed, 14 Jul 1999 13:41:13 -0400
From: Rodrigo <rcortes@alumnos.utfsm.cl>
Subject: Como ler un directorio...
Message-Id: <378CCBB9.43B3C028@alumnos.utfsm.cl>

Se puede hacer en perl que un script lea un directorio y guarde en un
arreglo los nombres de todos los archivos que existen en dicho
directorio??
De ser asi... como se puede hacer???
Por favor envien sus respuestas a roco3d@softhome.net

Muchas gracias...

Rodrigo Cortes
ROCO3D
http://roco3d.cjb.net



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

Date: 14 Jul 1999 17:56:13 GMT
From: saku.news@ytti.net (Saku Ytti)
Subject: Re: Como ler un directorio...
Message-Id: <slrn7opjq6.i24.saku.news@ytti.net>

On Wed, 14 Jul 1999 13:41:13 -0400, Rodrigo <rcortes@alumnos.utfsm.cl> wrote:
>Se puede hacer en perl que un script lea un directorio y guarde en un
>arreglo los nombres de todos los archivos que existen en dicho
>directorio??
>De ser asi... como se puede hacer???
>Por favor envien sus respuestas a roco3d@softhome.net

Juu, se on verovappaatavyähykettä nykyään.

-- 
	--ytti - ::3585:0512:1378


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

Date: Wed, 14 Jul 1999 11:31:06 -0500
From: "Jeremy" <jeremy140@hotmail.com>
Subject: Database Question
Message-Id: <TT2j3.827$c81.4884@newsfeed.slurp.net>

Hello, All

Could someone please tell me if and how it is possible to access a secured
Access database (via a workgroup information file, system.mdw) with
Perl/CGI?  This will need to be a DSN-less connection.  Thanks!

Jeremy





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

Date: Wed, 14 Jul 1999 16:43:10 GMT
From: sitaram@diac.com (Sitaram Chamarty)
Subject: Re: document converter
Message-Id: <slrn7op93t.r54.sitaram@diac.com>

On Wed, 14 Jul 1999 01:56:21 -0700, Josh Suarez
<tortuga@leland.stanford.edu> wrote:
>I need a program which can convert word documents (and perhaps other
>formats) to text files, while retaining some indicator of which words
>were originally bold and italic.  The program needs to run on unix.  Has
>anyone seen something like this?  A perl script perhaps?
>Thanks,

A perl module exists - I believe it is called OLE::Storage - which
contains ancillary utils to read .doc and .xls files.  I have,
however, had no luck with it (I really need to find some time to
submit a proper bug report!)

Meanwhile, there is another tool called "MSwordView" that is not
written in Perl, that purports to do a better job - translating
into HTML instead of plain text, including preserving tables etc.

I did use it a long time ago, though not recently, and it works
pretty well:

    http://www.csn.ul.ie/~caolan/docs/MSWordView.html

HTH.


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

Date: Wed, 14 Jul 1999 17:00:06 GMT
From: laith1@my-deja.com
Subject: Encrypt/decrypt for Win32?
Message-Id: <7mifmc$lne$1@nnrp1.deja.com>

Hello,

I am using Perl 5.005_03 on NT 4 sp4 and would
like to know if there is a Win32 module designed
for encrypting/decrypting strings contained in a
file.

This file would contain the encrypted passwords
for several users (eg privileged Oracle 7.3
users), which I can then decrypt, assign to a
variable, and use the variable in the call to
sqlplus or svrmgr, rather than the plain text
password.

I know there is meant to be a Win32::DES module,
but the link to this on perl.com is broken, and I
can't seem to find it anywhere else.

Thanks

Laith Suheimat
Middlesex University


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


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

Date: Wed, 14 Jul 1999 19:52:21 +0300
From: blade@leela.janton.fi (Sami Rosenblad)
Subject: eval() risky?
Message-Id: <blade-1407991952210001@durandal.janton.fi>

I read the perlsec manpage for hints about eval and Taint checking, but
didn't find anything appropriate. Here's my problem:

I have a CGI script that handles a dynamic forum with threaded reading,
submitting, and searching facilities. Now, the search engine I wrote could
be described as a quick hack, because it basicly does this:

# this is from the form decoding routine

   if (defined $FORM{keyword}) {
      $SEARCH = $FORM{keyword};
      for ($SEARCH) {
         s#(\w+)#/$1/i#g;
         s#/and/i#and#gi;
         s#/or/i#or#gi;
         s#/not/i#not#gi;
      }
   }

Basicly, the substitutions catch all words and change them into matching
operators, foo would become /foo/i, but 'and', 'or', and 'not' will remain
untouched. There's surely a better way to write this, but I told you it's
a quick hack. (:

Now, the global variable $SEARCH is the actual string to eval() in the
search routine, shown here:

         push @{$thread{$thre}}, $id if $fora and eval $SEARCH;

%thread is a hash of arrays used to thread the messages, $id is the
message being processed, and $fora is a boolean that is true if the
message satisfies other search criteria than string search.

So, $SEARCH is eval()'d, and may contain TAINTED data, right? Is there a
(remote) possibility that somebody skilled enough could write a search
string that would pass the initial substitutions and access the command
shell or something like that? If so, how can I prevent it?

eval() seems so powerful in an application like this, because I'm getting
logical operators and parentheses "for free". Surely beats writing a
parser of my own for such a simple task.

Help appreciated. Thanks in advance.

-- 
Sami Rosenblad -- blade@leela.janton.fi -- running linux since 1999


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

Date: Wed, 14 Jul 1999 20:34:11 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Generating Passwords
Message-Id: <7mjdvj$3o21@news.cyber.net.pk>

Hi,

I tried to make it as short as I could.... any other optimization int it?

{
  ( $_ = chr rand 123 and /[A-Z0-9]/i && $pass !~ $_ and $pass .= $_ ) ||
redo
    for 1 .. 8
}


generates 8 character passwords, which are not repeated... and contains only
A-Z (lower and upper) and 0-9 ... and not underscore, dash etc.

--
Faisal Nasim (the Whiz Kid)
Web: http://wss.hypermart.net/
FAX: (815) 846-2877





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

Date: Wed, 14 Jul 1999 13:40:51 -0400
From: Paul Leduc <pleduc@ca.ibm.com>
Subject: Re: getting the virtual host info...
Message-Id: <378CCBA2.D4D4CB1F@ca.ibm.com>

thanks!  that did it.

brian d foy wrote:

>
> the host is the same, so it should return the same host each time.
>
> you'll have to add port information - $ENV{SERVER_PORT} or whatever
> your server does with that info.
>



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

Date: Wed, 14 Jul 1999 16:43:12 GMT
From: sitaram@diac.com (Sitaram Chamarty)
Subject: Re: Getting very irregular single 'name' field into first/last name for credit card gateway -- what hit rate is possible?
Message-Id: <slrn7op9oe.r54.sitaram@diac.com>

On Tue, 13 Jul 1999 21:52:03 -0500, XFACTOR <X@FACTOR.COM> wrote:
>>*plonk*
>>Abigail
>>   **plonk**
>>Tad McClellan
>>*plonk*
>>Martien
>
>What a crew of pompous asses.  Threatening to killfile someone for such

On the contrary, if he got plonked by even Tad, he deserves it!
Tad is one of the more patient guys in this group, usually
unfailingly polite and helpful.  So is Martien, and Abigail is at
least funny in her responses.

As for the actual point they were making[1] - I have to deal with people who
do that everyday at my work, and I ABSOLUTELY HATE it.  With my cow-orkers I
have no choice, but I'll be darned if I'll tolerate it from usenet.  And a
Perl group too.  I haven't gotten to killfiling such posts, but these folks
reply to far, far, more posts than I do, and they have every right to be
selective about what they tolerate.

And if you want to learn Perl, you'll have to deal with it.  It's not as if
they're making arbitrary rules - there's usually a good reason behind their
rants.

Sitaram

[1] IIRC - it was about posting in the "MS Exchange" reply style - where the
"quoted" text appears indented after your response.


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

Date: Wed, 14 Jul 1999 16:43:14 GMT
From: sitaram@diac.com (Sitaram Chamarty)
Subject: Re: Getting very irregular single 'name' field into first/last name for credit card gateway -- what hit rate is possible?
Message-Id: <slrn7opaf5.r5p.sitaram@diac.com>

On Wed, 14 Jul 1999 18:42:06 +1000, Brad Long <bjl@uq.net.au> wrote:
>Basically, I agree that Abigail is a problem!

Yes.  Looking forward to her wry humour [1] is wasting a lot of my
time too :-)

Sitaram

[1] for example, in <slrn7oodgn.h7.abigail@alexandra.delanet.com>:

    That's very strange. Your 12 line program gets uninitialized variables
    on lines 29 and 32!

    What can we say. It's probably solar flares. It should pass in a year
    or 3.


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

Date: 14 Jul 1999 09:09:59 -0700
From: tbrannon <brannon@quake.usc.edu>
Subject: HELP: FileHandle usage fails
Message-Id: <ysizemib9pre.fsf@nunki.usc.edu>


When running the line:

	    print <$fh[$i]>;

I get the error:

sh: -c: line 1: syntax error near unexpected token `IO::File=GLOB(0'
sh: -c: line 1: `echo IO::File=GLOB(0x824b88c)|tr -s '	'
'\012\012\012\012''



#!/usr/bin/perl -d

use IO::File;

if ($#ARGV != 1) {
  die "Usage: compare-tunings.pl tuning-file-a tuning-file-b\n";
}

$file[0]=shift;
$file[1]=shift;

open F, "/tmp/test";

for $i (0..1) {


  $fh[$i]=new IO::File;
  if ($fh[$i]->open("< $file[$i]")) {
    print <$fh[$i]>;
  }

  if (!defined $fh[$i]) {
    die "FileHandle $i not defined: $!\n";
  }

  while (<$fh[$i]>) {
    print $_;
  }

}



-- 
Terrence Brannon  * brannon@lnc.usc.edu * http://lnc.usc.edu/~brannon
		       (213) 740-3397 [office]


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

Date: Wed, 14 Jul 1999 16:25:24 GMT
From: jett1not@homedot.com (JT)
Subject: Re: Linux - Apache - Perl
Message-Id: <378cb7d5.1553729@24.2.0.71>

On 13 Jul 1999 01:30:44 -0500, abigail@delanet.com (Abigail) wrote:

>I wonder what's worse. People asking totally off topic questions, or
>people answering off-topic questions, rewarding the posters of off topic
>questions.
>
>It's like tourists feeding the bears in a national park. They become a
>problem. 
>
>
>
>
>Abigail

Hmm.. Good point!
I've noticed that you answer quite a lot of "off-topic" questions.
Maybe you should consider passing them by if you have nothing of any
real value to contribute. We are not all gurus, in fact as a Perl
"newbie" I learn a lot from even the simplest questions.

Lighten up, please. Not everyone is as perfect as you...
-JT

Remove the "not" and delete the "dot" to reply
jett1not@homedot.com


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

Date: 14 Jul 1999 17:13:35 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Linux - Apache - Perl
Message-Id: <slrn7ophe9.3rn.fl_aggie@thepentagon.com>

On Wed, 14 Jul 1999 16:25:24 GMT, JT <jett1not@homedot.com>, in
<378cb7d5.1553729@24.2.0.71> wrote:

+ We are not all gurus, in fact as a Perl
+ "newbie" I learn a lot from even the simplest questions.

Ok, how do I fix my Saturn? that would be the motor vehicle, not the
game station. Can you learn any perl from that question?

How much perl did you learn from the original question? from what I
was able to understand, the problem wasn't perl, but that some bash
scripts where attempting to masquerade as perl scripts.

I guess you learned that bash != perl...

+ Lighten up, please. Not everyone is as perfect as you...

I'd suggest killfiles...

James


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

Date: Wed, 14 Jul 1999 20:36:58 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: newbie question: how put files from dir in array
Message-Id: <7mje4p$3o22@news.cyber.net.pk>

: Hi, I'm just learning perl and wondering how I could put all the file
names
: of a certain dir. in an array ?
: Can somebody show me an example ?

opendir MYDIR , "/etc/yourdir" or die "error: $!";
    @files = readdir MYDIR;
close MYDIR;

OR

@files = </etc/yourdir/*>;




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

Date: 14 Jul 1999 15:52:43 GMT
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: newbie question: how put files from dir in array
Message-Id: <7mibob$9q1@courier.xilinx.com>

iLs <iLs@cyberdude.com> wrote:
: Hi, I'm just learning perl and wondering how I could put all the file names
: of a certain dir. in an array ?

An examination of the perl documentation will lead you to the
opendir, readdir and closedir functions.  The readdir documentation
contains the following:

=item readdir DIRHANDLE

Returns the next directory entry for a directory opened by C<opendir()>.
If used in list context, returns all the rest of the entries in the
directory.  If there are no more entries, returns an undefined value in
scalar context or a null list in list context.

If you're planning to filetest the return values out of a C<readdir()>, you'd
better prepend the directory in question.  Otherwise, because we didn't
C<chdir()> there, it would have been testing the wrong file.

    opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
    @dots = grep { /^\./ && -f "$some_dir/$_" } readdir(DIR);
    closedir DIR;


-- 
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


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

Date: Wed, 14 Jul 1999 20:44:47 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Not able to write to file
Message-Id: <7mjejg$2a08@news.cyber.net.pk>

: hello. yes, i am a newbie to perl.  i am playing with substr and tr to
: alter substrings from a said file, say test.txt.  well, i have no
: problem opening the file, making the changes *temporarily*, but once
: the script ends, the file remains unchanged.  i know it is opening the
: file correctly because i tell it to print output and it shows me my
: changes.  i will post the actual script when i get to work if it
: helps.  thanks.

You should know that when you read a file into a variable the changes
on the variable will not directly affect the file, you should open the file
again or with +< in the first place, and print the scalar/array to it.




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

Date: 14 Jul 1999 17:15:17 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Not able to write to file
Message-Id: <slrn7ophhf.3rn.fl_aggie@thepentagon.com>

On Wed, 14 Jul 1999 09:50:38 -0500, Marshall Culpepper
<marshalc@NO-SPAMamericasm01.nt.com>, in
<378CA3BE.3136080F@NO-SPAMamericasm01.nt.com> wrote:

+ you probably forgot to write the saved changes to the file..

+ print FILE $changes

Hmmm, yes, but I bet he's also forgetting to check the open() status.

James - open(IN,'some_file') or die "some_file failed: $!";


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

Date: Wed, 14 Jul 1999 16:25:47 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Premature end of script headers?
Message-Id: <378db95a.8997319@news.skynet.be>

Patrick Tully wrote:

>    I'm getting this error mesg, and don't know how to fix this problem.
>Can anyone help me with this?  

Typically, I'd say, there's a syntax error in the script (there isn't, I
checked), the shebang line is wrong ("#!/usr/sbin/perl5", isthat the
correct path?), or maybe you've uploaded it in binary. Try ASCII
instead.

>This is the address to the program i am tring
>to run:
>    http://www.liquidwire.net/dev/passwd/sample.cgi

What does the log say? That nice site gives you easy access to your log,
but not to us.

	Bart.


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

Date: Wed, 14 Jul 1999 16:27:24 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Premature end of script headers?
Message-Id: <378eba36.9217019@news.skynet.be>

Ooh, I was a little hasty. This doesn't look right:

	print "Content-type: text/html\n";

You need an empty line following that header. Add one more "\n".

	Bart.


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

Date: Wed, 14 Jul 1999 13:14:50 -0400
From: "Keith Lee" <leejk@cat.com>
Subject: Re: Print an array into a table
Message-Id: <7migin$nd9$1@ns1.cat.com>

Thanks,
That got me going in the direction I needed.

Tad McClellan <tadmc@metronet.com> wrote in message
news:kqpfm7.ikh.ln@magna.metronet.com...
> Keith Lee (leejk@cat.com) wrote:
>
> [snip code]
>
> : This works, but prints out the list in a table with 1 column. I want to
> : print out the list in a table 3 columns wide, and have the number of
rows
> : equal to whatever it takes. Is there some way to keep track of every
third
> : value in the array?
>
>
>    The modulus operator (%) can help with that.
>
>
> ------------------------------
> #!/usr/bin/perl -w
> use strict;
>
> my @names = qw(Fred Wilma Barney Betty Clinton Gore Bush Quayle Satan
Gates);
> for my $i ( 0..$#names ) {
>    my $remainder = $i % 3;
>    print "<tr>\n" if $remainder == 0;      # start of row
>
>    print "   <td>$names[$i]</td>\n";       # table cell
>
>    print "</tr>\n\n" if $remainder == 2;   # end of row
> }
> print "</tr>\n" unless $#names % 3 == 2;
> ------------------------------
>
>
> --
>     Tad McClellan                          SGML Consulting
>     tadmc@metronet.com                     Perl programming
>     Fort Worth, Texas




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

Date: Wed, 14 Jul 1999 08:38:35 -0800
From: Ashish Kadakia <anonymous@web.remarq.com>
Subject: Rebol and Perl
Message-Id: <931970317.13388@www2.remarq.com>

Hi, I just want to know if anyone has studied Rebol
language and done any programming which enhances the
programming in Perl?




**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****


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

Date: 14 Jul 1999 20:36:12 +0300
From: "Paul Slavic" <zzoo@zzoo.hostings.com>
Subject: Secure UserAgent with Perl?
Message-Id: <01bece17$342ff380$0903a8c0@server1>

Hi,

I need to connect to secure web server programmatically from Perl.
Is there any way to do it?
I tested LWP UserAgent module - it does not support "https" scheme.

-- 
Paul Slavic,
http://zzee.com


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

Date: Wed, 14 Jul 1999 16:18:23 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Test if a File Exists?
Message-Id: <378cb7f7.8641954@news.skynet.be>

Vice Admiral Acker wrote:

>How would I test if a file existed or not?

	open(FILE,">>filename");

Now it exists!    :-)

	Bart.


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

Date: Wed, 14 Jul 1999 18:02:23 +0100
From: Steff Watkins <steff.w@gordian.co.uk>
Subject: Re: Test if a File Exists?
Message-Id: <378CC29F.57EDDF08@gordian.co.uk>

Vice Admiral Acker wrote:
> 
> How would I test if a file existed or not?

Hi,

Use the '-f' (file exist) test as described in the 'perlfunc' manual pages.
Something like:

=============================================
  #!/usr/local/bin/perl

  $name='/name/to/file';

  if (-f $name) {
   print("File exists!\n");
  }
  else
  {
   print("File does not exists!!\n");
  }
=============================================

 ..but that is, of course, just one of the many ways that you can test for rhe
existance of a file in Perl!!! *grin*

Hope that helps,

Steff


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

Date: Wed, 14 Jul 1999 17:13:35 +0000
From: Bill Snow <snow@flinet.com>
Subject: Using variable to modify regexp
Message-Id: <378CC53F.4709CC50@flinet.com>

Is it possible to use a variable to modify a regexp?  I'm able to use a
variable ok between the slashes but if I try to use one at the end. It
does not work.  I've tried various combinations and looked at FAQ
without finding anything.

eg.


$mod = "i";  # want to ignore case

if ( /abc/$mod ) {
	do something
}



TIA


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

Date: 14 Jul 1999 13:44:47 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Using variable to modify regexp
Message-Id: <x7wvw3m8hc.fsf@home.sysarch.com>

>>>>> "BS" == Bill Snow <snow@flinet.com> writes:

this just to show the huddle masses out there what a good question and
answer should look like.

  BS> Is it possible to use a variable to modify a regexp?  I'm able to use a
  BS> variable ok between the slashes but if I try to use one at the end. It
  BS> does not work.  I've tried various combinations and looked at FAQ
  BS> without finding anything.

note how i quote only the relevent parts of the previous post and i put
my comments after each section i quote.

this is an intelligent and well worded question. he states his goal
immediately and then describes what he has tried that works and
fails. no code is needed here since his descriptions are apt. then he
states that he actually tried other solutions and did some research on
the problem.

  BS> $mod = "i";  # want to ignore case

  BS> if ( /abc/$mod ) {
  BS> 	do something
  BS> }

well a quick grep show the faq doesn't seem to mention internal modifiers.
but perlre covers it just fine.

     (?imsx)   One or more embedded pattern-match modifiers.
               This is particularly useful for patterns that are
               specified in a table somewhere, some of which want
               to be case sensitive, and some of which don't.
               The case insensitive ones need to include merely
               (?i) at the front of the pattern.  For example:


                   $pattern = "foobar";
                   if ( /$pattern/i )

                   # more flexible:

                   $pattern = "(?i)foobar";
                   if ( /$pattern/ )

  BS> TIA

and a polite signature with no bullshit about how tough life with perl
is or have mercy on us. just i a perl thing and i have worked on it
and i can't figure it out.

and he got a quoted section of the docs rather than an rtfm. he is
today's winner of the post and response of the day.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: Wed, 14 Jul 1999 13:33:51 -0400
From: Michael G Schwern <stupid@pobox.com>
To: alexmc@my-deja.com
Subject: Re: What's faster: GDBM or Storable
Message-Id: <140719991333519487%stupid@pobox.com>

[[ This message was both posted and mailed: see
   the "To," "Cc," and "Newsgroups" headers for details. ]]

In article <7mhpfm$egs$1@nnrp1.deja.com>, <alexmc@my-deja.com> wrote:

> In article <130719992239437576%stupid@pobox.com>,
>   Michael G Schwern <stupid@pobox.com> wrote:
> 
> > Now that I'm thinking, I'm going to send off some patches to Guru to
> > get MLDBM to select its defaults more intellegently.
> >
> 
> Thanks very much. I quite liked MLDBM when I have used it.
> It seemed much simpler than trying to deal with DBI and MySQL.
> I am surprised that more people don't use it...


Well, again, DBI and MLDBM do different things.

Something simple like this is well suited to MLDBM:

# Get a user's information from their user_id.
$user_info = $mldbm{$user_id};


But do anything more complicated and MLDBM's performance drops like a
rock.  For instance, finding all users who live in New York:

while(($user, $info) = each %mldbm) {
   push @nyers, $user if $info->{State} eq 'NY';
}

This is very slow with MLDBM.  Its just not built to do that.  However,
with DBI:

$sth = $dbh->prepare(<<"");
SELECT   ID
FROM     UserInfo
WHERE    State = ?

$sth->execute('NY');

while($row = $sth->fetch) { push @nyers, $row->[0] }

Its very quick (assuming State is indexed).


As most applications need both abilities (Looking information up
directly and searching) I tend to use DBI whenever possible over a DBM
file unless my feature set is very well known at the start.  The extra
complexity is worth it.

I've been toying for a while with the idea of writing DBD::DBM, a DBI
driver for DBM files, basically for writing prototype programs where
you don't want to bother setting up an SQL database so you fake it with
a DBM file and then later on transparently switch over to something
better.


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

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


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