[13417] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 827 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 17 05:07:24 1999

Date: Fri, 17 Sep 1999 02:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <937559110-v9-i827@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 17 Sep 1999     Volume: 9 Number: 827

Today's topics:
    Re: And the band played Waltzing Matilda (Alex Kamilewicz)
        cgi help <olli@fidata.fi>
        cgi not working soulierb@my-deja.com
    Re: CONTEST: Range Searching <rick.delaney@home.com>
    Re: CONTEST: Range Searching (Kevin Reid)
    Re: CONTEST: Range Searching (Ken Pizzini)
    Re: CONTEST: Range Searching <jamie@mccarthy.org>
    Re: CONTEST: Range Searching <nospam.newton@gmx.net>
    Re: CONTEST: Range Searching (Neko)
        CPAN modules for Windows <pandey@my-deja.com>
        Database retrieval of information using PERL <steve@interjize.com>
    Re: Encrypting (and decrypting) password <steve.button@nl.origin-it.com>
    Re: Encrypting (and decrypting) password <steve.button@nl.origin-it.com>
    Re: help! <sjohns17@uic.edu>
    Re: help: read only a char without echo? <nospam.newton@gmx.net>
        How to know modules of a installed version of perl <ivanb@lsi.upc.es>
    Re: how to produce a 'beep'? <nospam.newton@gmx.net>
        How to test for file Perl <resource@ERASEjps.net>
    Re: How to test for file Perl (Helgi Briem)
        Line chart <clousberg@voslogistics.com>
    Re: Making and using a DB. (Help!!!) <mattking@techie.com>
        optimizing execution speed (BLUESRIFT)
    Re: optimizing execution speed (Sam Holden)
    Re: Perl + ICQ (Greg Boug)
        PERL->mySQL steffi@mvi.de
    Re: unpack("%32C*", $text) andy_muscat@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 17 Sep 1999 09:55:48 +0200
From: manc0046@sable.ox.ac.uk (Alex Kamilewicz)
Subject: Re: And the band played Waltzing Matilda
Message-Id: <1dy6kxj.peq3c187ymjuN@max39.public.ox.ac.uk>

Excession <daccles@ozemail.com.au> wrote:

<snip>

You are _so_ unlike your self-styled namesake, it's almost ironic.

-- 
'There are no stupid questions, only stupid people.'

manc0046@sable.ox.ac.uk - http://users.ox.ac.uk/~manc0046


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

Date: Fri, 17 Sep 1999 08:03:57 GMT
From: Olli Aalto <olli@fidata.fi>
Subject: cgi help
Message-Id: <37E1F6EF.8F8D1113@fidata.fi>

How do I make my script update the client browser
every second?

Here's my script:

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

use Date::Calc qw(Delta_DHMS Today_and_Now);
use CGI qw(:standard);

print header(), start_html("y2k");

{
@diff = Delta_DHMS(Today_and_Now(), (2000, 1, 1, 0, 0, 0));
print "<h1>$diff[0] days $diff[1] hours $diff[2] mins $diff[3]
secs</h1>";
sleep (1);    # useless right now. I had "redo;" on the next line,
                  # the page didn't work.
}

print end_html();

This should be a counter. It works as a standalone application.




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

Date: Fri, 17 Sep 1999 08:31:32 GMT
From: soulierb@my-deja.com
Subject: cgi not working
Message-Id: <7rsu94$rn6$1@nnrp1.deja.com>

hi,

I have a webserver, with a linux Os, and of course Apache server.
I want to use  new cgi, but i can't execute it.
Explanation : I have 2 script : card.cgi and program.cgi (writen in
Perl). Well they are working really good on a freehosting server, but
not on my server.
They are well configured, i transfer them in ASCII, and chmod 755 them.
problem : if I try
perl - card.cgi => syntax is ok
but
 ./card.cgi to execute it, i get the message, that there is no such  file
in my folder
but if i make a ls in this folder, the card.cgi is in the list.

if i do the same thing with my program.cgi, syntax is ok, and no problem
to execute it.

Question : what can I do ?
Why my script works good on a freehosting webserver (APache server too),
and not on mine ?
Nota : I have other script (mail.pl or search.pl) who works realy good.
Is this a problem with my .cgi extension ?

To complete, I try to rename my card.cgi in card.pl, chmod it and i get
the same message (no such file).

Bertrand (France)
soulierb@bigfo


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


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

Date: Fri, 17 Sep 1999 01:41:49 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: CONTEST: Range Searching
Message-Id: <37E19C55.CBD5DAF4@home.com>

Tom Christiansen wrote:
> 
>     2) Write a "pataft" program that prints out up to N lines
>        after the match as well as the match itself.  Here's
>        the usage message:
> 
>             pataft [-A N] pattern [files ...]

Okay, I'll take the easy one.

    perl -ne 'print if ($c=0, /pat/) .. $c++ == 3' files

If one really wanted to save this then something like this would do.

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

$A &&= shift;
$pat = shift;
die <<USAGE unless @ARGV;
pataft [-A N] pattern [files ...]
USAGE

while(<>){
    print if ($c = 0, /$pat/o) .. $c++ == $A;
}
__END__

Of course we probably shouldn't encourage skipping -w (though I see no
need for 'use strict' for something so short).

Adding -w means changing

    $A &&= shift;
to
    $A = $A ? shift : 0;

> For Extra Credit:
>     Provide alternate solutions that also coalesce with overlapping
>     ranges.  For example, if you ask for 2 lines before and after, and
>     lines 2, 4, and 5 all contain matches, the output should comprise
>     lines [1-7] rather three separate output blocks showing lines.
>     [1-4], [2-6], and [3-7].

A slight rearrangement after USAGE give this alternate solution:

$c = $A + 1;
while(<>){
    $c = 0 if /$pat/o;
    print  if $c++ <= $A;
}

, which is pretty much like the other posters' solutions.  

But I don't like it because it doesn't make a nice one-liner as above. 
I guess I still have grep.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Thu, 16 Sep 1999 17:04:41 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: CONTEST: Range Searching
Message-Id: <1dy873h.1oek316ilsakgN@imac.loc>

Tom Christiansen <tchrist@mox.perl.com> wrote:

> We're lately been stricken with questions about what comes down to
> variations on the same essential theme: how to search a stream for matches
> and then produce as output some number of lines before or after the match
> as well as the matched line.  This has to work efficiently for an input
> stream of unlimited length.
<snip>
> So here's the challenge: devise idiomatic solutions to the
> following problems.  
> 
>     1) Write a "patfore" program that prints out up to N lines
>        before the match as well as the match itself. 
>     2) Write a "pataft" program that prints out up to N lines
>        after the match as well as the match itself.
> 
>     3) Write a "patba" program that prints out up to
>        X lines before the match and Y lines after the match.

It seems to me that 3) does everything 1) and 2) do.

Therefore, here is my single solution:

#!perl -w

use Getopt::Std;
getopts('mB:A:') and $pat = shift and @ARGV or usage();

foreach ($opt_A, $opt_B, $opt_m) {$_ ||= 0}
$pat =~ s!^/(.*)/$!$1!;

foreach $IN (@ARGV) {
  open IN or die "Can't open $IN: $!";

  LINE: while (push(@lindex, tell IN), defined($_ = <IN>)) {
    shift @lindex if $#lindex > $opt_B;
    if (/$pat/o) {
      print "---\n" if $noncontiguous;

      seek(IN, $lindex[0], 0);
      for (my $i = 0; $i < $opt_A + @lindex; $i++) {
        my $y = <IN>; last if !defined $y;
        print(($opt_m ? ($i == $#lindex ? '+ ' : '  ') : '') . $y);
      }
      @lindex = ();
      $noncontiguous = 0;
    } else {$noncontiguous = 1}
  }
}

sub usage {print <<"END" and exit}
$0 [-m] [-B lines] [-A lines] /pattern/ [files...]

  -m    Print indication of matched line
  -B n  Print n lines before the match
  -A n  Print n lines after the match

  Slashes on the pattern are optional.

END

__END__


> Solutions will be judged upon these overall criteria:
<snip>
>     Subjective:
>       * conciseness:  keep it short.  no frills.  just a few lines.
Nope - plenty of frills here.

-- 
 Kevin Reid: |    Macintosh:      
  "I'm me."  | Think different.


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

Date: 16 Sep 1999 21:59:57 GMT
From: ken@halcyon.com (Ken Pizzini)
Subject: Re: CONTEST: Range Searching
Message-Id: <slrn7u2ped.1dm.ken@pulsar.halcyon.com>

On 16 Sep 1999 08:52:46 -0700, Tom Christiansen <tchrist@mox.perl.com> wrote:
>So here's the challenge: devise idiomatic solutions to the
>following problems.  

Can we abbreviate the solutions a bit --- omit the command-line
parsing as being boring?  While essential to an actual utility
the command-line parsing tends to clutter newsgroup postings
and obscure the stark beauty of any truly elegant solution.
(I am not making the claim that my code below qualifies as
"truly elegant", though I think my solution to (1) comes close.)


>    1) Write a "patfore" program that prints out up to N lines
>       before the match as well as the match itself.  Here's
>       the usage message:
>
>	    patfore [-B N] pattern [files ...]

  push @lines, $_;
  print splice(@lines, 0, $N) if /pattern/;
  shift @lines if @lines >= $N;


>    2) Write a "pataft" program that prints out up to N lines
>       after the match as well as the match itself.  Here's
>       the usage message:
>
>	    pataft [-A N] pattern [files ...]

  /pattern/ and $end = $. + $N;
  print if $. <= $end;


>    3) Write a "patba" program that prints out up to
>       X lines before the match and Y lines after the match.
>
>	    patba [-A X] [-B T] pattern [files ...]
>
>       or both N before and after:
>
>	    patba [-C N] pattern [files ...]

Assume that the command-line parsing of -C N sets $X=$T=$N .

  push @lines, $_;
  if (($matched = /pattern/) || $. <= $end) {
    print @lines;
    @lines = ();
    $end = $matched && $. + $X;
  } else {
    shift @lines if !$end && @lines >= $T;
  }


>For Extra Credit:
>    Provide alternate solutions that also coalesce with overlapping
>    ranges.  For example, if you ask for 2 lines before and after, and
>    lines 2, 4, and 5 all contain matches, the output should comprise
>    lines [1-7] rather three separate output blocks showing lines.
>    [1-4], [2-6], and [3-7].

The above solutions all coalesce; they become more cumbersome if
they are altered to avoid coalescing.

		--Ken Pizzini


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

Date: Thu, 16 Sep 1999 21:23:56 -0400
From: Jamie McCarthy <jamie@mccarthy.org>
Subject: Re: CONTEST: Range Searching
Message-Id: <37E1982C.824F9538@mccarthy.org>

Tom Christiansen wrote:

> For Extra Credit:
>     Provide alternate solutions that also coalesce with overlapping
>     ranges.  For example, if you ask for 2 lines before and after, and
>     lines 2, 4, and 5 all contain matches, the output should comprise
>     lines [1-7] rather three separate output blocks showing lines.
>     [1-4], [2-6], and [3-7].

The extra credit problem is IMHO the only fun one so that's what
I'll try.  Also it's the most sensible, the first three problems
produce unexpected (to a human) output.

> Solutions will be judged upon these overall criteria:
> 
>     Objective:
> 
>       * correctness: does it actually do the right thing?  if not,
>         nothing else matters. :-)
>       * space efficiency: don't use more space than minimally needed
>       * time efficiency: is your solution fast?
>       * test coverage: do you include test data to check all border cases?

I notice readability is not on the list, heh.  I believe this
solution is correct but I haven't put together truly rigorous
test cases so I can't be sure.  It's pretty space-efficient,
printing and forgetting unneeded data, and I suspect time-
efficiency is OK (though being I/O-bound is likely of course).

>     Subjective:
> 
>       * conciseness:  keep it short.  no frills.  just a few lines.
>       * clarity: is this understandable to a native perl speaker?
>       * idiom: does this look like natural perl?  does it use cool
>         perl features absent in other languages?
>       * creativity: is your solution cleverly different from those
>         of others?

The core code is just a few lines, please pardon the command
line arguments and whatnot.  Opinions may differ as to how
"native" my coding style is:  if I look too much like a
reformed Pascal programmer I can scuzz it up a bit!  :-)



#!/usr/bin/perl -w

# Parse the command-line switches.

$after = $before = 0; # Defaults.
while (@ARGV and $ARGV[0] =~ /^-([ABC])$/) {
   SWITCH: {
      $1 eq 'A' and $after  = $ARGV[1];
      $1 eq 'B' and $before = $ARGV[1];
      $1 eq 'C' and $before = $after = $ARGV[1];
   }
   shift, shift;
}

# Parse the remaining command-line argument(s).

die "need a regex" unless @ARGV;
$regex = shift @ARGV;

# Set constants and globals.

$prelude  = ">>>\n"; # Or the empty string;
$postlude = "<<<\n"; # whatever you prefer.
@buff = ( );
$match = $skimmed = 0;

# The main loop.  The key is to track the last-matched
# line number in $match and of course the current line
# number in $. -- the difference between them tells us
# whether we're done matching and thus need to dump the
# context of the match(es) to STDOUT.

while (defined($line = <>)) {
   push @buff, $line;
   $match = $. if $line =~ /$regex/o;
   if ($match) {
      if ($. - $match > $before+$after) {
         &dump;
      } elsif ($. - $match > $before) {
         # One of the design goals is to run in the smallest
         # space possible.  That means immediately printing
         # any lines we know for a fact can be printed, and
         # shifting them off the buffer to free up their RAM.
         # The beauty is that we always know how near to the
         # _end_ of the buffer to dump, so we're free to skim
         # values off its _front_ if appropriate.
         print $prelude if !$skimmed++;
         print shift @buff;
      }
   }
   # If we're not matching and we're saving too much context,
   # we can shift off one line of that context.
   shift @buff if !$match and $#buff >= $before;
}

# After we run off the end of the last file, if we are still
# matching, it can be a little tricky to properly print context
# around the last lines (consider the case where the last match
# was less than $before+$after but more than $after lines ago).
# The simplest way to handle it is to pretend we have already
# "read" lines containing the empty string, up to the point
# where we would normally dump the buffer.  That way there is
# no special case.

if ($match) {
   push @buff, ("") x (1+$before+$after+$match-$.);
   &dump;
}

# Dump the contents of the circular buffer to screen.

sub dump {
   print
      $skimmed ? "" : $prelude,
      @buff[0..$#buff-$before-1],
      $postlude;
   @buff = ($before ? @buff[-$before, -1] : ());
   $match = $skimmed = 0;
}

__END__




Sample runs:

$ ./patba.pl -C 0 '^Aa|^Zu|perl' /usr/dict/words
>>>
Aarhus
Aaron
<<<
>>>
improperly
<<<
>>>
properly
<<<
>>>
superlative
superlatively
superlatives
<<<
>>>
Zulu
Zulus
Zurich
<<<

$ cat /usr/dict/words | ./patba.pl -C 2 '^Aa|^Zu|perl'
>>>
Aarhus
Aaron
Ababa
aback
<<<
>>>
impromptu
improper
improperly
impropriety
improve
<<<
>>>
propensity
proper
properly
properness
propertied
<<<
>>>
superiority
superiors
superlative
superlatively
superlatives
supermarket
supermarkets
<<<
>>>
Zoroaster
Zoroastrian
Zulu
Zulus
Zurich
<<<

--
 Jamie McCarthy


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

Date: Fri, 17 Sep 1999 09:42:50 +0200
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.net>
Subject: Re: CONTEST: Range Searching
Message-Id: <37E1F0FA.24C6DB2F@gmx.net>

Kragen Sitaker wrote:
> 
> In article <7rrrc9$dj8@cocoa.brown.edu>, Don Blaheta <dpb@cs.brown.edu> wrote:
> >
> >       $fore = $opt{B} || $opt{C} || 3;
> >       $aft = $opt{A} || $opt{C} || 3;
> 
> I also notice you picked the same default number of lines as I did!

Perhaps comes from diff(1), which prints three lines of context with the
-c flag, and has the -C n flag for 'n' lines of context if you don't
want three.

Cheers,
Philip


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

Date: Fri, 17 Sep 1999 08:42:23 GMT
From: tgy@chocobo.org (Neko)
Subject: Re: CONTEST: Range Searching
Message-Id: <37e1f36d.476651708@news.supernews.com>

On 16 Sep 1999 08:52:46 -0700, Tom Christiansen <tchrist@mox.perl.com> wrote:

>    1) Write a "patfore" program that prints out up to N lines
>       before the match as well as the match itself.  Here's
>       the usage message:
>
>	    patfore [-B N] pattern [files ...]

Two versions.  The first will output each match.  The second will coalesce
overlaps.  Both actually store more (maybe 100) lines than necessary, trading
a bit of space for a bit of time (less shifting of arrays).  They are still
space efficient though in that they won't slurp whole files.

#!/usr/bin/perl
# patfore [-B N] pattern [files ...]
# Each match by itself.

$b = @ARGV && $ARGV[0] eq '-B'
    ? (shift, shift)[1]
    : 3;
$max = $b > 100 ? $b : 100;

$re = shift;
defined $re or die "usage: patfore [-B N] pattern [files ...]\n";

while (<>) {
    print "Match #", ++$i, " [\n", @lines[-$b..-1], "$_]\n\n" if /$re/o;
    push @lines, $_;
    @lines = @lines[-$b..-1] if @lines > $max;
}

__END__

#!/usr/bin/perl
# patfore [-B N] pattern [files ...]
# Will coalesce overlaps.

$b = @ARGV && $ARGV[0] eq '-B'
    ? (shift, shift)[1]
    : 3;
$max = $b > 100 ? $b : 100;

$re = shift;
defined $re or die "usage: patfore [-B N] pattern [files ...]\n";

while (<>) {
    @lines = @lines[-$b..-1] if @lines > $max;
    unless (/$re/o) {
        push @lines, $_;
        next;
    }
    print "Match #", ++$i, " [\n", @lines[-$b..-1], $_;
    COAL: for (1..$b) {
        last if eof;
        push @lines, scalar <>;
        if ($lines[-1] =~ /$re/o) {
            print @lines[-$_..-1];
            goto COAL;
        }
    }
    print "]\n\n";
}

__END__

>    2) Write a "pataft" program that prints out up to N lines
>       after the match as well as the match itself.  Here's
>       the usage message:
>
>	    pataft [-A N] pattern [files ...]

Again two versions.  The first uses a seek() without checking for errors, so
it's not so robust.  Also, if there's any overlap, it ends up reading the
same lines twice.  It would have been better to keep an array of lines
around, but I'm sufficiently lazy right now not to care.

#!/usr/bin/perl
# pataft [-A N] pattern [files ...]
# Each match by itself.

$a = @ARGV && $ARGV[0] eq '-A'
    ? (shift, shift)[1]
    : 3;

$re = shift;
defined $re or die "usage: pataft [-A N] pattern [files ...]\n";

while (<>) {
    /$re/o or next;
    $tell = tell ARGV;
    print "Match #", ++$i, " [\n$_";
    for (1..$a) {
        last if eof;
        print scalar <>;
    }
    print "]\n\n";
    seek ARGV, $tell, 0;
}

__END__

#!/usr/bin/perl
# pataft [-A N] pattern [files ...]
# Will coalesce overlaps.

$a = @ARGV && $ARGV[0] eq '-A'
    ? (shift, shift)[1]
    : 3;

$re = shift;
defined $re or die "usage: pataft [-A N] pattern [files ...]\n";

while (<>) {
    /$re/o or next;
    print "Group #", ++$i, " [\n$_";
    COAL: for (1..$a) {
        last if eof;
        $line = <>;
        print $line;
        goto COAL if $line =~ /$re/o;
    }
    print "]\n\n";
}

__END__

>    3) Write a "patba" program that prints out up to
>       X lines before the match and Y lines after the match.
>
>	    patba [-A X] [-B T] pattern [files ...]
>
>       or both N before and after:
>
>	    patba [-C N] pattern [files ...]

#!/usr/bin/perl
# patba [ [ [-A X] [-B Y] ] | [-C N] ] pattern [files ...]
# Each match by itself.

while (@ARGV && $ARGV[0] =~ /-[ABC]/) {
    /A/ ? ($a) :
    /B/ ? ($b) :
    ($a, $b) = (shift) x 2 for shift;
}
defined or $_ = 3 for $a, $b;
$b++;
$max = $b > 100 ? $b : 100;

$re = shift;
die "usage: patba [ [ [-A X] [-B Y] ] | [-C N] ] pattern [files ...]\n"
    unless defined $re;

while (<>) {
    push @lines, $_;
    @lines = @lines[-$b..-1] if @lines > $max;
    /$re/o or next;
    $tell = tell ARGV;
    print "Match #", ++$i, " [\n", @lines[-$b..-1];
    for (1..$a) {
        last if eof;
        print scalar <>;
    }
    print "]\n\n";
    seek ARGV, $tell, 0;
}

__END__

#!/usr/bin/perl
# patba [ [ [-A X] [-B Y] ] | [-C N] ] pattern [files ...]
# Will coalesce overlaps.

while (@ARGV && $ARGV[0] =~ /-[ABC]/) {
    /A/ ? ($a) :
    /B/ ? ($b) :
    ($a, $b) = (shift) x 2 for shift;
}
defined or $_ = 3 for $a, $b;
$max = $b > 100 ? $b : 100;

$re = shift;
die "usage: patba [ [ [-A X] [-B Y] ] | [-C N] ] pattern [files ...]\n"
    unless defined $re;

while (<>) {
    @lines = @lines[-$b..-1] if @lines > $max;
    unless (/$re/o) {
        push @lines, $_;
        next;
    }
    print "Group #", ++$i, " [\n", @lines[-$b..-1], $_;
    COAL: for (1..$a) {
        last if eof;
        $line = <>;
        print $line;
        goto COAL if $line =~ /$re/o;
    }
    for (1..$b) {
        last if eof;
        push @lines, scalar <>;
        if ($lines[-1] =~ /$re/o) {
            print @lines[-$_..-1];
            goto COAL;
        }
    }
    print "]\n\n";
}

__END__

>Solutions will be judged upon these overall criteria:
>
>    Objective: 
>
>      * correctness: does it actually do the right thing?  if not, 
>	nothing else matters. :-)
>      * space efficiency: don't use more space than minimally needed
>      * time efficiency: is your solution fast?
>      * test coverage: do you include test data to check all border cases?

They are correct unless they aren't.  When printing the previous N lines,
more space is used than absolutely necessary, but it means I don't have to
shift a perfect array for every line.  I used a modified version of Don
Blaheta's test data (it adds a 'foo' at the very start and very end):

	foo
	a
	b
	foo
	foo
	c
	foo
	d
	e
	f
	g
	foo
	h
	i
	j
	k
	l
	m
	n
	foo
	o
	p
	q
	r
	s
	t
	u
	v
	w
	x
	y
	z
	foo

>    Subjective:
>
>      * conciseness:  keep it short.  no frills.  just a few lines.
>      * clarity: is this understandable to a native perl speaker?
>      * idiom: does this look like natural perl?  does it use cool
>	perl features absent in other languages?
>      * creativity: is your solution cleverly different from those
>	of others?

Some of it is more concise than others, but none measured to just a few
lines.  Those who've walked the desert should have no trouble understanding
the code, though a few may spit on me for using goto().  It's Perl written in
Perl so perhaps it's idiomatic.  I doubt it's very creative or clever though.


-- 
Neko | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=


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

Date: Fri, 17 Sep 1999 07:00:57 GMT
From: Shardendu Pandey <pandey@my-deja.com>
Subject: CPAN modules for Windows
Message-Id: <7rsov7$nae$1@nnrp1.deja.com>

Hi,
I am exploring perl on Windows and am
interested in knowing whether there
is equivalent of CPAN libraries on
Windows.


Best wishes
Pandey

--
==============================================


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


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

Date: Fri, 17 Sep 1999 07:38:04 GMT
From: "Steve Klein" <steve@interjize.com>
Subject: Database retrieval of information using PERL
Message-Id: <wdmE3.3770$RS3.33913@ha1>

Does anyone know of a good script or an example of a PERL program that takes
database information and does a Query on the info.

Example:  there would be a form giving input areas for addresses and based
on that address, the certain field would have the correct zip-code.  The
goal from the form is the person fills out their address, and the CGI will
lookup that address, see if it falls between a certain criteria, and then
give back the appropriate zip-code.

If anyone has an idea, or a website I can look this information up on, I
would greatly appreciate it.

Thanks,




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

Date: Fri, 17 Sep 1999 09:42:36 +0200
From: "Steve Button" <steve.button@nl.origin-it.com>
Subject: Re: Encrypting (and decrypting) password
Message-Id: <0E16861EE7BCD111BE9400805FE6841F0B726414@c1s5x001.cor.srvfarm.origin-it.com>

jerrad pierce wrote in message <37E10797.C4432296@networkengines.com>...
>Why continure passing the password around?

To be honest, because that's the only way I know how to do it so far. I'm
learning as I go along.

>Why not some cookie that says they are logged in?

Haven't figured out how to use cookies yet (we call them Buscuits in the UK
:-)  But that is definitely the way I am hoping to go early next year, in
the mean time all I *really* want is that people don't get to see the
password that they typed in the URL of their next page!  It would not look
very professional, and anyone looking over their sholder would get to see
what the password is.  I also want to deter

>Try Apache::ASP

What! Learn another language AND be at the mercy of Bill's marketing
policies!  I thought about going the ASP route and decided that perl/CGI was
much more gooder for what I needed at the time. For many reasons, but mostly
because I liked using perl and I wanted to learn more about it. I was also a
C programmer (years ago) and now I'm a unix sysadm, so I've done loads of
shell / awk / sed and perl is a bit like all of them, munged together. I
looked at ASP and I didn't like what I saw, probably because I didn't
understand it.

So, how do I learn more about these Biscuits then?

Thanks,

Steve

HuntAHome      http://www.huntahome.com
Properties throughout the UK and Europe
You can subscribe to receive a free daily email of all properties that match
your requirements (location, price, bedrooms)
You can advertise your property, with photograph, for free.




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

Date: Fri, 17 Sep 1999 10:03:56 +0200
From: "Steve Button" <steve.button@nl.origin-it.com>
Subject: Re: Encrypting (and decrypting) password
Message-Id: <0E16861EE7BCD111BE9400805FE6841F0B726A95@c1s5x001.cor.srvfarm.origin-it.com>


Ethan H. Poole wrote in message <37E14923.DE1C6921@ingress.com>...
>Steve Button wrote:
>>
>> Hello,
>> I'm trying to encrypt a password that a user types in, so that I can pass
it
>> [SNIP]
>Ideally, you should be letting the server and client handle the encryption
>using SSL, otherwise your initial login presents a weak link.

Hmmmmm. I've got SSL with my ISP, but (like many other things) haven't
figured out how to use it. Expect I will have to use it when we start taking
money (on-line) on the site, but that's a couple of years away at least.

>
>For simple encryption (and there isn't much point to anything more complex
>if you are still passing everything cleartext including the initial
>login), you could use XOR encryption -- and making certain the key
>contained in the script's code does not become compromised.

Yes, that's what I want to do!  (for now) I assume you're suggeting that I
simply XOR each of the characters with some (known) bitmask and then do the
same thing again at the other end, to switch it back again. This sounds like
what I need.  I don't need anything more fancy than that, because I'm only
giving people the ability to advertise property for sale / rent for free.
The worst thing that could happen is that someone tampers around with the
information on there.  Is someone really going to bother doing this, when I
am giving them the ability to put whatever they want under their own account
anyway?  I can see that it would be fairly trivial for someone to crack this
by simply XORing with all 255 possible combinations and seeing which one
comes up with a word (or trying each one in turn). But, it's a lot better
than nothing !!
>
>However, you had better make certain that there is some random data (but


So, you mean that I should (for example) hold a table of 24 different
characters (keys) and use a different one depending upon the hour?
(obviously I will NOT do this now, as someone would just have to read this
post.....)
>
>If you are looking for genuine encryption and not just something that
>makes life a tiny bit more complicated to ward off crackers you should be
>using SSL and allowing the client and server to handle encrypting the
>entire data stream.

Hmmmmmm. But that alone would not solve my initail problem would it?  I
mean, if I just passed the password in the POST method (or whatever it is)
they would get their OWN password printed in plain text at the top of their
screeen in the box that says "location:".  This would give the perception of
bad security.

Thanks for the answers!  I think that I have enough to be going on with now.
>
>--
>Ethan H. Poole           ****   BUSINESS   ****
>ehpoole@ingress.com      ==Interact2Day, Inc.==
>(personal)               http://www.interact2day.com/




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

Date: Fri, 17 Sep 1999 02:12:26 -0500
From: Seth David Johnson <sjohns17@uic.edu>
Subject: Re: help!
Message-Id: <Pine.A41.4.10.9909170211270.334102-100000@tigger.cc.uic.edu>

On Fri, 17 Sep 1999, bob wrote:

> can someone email/IM me a description of what's on channel 80?
> i then need to make a change and ask them to tell me what changed.

Well, I only get basic cable, so... Is there a Perl port for WebTV?

impishly,
-Seth



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

Date: Fri, 17 Sep 1999 09:37:56 +0200
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.net>
Subject: Re: help: read only a char without echo?
Message-Id: <37E1EFD4.BA4B82AF@gmx.net>

Jonathan Stowe wrote:
> 
> Alexander Urban <A.Urban@alcatel.de> wrote:
> > Hi,
> >
> > I'd like to read only one character without echo under UNIX-System.
> 
> In the first instance please see perlfaq5:
> 
>   How can I read a single character from a file?  From the keyboard?

In the second, see perlfaq8:

   How do I read just one key without waiting for a return key?

which also has a solution with noecho at the bottom.

In fact, the examples given for the two questions are very similar.
Compare and contrast. (15 points)

Cheers,
Philip


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

Date: Fri, 17 Sep 1999 10:02:26 +0200
From: Ivan Balanya Jimenez <ivanb@lsi.upc.es>
Subject: How to know modules of a installed version of perl
Message-Id: <37E1F592.EEA91D78@lsi.upc.es>

Hello,

My name is Ivan Balanya and I would like to know if there is any form of
listing the modules that have been installed with Perl. I have been told
that there is a command that do this, but I don't know which is.

Thankyou,

    	Ivan
-- 
Ivan Balanya Jimenez
Laboratori de Calcul
Llenguatges i Sistemes Informatics


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

Date: Fri, 17 Sep 1999 09:46:58 +0200
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.net>
Subject: Re: how to produce a 'beep'?
Message-Id: <37E1F1F2.A7579CF2@gmx.net>

Uri Guttman wrote:
> 
>   On 16 Sep 1999, Tom Christiansen wrote:
> 
>   >> use Curses;
>   >> initscr();
>   >> beep();
>   >> endwin();
> 
> i can't resist it:
> 
> use Acme::RoadRunner ;
> 
> $wiley = Acme::RoadRunner->new() ;

This matches initscr()

> print $wiley->beepbeep() ;

This matches beep()

You forgot endwin():

  $wiley->vroom() ;

Cheers,
Philip :)


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

Date: Thu, 16 Sep 1999 22:53:02 +0000
From: Warren Bell <resource@ERASEjps.net>
Subject: How to test for file Perl
Message-Id: <37E174CE.C2DC6A12@ERASEjps.net>

I'm trying to write a script that needs to check a directory for a file
as part of an if then statement.  I can't seem to get it, it keeps
comming up with errors.  How can I do this?  Somthing like:

$file="/home/user/file"

if ($file){
do this
}else{
do this
}


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

Date: Fri, 17 Sep 1999 08:45:11 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: How to test for file Perl
Message-Id: <37e1fefc.939192767@frettir.simnet.is>

On Thu, 16 Sep 1999 22:53:02 +0000, Warren Bell
<resource@ERASEjps.net> wrote:

>I'm trying to write a script that needs to check a directory for a file
>as part of an if then statement.  I can't seem to get it, it keeps
>comming up with errors.  How can I do this?  Somthing like:
>
>$file="/home/user/file"
>
>if ($file){
>do this
>}else{
>do this
>}

Try

if (-e $file ) {dostuff};

-e is the "exists" file checking switch.
There are other useful ones such as 
-d (checks for a directory)  
-s (checksfor size)
-w (checks if writeable)

Enjoy


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

Date: Fri, 17 Sep 1999 10:34:12 +0200
From: "C. Lousberg" <clousberg@voslogistics.com>
Subject: Line chart
Message-Id: <7rsugp$eua$1@rubens.telebyte.nl>

How do I make a line-chart on our homepage from a  SQL-Database ?
Someone have an example that I can use ?




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

Date: Fri, 17 Sep 1999 08:29:37 +0200
From: "Matt King" <mattking@techie.com>
Subject: Re: Making and using a DB. (Help!!!)
Message-Id: <7rsl52$q16$1@news.uk.ibm.com>

Please tell me where I can get it. I tried the Active web site and there was
not DB_File package for download. Perhaps they have more then one area? Or
perhaps it's got some strange name?

Do you know if using the DB_File will solve the current problems I'm having
with the SDBM_File package? Are there any other alternatives to this that
can be installed in the Active version? (I don't have the make utility
so..... ppm or manual installation it has to be (please not manual, please)
(anyone know where I can find a Win32/Active make? Found a pmake, doesn't
work though.) ).

I'm begining to see why it's called active perl, you have to be real active
to get it to work, and continue working, like real perl =P

Matt

Eric Bohlman <ebohlman@netcom.com> wrote in message
news:7rs94i$b24@dfw-ixnews6.ix.netcom.com...
> DB_File is available for ActivePerl and can be installed with PPM.





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

Date: 17 Sep 1999 06:59:49 GMT
From: bluesrift@aol.com (BLUESRIFT)
Subject: optimizing execution speed
Message-Id: <19990917025949.01880.00001118@ng-ci1.aol.com>

The following questions are asked in the context of Perl scripts running on an
Apache Unix server written for web browsers. I want to learn techniques that
will not necessarily lead to faster written code, but faster execution of
scripts that I write for others to use.  I am assuming that it is indeed
possible to create code that appears elegant but may actually execute more
slowly. For example, as a beginner I may be tempted to make my life easier by
relying on CGI.pm but intiutively I believe there must be a performance cost
with use of such modules.

What I am looking for is general advice on optimizing the execution speed of
Perl scripts.  This newsgroup may not be forum for such questions as:

"At what point is it better to modularize an application into separately called
script files as opposed to calling subroutines within the same file?"
-or-
"At what point is it better to use subroutines at all instead of simply
repeating redundant code?"

where obviously one answer is to test which actually performs more quickly. But
valid tests are very difficult to construct when dealing with servers that are
subject to wide variances in traffic and processor load.  So, I am looking for
advice from those who have had the resources to research and establish
practical guidelines.  
Perhaps this may be a bit over the top, but it has even occurred to me that it
may be possible to create code that tests the "environment" and triggers
alternate paths of execution based on current conditions.  Has anyone reading
this done such a thing?

If not here, where would I go to find answers to questions such as these which
are not purely Perl language but also involve "real world" considerations?

Thank You,
Rob Bell


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

Date: 17 Sep 1999 07:08:38 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: optimizing execution speed
Message-Id: <slrn7u3q7m.8mo.sholden@pgrad.cs.usyd.edu.au>

On 17 Sep 1999 06:59:49 GMT, BLUESRIFT <bluesrift@aol.com> wrote:
>The following questions are asked in the context of Perl scripts running on an
>Apache Unix server written for web browsers. I want to learn techniques that
>will not necessarily lead to faster written code, but faster execution of
>scripts that I write for others to use.  I am assuming that it is indeed
>possible to create code that appears elegant but may actually execute more
>slowly. For example, as a beginner I may be tempted to make my life easier by
>relying on CGI.pm but intiutively I believe there must be a performance cost
>with use of such modules.

Correctness is usually _much_ more important than speed. The extra cost
in speed is worth the fact that you avoid getting it wrong - which almost
everybody seems to do when they don't use CGI.pm.

Usiong mod_perl with Apache will make orders of magnitude more difference
then rolling your own CGI stuff...

>
>What I am looking for is general advice on optimizing the execution speed of
>Perl scripts.  This newsgroup may not be forum for such questions as:
>
>"At what point is it better to modularize an application into separately called
>script files as opposed to calling subroutines within the same file?"

If the script gets executed often enough for it to matter, then it
shouldn't matter ;) Since all the files will end up in the OS's 
cache somewhere anyway.

>-or-
>"At what point is it better to use subroutines at all instead of simply
>repeating redundant code?"

Always would be my answer. 

-- 
Sam

You are bordering on ridiculous if you think you need to support your
premises.  Such an argument is an infinite regression.
 	--George Reese in <wv0O1.1521$Ge.4809664@ptah.visi.com>


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

Date: 16 Sep 1999 23:41:48 GMT
From: gboug@iona.kau1.kodak.com (Greg Boug)
Subject: Re: Perl + ICQ
Message-Id: <slrn7u301s.kn6.gboug@iona.kau1.kodak.com>

On Thu, 16 Sep 1999 08:59:52 -0700, Tom Phoenix <rootbeer@redcat.com> wrote:
>Sure there is; the question is whether anyone has written it yet. :-)
>
>If the ICQ protocol is available, someone probably has a module (which
>should be on CPAN). If the protocol is proprietary, then someone should
>design an open protocol to replace it. :-) But that's outside of the scope
>of this newsgroup.
>
>If you find nothing on CPAN, see about searching for the protocol spec.
>Good luck!

Its Net::ICQ, and yes it exists, but I think it is based on the old
version 2 protocol, and doesn't completely work yet anyway, AFAIK...

It is on CPAN...


-- 
To reply, remove the uppercase letters in my email address...
Disclaimer: The opinions expressed are purely my own and do not
represent the opinions of my employer...


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

Date: Fri, 17 Sep 1999 08:31:13 GMT
From: steffi@mvi.de
Subject: PERL->mySQL
Message-Id: <7rsu8h$rn0$1@nnrp1.deja.com>

HI!
can anybody help me?
I want to read out values from a mySQL-Database with a perl-script.
but i don't know how!!!!
have someone an example??

this is wrong..but why?
-------------------------------------
#!/usr/local/bin/perl

use DBI;
use strict;
my $database = "test";
my $data_source = "DBI:mysql:$database";
my $username = "test";
my $password = "test";
my $dbh = DBI->connect( $data_source, $username, $password)
    or die "Can't connect to $data_source\n";


$s1 = qq|select mit_name,mit_vorname,amt_id from mitarbeiter where
mit_id=2|;
$sth = $dbh->prepare($s1) || print $DBI::errstr;
$sth -> execute || print $DBI::errstr;

while (@row = $sth->fetchrow()) {
  print "$row[0] $row[1] $row[2]\n";
}

$dbh->disconnect;
exit(0);


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


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

Date: Fri, 17 Sep 1999 08:27:19 GMT
From: andy_muscat@my-deja.com
Subject: Re: unpack("%32C*", $text)
Message-Id: <7rsu0u$rdd$1@nnrp1.deja.com>

In article <37E14D54.B227DDB1@cisco.com>,
  Makarand Kulkarni <makkulka@cisco.com> wrote:
> [andy_muscat@my-deja.com wrote:
>
> > Does anyone know what the C/C++ version of unpack("%32C*",$text)
would
> > be?
> > I want to produce a checksum for a piece of text in C++ to mimic the
way
> > it is done in a Perl script. The perl is
> > $checksum  = unpack ("%32C*",$text);
>
> (1)There is a program which you can get here.
> http://www.cps.msu.edu/~leekukji/cps422/checksum.html
> I have not used or tested this program.
>
> (2)Utilities sum and cksum on unix can do this.
> --
>
>

(1)Thanks for this, does it mimic unpack ("%32C*",$text)? I can see what
it is doing but do not know whether it is the same as the perl.

(2)I need to be able to port to NT so sum an cksum aren't an answer.


Thanks




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


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

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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that you aren't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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


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