[10265] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3858 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 30 13:08:11 1998

Date: Wed, 30 Sep 98 10:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 30 Sep 1998     Volume: 8 Number: 3858

Today's topics:
    Re: 10 SEP 1998 ==> 1998-09-10 <murrayb@vansel.alcatel.com>
    Re: 10 SEP 1998 ==> 1998-09-10 <matt@bessie.franken.de>
    Re: 10 SEP 1998 ==> 1998-09-10 <uri@camel.fastserv.com>
    Re: assign name and content of a variable provided from <aqumsieh@tigre.matrox.com>
        bug in Berkley DB/DB_File? hazard@my-dejanews.com
    Re: epoch time <aqumsieh@tigre.matrox.com>
    Re: Locking files, counter, unique serial number... <imchat@imchat.com>
    Re: Locking files, counter, unique serial number... <imchat@imchat.com>
    Re: Locking files, counter, unique serial number... (Nathan V. Patwardhan)
    Re: mailing attachments in Perl <95ncp@eng.cam.ac.uk>
    Re: mod_perl configuration intuitiveknowledge@yahoo.com
    Re: mod_perl file closing problem (brian d foy)
    Re: need a regular expressions expert.... <uri@camel.fastserv.com>
    Re: need a regular expressions expert.... (Matt Knecht)
    Re: need a regular expressions expert.... <uri@camel.fastserv.com>
    Re: Need IP Address Sort Subroutine <jdporter@min.net>
    Re: Need IP Address Sort Subroutine <jdporter@min.net>
    Re: Need IP Address Sort Subroutine <erhmiru@erh.ericsson.se>
    Re: Need IP Address Sort Subroutine <uri@camel.fastserv.com>
    Re: new term for illogical <uri@camel.fastserv.com>
    Re: POLL: Perl features springing into your face <merlyn@stonehenge.com>
    Re: restricting script execution? droby@copyright.com
        Sending HTML file as an attachment. ankur_palkar@hotmail.com
    Re: Sending HTML file as an attachment. (Sean McAfee)
    Re: Sending HTML file as an attachment. <95ncp@eng.cam.ac.uk>
    Re: Simple database recommendation needed (Aahz Maruch)
    Re: Some kind of 'real' user interface? <aqumsieh@tigre.matrox.com>
    Re: SRC: encrypt your Perl scripts! :-) droby@copyright.com
        Stock paging, anyone seen this script? (Cypher)
    Re: Substitution-Problem (Patrick Timmins)
    Re: Substitution-Problem <aqumsieh@tigre.matrox.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 30 Sep 1998 07:46:30 -0700
From: Brad Murray <murrayb@vansel.alcatel.com>
Subject: Re: 10 SEP 1998 ==> 1998-09-10
Message-Id: <u4stp3bg9.fsf@vansel.alcatel.com>

Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at> writes:

> Re: 10 SEP 1998 ==> 1998-09-10, Claes-Goran
> <c-g-magn@dsv.su.se> said:
> 
> Claes-Goran> I am trying to convert $rest which consist of a
> Claes-Goran> date in the form DD MMM YYYY (10 SEP 1998). I
> Claes-Goran> want to print it as YYYY-MM-DD (1998-09-10).
> 
> perldoc Date::Manip
> perldoc Date::DateCalc
> perldoc POSIX (strftime)

Or, without loading a lot of modules in order to do a simple transformation:

%months=( JAN => 1, FEB => 2, MAR => 3, APR => 4, MAY => 5,
          JUN => 6, JUL => 7, AUG => 8, SEP => 9, OCT => 10,
          NOV => 11,DEC => 12 );

$rest = "10 SEP 1998";    # or however you need to get your $rest

($day,$month,$year) = split ' ', $rest;
printf "%s-%0.2d-%0.2d",$year,$months{$month},$day;

-- 
-o- Brad Murray                  "Most programs aren't released;
-o- Alcatel Canada                they are allowed to escape."
-o- Software Analyst                        Jeff DelPapa


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

Date: 30 Sep 1998 16:49:15 +0200
From: "Matt D. Herold" <matt@bessie.franken.de>
Subject: Re: 10 SEP 1998 ==> 1998-09-10
Message-Id: <6utgdb$cd8$1@bessie.franken.de>

Claes-Goran Magnusson <c-g-magn@dsv.su.se> wrote:

> if ($tag eq 'DATE') {
>    $rest =~ m/(\d\d\d\d$)/o;
>    print " $1";
>    $rest =~ m/[A-Z]{3}/o;

This must be
     $rest =~ m/([A-Z]{3})/o;

Ciao
Matt
-- 
Matt D. Herold <matt@bessie.franken.de>   +++++ PGP-Mail welcome ++++++
-- http://www.franken.de/users/bessie/   ++ key in herold/pgp-key.asc ++ 
-- tel: +49-911-3849229                   +++++++ ID: 5AA3308D ++++++++
         !! neue eMail-Adresse, alte aber weiterhin g|ltig !!


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

Date: 30 Sep 1998 12:45:46 -0400
From: Uri Guttman <uri@camel.fastserv.com>
Subject: Re: 10 SEP 1998 ==> 1998-09-10
Message-Id: <sarbtnxtupx.fsf@camel.fastserv.com>


  MDH> Claes-Goran Magnusson <c-g-magn@dsv.su.se> wrote:
  MDH> if ($tag eq 'DATE') {
  MDH> $rest =~ m/(\d\d\d\d$)/o;
  MDH> print " $1";
  MDH> $rest =~ m/[A-Z]{3}/o;

  MDH> This must be
  MDH>      $rest =~ m/([A-Z]{3})/o;

in all the above cases, the /o modifier is not needed since you have a
fixed regex (no interpolation).

uri

-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: 30 Sep 1998 11:41:31 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
Subject: Re: assign name and content of a variable provided from a file
Message-Id: <x3yu31pk3pw.fsf@tigre.matrox.com>


"Schimpeler U. DP/EVA" <USchimpeler@pfh.sel.alcatel.de> writes:

> example lines:
>   var_name_1 para_1a para_1b
>   var_name_2
>   var_name_3 para_3
> 
> 2. the problem: How to define a variable with the name given in column 1
> and assign the values stated in the columns following the name?

look into using soft references.
Another way would be to use a hash with the variable names as keys,
and the stated values as values.

while (<FILE>) {
	chomp;
	s/^\s+|\s+$//g;
	@ary = split /\s+/;
	$key = shift @ary;
	$hash{$key} = [@ary];
}

Hope this helps,
-- 
Ala Qumsieh             |  No .. not Just Another
ASIC Design Engineer    |  Perl Hacker!!!!!
Matrox Graphics Inc.    |
Montreal, Quebec        |  (Not yet!)


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

Date: Wed, 30 Sep 1998 15:05:43 GMT
From: hazard@my-dejanews.com
Subject: bug in Berkley DB/DB_File?
Message-Id: <6uthc7$iku$1@nnrp1.dejanews.com>

Hi.

I had a small program which accounted all received mail in Berkley DB
database hash. Everything worked fine until now, I get a segmentation fault
after scanning about a half of the databse. If I do %keys , I get a
segmentation fault immediately. The base wasnt corrupted.

I copied the base and tried it on a RH5.0 glibc box - with the same results as
on the RH4.2 with berkley db 1.85.

Can anyone help me debug the problem? Or it's a problem with perl DB_File
module/berkley db? I runned it with perl -d and it segfaults in Carp.pm:
DB_File::NEXTKEY(/usr/lib/perl5/Carp.pm:94):
94:	$$msg

I can give anyone interested a copy of the test perl script which reproduces
segfault and copy of the base itself. Please, CC your answers to
hazard.bsn(at)maks.net

Vladimir

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 30 Sep 1998 11:42:19 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
Subject: Re: epoch time
Message-Id: <x3ysoh9k3ok.fsf@tigre.matrox.com>


Kamran <kamrani@ifi.uio.no> writes:

> Is there any function in perl which can read and set the
> epoch time, i.e. number of seconds since Jan. 1. 1970 ?
> Something like javas Date().
> 

check out the time() function.

-- 
Ala Qumsieh             |  No .. not Just Another
ASIC Design Engineer    |  Perl Hacker!!!!!
Matrox Graphics Inc.    |
Montreal, Quebec        |  (Not yet!)


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

Date: Wed, 30 Sep 1998 11:46:26 -0500
From: "Mark P." <imchat@imchat.com>
To: nigel.parker@iee.org
Subject: Re: Locking files, counter, unique serial number...
Message-Id: <36126061.51DBA6FF@imchat.com>

Try this sub. This is Selena Sols counter which works just great.
$counter_file = "./data/form.counter";
  sub counter
    {

# Open up the counter file.  If the counter file cannot be opened,
# however, access the &open_error routine

    open (COUNTER_FILE, "$counter_file") || &open_error($counter_file);

# Check to see what number the counter is currently on and assign that
# value to $_

    while (<COUNTER_FILE>)
      {
      $item_number = "$_";
      }
    close (COUNTER_FILE);

# Add one to that number, change the counter file to the new number,
# return the number to the mian script, and close the counterfile.

    $item_number += 1;
    open (COUNTER_FILE, ">$counter_file") || &open_error($counter_file);
    print COUNTER_FILE "$item_number\n";
    close (COUNTER_FILE);
    return $item_number;
    }

  sub open_error
    {

# Let the client know that the script was unable to open the requested file
# and then die so that the routine does not continue

    print "I am really sorry, but for some reason I was unable to open
    <P>$counter_file<P>  Would you please make sure that the filename is
    correctly defined in the script, it actually exists, and has the
    right permissions relative to the web browser.  Thanks!";
    die;
    }


Nigel Parker wrote:

> I would like some way of providing unique serial numbers to electronic
> documents.  I've tried the example code from the FAQ "I still don't get
> locking. I just want to increment the number in the file. How?"
>
> That code is:
>    sub get_and_update_rfp_counter {
>       sysopen(FH, "rfp_counter", O_RDWR|O_CREAT, 0644);
>       flock(FH, 2);
>       my $count = <FH> || 0;
>       seek(FH, 0, 0);
>       truncate(FH, 0);
>       print FH $count+1, "\n";
>       close FH;
>       $form{'serial_no'} = "E-".substr($count, 0, -1);
>    }
>
> But I keep getting the following error:
> can't write rfp_counter: Bad file descriptor at C:\WebSite\cgi-shl\epmt.pl
> line 528, <FH> chunk 1.
>
> This code won't work through WebSite Pro (on NT4) or SunOS running apache.
> However, it *did* work to start with under WebSite, but then started
> giving the error above (I didn't think I changed anything)!
>
> Anyone know what's wrong here?  Or maybe where I can get hold of a
> unique/incrementing number module which supports file locking (a
> longshot, I know)?
>
> Perhaps I'm going about this in completely the wrong way!  I'd appreciate
> any suggestions.
>
> PS  What does <FILEHANDLE> mean (can't find it anywhere)?
>
> Cheers.
>
> Nigel
> --
> Girton College, Cambridge, England, CB3 0JG.             Tel: 0411 384803
>
> http://welcome.to/nigels                             nigel.parker@iee.org





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

Date: Wed, 30 Sep 1998 11:47:31 -0500
From: "Mark P." <imchat@imchat.com>
To: nigel.parker@iee.org
Subject: Re: Locking files, counter, unique serial number...
Message-Id: <361260A1.6656D044@imchat.com>

Try this sub. This is Selena Sols counter which works just great.
$counter_file = "./data/form.counter";
  sub counter
    {

# Open up the counter file.  If the counter file cannot be opened,
# however, access the &open_error routine

    open (COUNTER_FILE, "$counter_file") || &open_error($counter_file);

# Check to see what number the counter is currently on and assign that
# value to $_

    while (<COUNTER_FILE>)
      {
      $item_number = "$_";
      }
    close (COUNTER_FILE);

# Add one to that number, change the counter file to the new number,
# return the number to the mian script, and close the counterfile.

    $item_number += 1;
    open (COUNTER_FILE, ">$counter_file") || &open_error($counter_file);
    print COUNTER_FILE "$item_number\n";
    close (COUNTER_FILE);
    return $item_number;
    }

  sub open_error
    {

# Let the client know that the script was unable to open the requested file
# and then die so that the routine does not continue

    print "I am really sorry, but for some reason I was unable to open
    <P>$counter_file<P>  Would you please make sure that the filename is
    correctly defined in the script, it actually exists, and has the
    right permissions relative to the web browser.  Thanks!";
    die;
    }


Nigel Parker wrote:

> I would like some way of providing unique serial numbers to electronic
> documents.  I've tried the example code from the FAQ "I still don't get
> locking. I just want to increment the number in the file. How?"
>
> That code is:
>    sub get_and_update_rfp_counter {
>       sysopen(FH, "rfp_counter", O_RDWR|O_CREAT, 0644);
>       flock(FH, 2);
>       my $count = <FH> || 0;
>       seek(FH, 0, 0);
>       truncate(FH, 0);
>       print FH $count+1, "\n";
>       close FH;
>       $form{'serial_no'} = "E-".substr($count, 0, -1);
>    }
>
> But I keep getting the following error:
> can't write rfp_counter: Bad file descriptor at C:\WebSite\cgi-shl\epmt.pl
> line 528, <FH> chunk 1.
>
> This code won't work through WebSite Pro (on NT4) or SunOS running apache.
> However, it *did* work to start with under WebSite, but then started
> giving the error above (I didn't think I changed anything)!
>
> Anyone know what's wrong here?  Or maybe where I can get hold of a
> unique/incrementing number module which supports file locking (a
> longshot, I know)?
>
> Perhaps I'm going about this in completely the wrong way!  I'd appreciate
> any suggestions.
>
> PS  What does <FILEHANDLE> mean (can't find it anywhere)?
>
> Cheers.
>
> Nigel
> --
> Girton College, Cambridge, England, CB3 0JG.             Tel: 0411 384803
>
> http://welcome.to/nigels                             nigel.parker@iee.org





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

Date: Wed, 30 Sep 1998 16:53:07 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Locking files, counter, unique serial number...
Message-Id: <TltQ1.1137$_c5.10585763@news.shore.net>

Mark P. (imchat@imchat.com) wrote:
: Try this sub. This is Selena Sols counter which works just great.
: $counter_file = "./data/form.counter";
:   sub counter
:     {
[snip]

I hesitate to use "great" and "Selena Sol" in the same sentence.  Did
I miss something or is the code snippet which you offered missing
flock()?

--
Nate Patwardhan|root@localhost
"Fortunately, I prefer to believe that we're all really just trapped in a
P.K. Dick book laced with Lovecraft, and this awful Terror Out of Cambridge
shall by the light of day evaporate, leaving nothing but good intentions in
its stead." Tom Christiansen in <6k02ha$hq6$3@csnews.cs.colorado.edu>


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

Date: Wed, 30 Sep 1998 16:19:33 +0100
From: Nigel Parker <95ncp@eng.cam.ac.uk>
Subject: Re: mailing attachments in Perl
Message-Id: <Pine.HPP.3.96L.980930161240.13693A-100000@club.eng.cam.ac.uk>

On 30 Sep 1998, Tony Curtis wrote:

: Re: mailing attachments in Perl, foxman
: <foxman@affection.com> said:
: 
: foxman> okay, so we can use simple commands like "sendmail"
: foxman> or "mail" to send messages to an email.  but how can
: foxman> we send attachments also?  say i wanted to send a
: foxman> document or an image, how would i specify this
: foxman> format?
: 
: as a start:
: 
:     perldoc MIME::Base64
:     perldoc MIME::Tools
:     perldoc Mail::Send

I have a small uucode routine which may be better than importing a library
or module...

   sub uu_encode {
      my ($in) = @_;
      foreach $line ($in =~ /.{1,45}/gs) {
            push @result, pack("u", $line);
      }
      join("", "begin 644 rfp.html\n", @result, "end\n");
   }

So you just need to open sendmail, print header, then
   print &uu_encode($message).

Mime is even easier to output, but not all mail readers will read it...

Cheers.


Nigel
-- 
Girton College, Cambridge, England, CB3 0JG.             Tel: 0411 384803

http://welcome.to/nigels                             nigel.parker@iee.org



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

Date: Wed, 30 Sep 1998 16:12:19 GMT
From: intuitiveknowledge@yahoo.com
Subject: Re: mod_perl configuration
Message-Id: <6utl92$n8n$1@nnrp1.dejanews.com>

In article <slrn6urhgb.9t9.randy@theory.uwinnipeg.ca>,
  randy@theory.uwinnipeg.ca (Randy Kobes) wrote:
> >> >Alias /perl/ /usr/apache/share/perl/
> >> ><Location /perl>
> >> >SetHandler perl-script
> >> >PerlHandler Apache::Registry
> >> >Options ExecCGI
> >> ></Location>
>    In your script, are you sending the HTTP header explicitly like
> 	print "Content-type: text/html\n\n";
> I believe you have to do this with PerlSendHeader set to be On within that
> Location. However, if you're using CGI.pm to send the HTTP header in
> your script, then PerlSendHeader should be Off.

Your advice works fine for me. Could you explain what exactly PerlSendHeader
is? I looked at the Apache doc and nothing was written there... Thanks in
advance.

joe

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Wed, 30 Sep 1998 10:44:39 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: mod_perl file closing problem
Message-Id: <comdog-ya02408000R3009981044390001@news.panix.com>
Keywords: from just another new york perl hacker

In article <1XoQ1.304$Fl6.6169565@news.abs.net>, ryan@mail.ramresearch.com (Ryan McGuigan) posted:

>you can't use exit; when using mod_perl

you could, but it's not smart to do so in most cases.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>


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

Date: 30 Sep 1998 11:43:33 -0400
From: Uri Guttman <uri@camel.fastserv.com>
Subject: Re: need a regular expressions expert....
Message-Id: <sarpvcdtxlm.fsf@camel.fastserv.com>

>>>>> "A" == Abigail  <abigail@fnx.com> writes:

  A> ++ This doesn't make much sense to me, but if you don't want to use
  A> ++ neagtion, just specify a different regex.
  A> ++ 
  A> ++ /^[^B][^A][^D]/
  A> ++ 
  A> ++ Comes to mind as one way to do it.

  A> But that disallows "HAPPY" as well.

dear abby,

i can say what i want about this since you plonked me. could you come up
with a less helpful posting? why not let others who actually say why
something is wrong post and leave your intellect to you .sigs?

uri

-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: Wed, 30 Sep 1998 16:08:05 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: need a regular expressions expert....
Message-Id: <FHsQ1.1143$7Q6.7658998@news2.voicenet.com>

Uri Guttman <uri@camel.fastserv.com> wrote:
>  A> ++ /^[^B][^A][^D]/
>  A> But that disallows "HAPPY" as well.
>dear abby,
>
>i can say what i want about this since you plonked me. could you come up
>with a less helpful posting? why not let others who actually say why
>something is wrong post and leave your intellect to you .sigs?

I've got to call you on this one.  This was helpful, because HAPPY
doesn't match the regex.  It was just another example.

In my own defense, I was totally thrown by the bizarre nature of the
question (As it seems many other people were as well).  Firing off the
first regex that comes to mind is generally not a good idea (That's what
I did in this case).

Note to self: test all code before posting ... even^Wespecially trivial
cases.

-- 
Matt Knecht - <hex@voicenet.com>


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

Date: 30 Sep 1998 11:39:45 -0400
From: Uri Guttman <uri@camel.fastserv.com>
Subject: Re: need a regular expressions expert....
Message-Id: <sarr9wttxry.fsf@camel.fastserv.com>

>>>>> "JP" == John Porter <jdporter@min.net> writes:

  JP> Uri Guttman wrote:
  >> >>>>> "MB" == Matthew Bafford <dragons@scescape.net> writes:
  MB> if     ( /^[^B][^A][^D]$/ )
  >> 
  >> boy, two exactly same incorrect answers to a single post. see my
  >> followup to matt knecht. you do have the $ anchor but the rest is very
  >> wrong. negating each char is not negating the string.
  >> it is very 'reese' (see my post about a new perl term) to do this.

  JP> I'm sorry, but that is an incorrect usage of the term.

  JP> You should not equate honest, innocent, newbie, clue deficiency
  JP> with wanton disregard for rationality.

i actually agree. i am trying to get the proper usage and definition
down. but i want it to be more than wanton disregard. general
irrationality should be covered by the term. but newbie innocence could
be an excuse not to use it.

uri

-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: Wed, 30 Sep 1998 11:16:24 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Need IP Address Sort Subroutine
Message-Id: <36124B48.DA6515B8@min.net>

Michal Rutka wrote:
> 
> BTW your code do not
> work for IP 200.255.255.255. On my machine it returns -1.

Then something is wrong with your machine.
I do not get that result.  I get 3372220415.


> Anyway, every address above 127.255.255.255 is 'unsortable'
> by you. It just 50% of all addresses so who cares?

Not on my machine.  What's your platform?


> Horror.

4q.


> @ips_sorted = sort {
>   pack("C4",split(/\./,$a)) cmp pack("C4",split(/\./,$b))
> } @ips;

Good idea.  
But your code causes the redundant splitting and packing
of some (possibly very many) of the strings.
You could wrap that little operation with a sub
which you can then memoize:

  use Memoize;
  sub pack_split { pack("C4",split(/\./,shift)) }
  memoize 'pack_split';
  @ips_sorted = sort { pack_split($a) cmp pack_split($b) } @ips;

Or you could use a Schwartzian Transform:

  @ips_sorted =
    map  { $_->[0] }
    sort { $a->[1] cmp $b->[1] }
    map  { $_, pack("C4",split(/\./,$_)) }
      @ips;


> Should be faster and without this Schwartzian thing (what is it, anyway)?

Get a life.  (Which is to say, read this newsgroup for a while.)

> BTW. Your 'Schwartzian' code does not work for me. I.e. lot of uninitialized
> values and result is empty.

Like I said...

-- 
John "Many Jars" Porter


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

Date: Wed, 30 Sep 1998 11:18:07 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Need IP Address Sort Subroutine
Message-Id: <36124BAF.3B2D5792@min.net>

sjagadish@my-dejanews.com wrote:
> 
> > Why? IP address is a string of four characters. It is better to
> > sort them as strings.
> 
> Wont work. If u sorted addreses as strings, u'd have 130.4.aaa.bbb listed
> AFTER 130.111.xxx.yyy while arranging in ascending order because 1 comes
> before 4

No, that's not what's going on.
He's converting each number (0..255) into the corresponding character,
and packing the four resulting characters into a string.
Remember, Perl doesn't care what bits are set in a byte, it can
still treat it as a "character".

-- 
John "Many Jars" Porter


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

Date: 30 Sep 1998 17:33:23 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
To: jdporter@min.net
Subject: Re: Need IP Address Sort Subroutine
Message-Id: <lasoh9y5rw.fsf@erh.ericsson.se>

John Porter <jdporter@min.net> writes:
> Michal Rutka wrote:
> > 
> > BTW your code do not
> > work for IP 200.255.255.255. On my machine it returns -1.
> 
> Then something is wrong with your machine.
> I do not get that result.  I get 3372220415.

Sorry, typo, it should be 'for IP 255.255.255.255'.

[...]
> Not on my machine.  What's your platform?

This is what uname says:
SunOS erhs86 5.5.1 Generic_103640-08 sun4u sparc SUNW,Ultra-Enterprise

[...]
>   use Memoize;
>   sub pack_split { pack("C4",split(/\./,shift)) }
>   memoize 'pack_split';
>   @ips_sorted = sort { pack_split($a) cmp pack_split($b) } @ips;
> 

Hym. Never heard about Memorize. It is not present in my distribution.

> Or you could use a Schwartzian Transform:
> 
>   @ips_sorted =
>     map  { $_->[0] }
>     sort { $a->[1] cmp $b->[1] }
>     map  { $_, pack("C4",split(/\./,$_)) }
>       @ips;
> 
> 
> > Should be faster and without this Schwartzian thing (what is it, anyway)?
> 
> Get a life.  (Which is to say, read this newsgroup for a while.)

I don't have so much time to follow this group. I have some real work
to do too..

> > BTW. Your 'Schwartzian' code does not work for me. I.e. lot of uninitialized
> > values and result is empty.
> 
> Like I said...

The point is that this thing is not portable, at least it does not
work on my Sparc. Therefore I will not bother to learn about things
which can cause compability problems. I put it rather on the banned
syntax list. The same counts for integer conversion.

> 
> -- 
> John "Many Jars" Porter

Regards

Michal


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

Date: 30 Sep 1998 12:03:45 -0400
From: Uri Guttman <uri@camel.fastserv.com>
To: John Porter <jdporter@min.net>
Subject: Re: Need IP Address Sort Subroutine
Message-Id: <sarn27htwny.fsf@camel.fastserv.com>

>>>>> "JP" == John Porter <jdporter@min.net> writes:

  JP> Michal Rutka wrote:
  >> 
  >> BTW your code do not
  >> work for IP 200.255.255.255. On my machine it returns -1.

  JP> Then something is wrong with your machine.
  JP> I do not get that result.  I get 3372220415.

  >> Anyway, every address above 127.255.255.255 is 'unsortable'
  >> by you. It just 50% of all addresses so who cares?

  JP> Not on my machine.  What's your platform?


  >> Horror.

  JP> 4q.

you tell him, john! :-)

  >> @ips_sorted = sort {
  >> pack("C4",split(/\./,$a)) cmp pack("C4",split(/\./,$b))
  >> } @ips;

  JP> Good idea.  

his split and pack is a good idea but you are right, of course, about
the redundancy that schwartzian removes.

  JP> Or you could use a Schwartzian Transform:

  JP>   @ips_sorted =
  JP>     map  { $_->[0] }
  JP>     sort { $a->[1] cmp $b->[1] }
  JP>     map  { $_, pack("C4",split(/\./,$_)) }
  JP>       @ips;

i think that should be
  JP>     map  { [$_, pack("C4",split(/\./,$_))] }

you never created the anon array.

  >> Should be faster and without this Schwartzian thing (what is it, anyway)?

  JP> Get a life.  (Which is to say, read this newsgroup for a while.)

  >> BTW. Your 'Schwartzian' code does not work for me. I.e. lot of
  >> uninitialized values and result is empty.

he did find your bug, but he didn't fix it.


but why use the temp array when you can do it i
linearly? you save the allocation of the temp arrays and dereferences in
the sort vs. the unpack at the end. and i use the socket routines to do
the work.

try this (tested):

perl -MSocket -le 'print join( "\n", map{ inet_ntoa($_) } sort map
{inet_aton $_ } <>)'

uri

-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: 30 Sep 1998 11:37:44 -0400
From: Uri Guttman <uri@camel.fastserv.com>
To: comdog@computerdog.com (brian d foy)
Subject: Re: new term for illogical
Message-Id: <saru31ptxvb.fsf@camel.fastserv.com>

>>>>> "bdf" == brian d foy <comdog@computerdog.com> writes:

  bdf> In article <36115CDB.15E38D59@bbnplanet.com>, Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> posted:
  >> Uri Guttman wrote:
  >> 
  >> HappyFunBall! not girl. grrrr. Do not taunt.

  bdf> yeah!  he really reesed that one. ;)

brian,

i did it on purpose. it got a reaction. i do know her tag well.

but i am glad you are using the new term!

uri

-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: Wed, 30 Sep 1998 15:07:01 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: POLL: Perl features springing into your face
Message-Id: <8c90j1d4hr.fsf@gadget.cscaper.com>

>>>>> "Ilya" == Ilya Zakharevich <ilya@math.ohio-state.edu> writes:

Ilya> There should be much more!  I hoped that Tom and Random keep a list of
Ilya> their peeves obtained when teaching, but apparently these misfeatures
Ilya> bite experienced people only: beginner just do not use things which
Ilya> are complicated enough, or do not recognize that something is not
Ilya> their fault (or even do not recognize that it does not do what they
Ilya> wanted...).

Who is "Random"? :-)

I can certainly contribute to this list... and will do so when I'm not
waiting 4 seconds for characters to echo as I am today. :)

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Wed, 30 Sep 1998 15:13:26 GMT
From: droby@copyright.com
Subject: Re: restricting script execution?
Message-Id: <6uthql$itc$1@nnrp1.dejanews.com>

In article <361133C6.788288DD@bbnplanet.com>,
  Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> wrote:
>
> > > Reading the source is fun :)
> >
> > "To a sufficiently fuzzy definition of 'fun'." :-)
>
> Well, I don't get out much. Besides, where are you going to find goodies
> like this...?
>
>  * "...we will have peace, when you and all your works have
> perished--and
>  * the works of your dark master to whom you would deliver us.  You are
> a
>  * liar, Saruman, and a corrupter of men's hearts."  --Theoden
>
> > Oh well, might as well get on with it :-(
>

I suspect you could probably find it the same place Larry (or some other
implementor) did - "The Lord of the Rings" by J.R.R. Tolkien.

The use of such quotes in context with source code is also an art though.

--
Don Roby

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Wed, 30 Sep 1998 15:23:41 GMT
From: ankur_palkar@hotmail.com
Subject: Sending HTML file as an attachment.
Message-Id: <6utidr$jkg$1@nnrp1.dejanews.com>

Hi!
   I have written a Perl script which takes some from a user
and generates an HTML file which is to be mailed to the user.
Can anyone tell me how to send a file as an attachment of
type TEXT/HTML in PERL? I tried to put "Content Type : Text/HTML"
at the beginning of a file, but it displays all the contenets
as text in pine/mailx.

   Thanks,
     Ankur

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Wed, 30 Sep 1998 15:49:51 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Sending HTML file as an attachment.
Message-Id: <zqsQ1.5425$F7.20269909@news.itd.umich.edu>

In article <6utidr$jkg$1@nnrp1.dejanews.com>,
 <ankur_palkar@hotmail.com> wrote:
>   I have written a Perl script which takes some from a user
>and generates an HTML file which is to be mailed to the user.
>Can anyone tell me how to send a file as an attachment of
>type TEXT/HTML in PERL? I tried to put "Content Type : Text/HTML"
>at the beginning of a file, but it displays all the contenets
>as text in pine/mailx.

You'll want to take a look at RFC1521.  Having done that, you'll need
to use a mail delivery agent which allows you to insert arbitrary header
lines, such as sendmail.

Just to inject some Perl content into this thread, here's a script I wrote
to fetch RFC documents:

----------------------------------------------------------------------
use Net::FTP;

$address = "put your e-mail address here";

$rfc = shift or die "No RFC specified\n";

$ftp = new Net::FTP("ftp.ncren.net");
login $ftp "anonymous", $address or die "Unable to log in\n";
cwd   $ftp "rfc";
get   $ftp sprintf("rfc%04d.txt", $rfc), "RFC$rfc"
    or die "Could not fetch document\n";
quit  $ftp;

print "RFC$rfc retrieved.\n";
----------------------------------------------------------------------

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


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

Date: Wed, 30 Sep 1998 17:17:11 +0100
From: Nigel Parker <95ncp@eng.cam.ac.uk>
To: ankur_palkar@hotmail.com
Subject: Re: Sending HTML file as an attachment.
Message-Id: <Pine.HPP.3.96L.980930171616.15085B-100000@club.eng.cam.ac.uk>

On Wed, 30 Sep 1998 ankur_palkar@hotmail.com wrote:

: Hi!
:    I have written a Perl script which takes some from a user
: and generates an HTML file which is to be mailed to the user.
: Can anyone tell me how to send a file as an attachment of
: type TEXT/HTML in PERL? I tried to put "Content Type : Text/HTML"
: at the beginning of a file, but it displays all the contenets
: as text in pine/mailx.

See other thread "mailing attachments in perl".


Nigel
-- 
Girton College, Cambridge, England, CB3 0JG.             Tel: 0411 384803

http://welcome.to/nigels                             nigel.parker@iee.org




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

Date: Wed, 30 Sep 1998 16:02:23 GMT
From: aahz@netcom.com (Aahz Maruch)
Subject: Re: Simple database recommendation needed
Message-Id: <aahzF03tw0.1D8@netcom.com>

In article <36116018.38991FDC@harris.com>,
Charlie Davies  <cdavies@harris.com> wrote:
>
>I am working on an UNIX based application where I need a simple
>database. I was looking for a recommendation from this group.
>
>The database will be fairly small 20K-40K records. Each record would
>have 3 text fields, each containing 50-60 characters. During a normal
>session, I will have to open the DB, find a given record, update its
>content, and close the DB.

I remember seeing a recent announcement for a SQL database implemented
entirely in Perl, but I can't find it again.  Anyone else remember it?
-- 
                      --- Aahz (@netcom.com)

Hugs and backrubs -- I break Rule 6     <*>     -=> http://www.rahul.net/aahz
Androgynous poly kinky vanilla queer het

Zippergate: if they can get you asking the wrong questions, they don't
need to worry about the answers.  Shut up, already!


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

Date: 30 Sep 1998 10:19:16 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
Subject: Re: Some kind of 'real' user interface?
Message-Id: <x3yvhm5k7iz.fsf@tigre.matrox.com>


"David" <david@nospam.port80.com> writes:

> I'm trying to work out how I can add some kind of 'graphical
> interface' to my Perl programs running under NT. I don't mind
> using a DOS window interface (with limited menus, and graphics)
> but a Windows interface would be even better.

Look up the Perl/Tk module available from CPAN

www.perl.com/CPAN/

-- 
Ala Qumsieh             |  No .. not Just Another
ASIC Design Engineer    |  Perl Hacker!!!!!
Matrox Graphics Inc.    |
Montreal, Quebec        |  (Not yet!)


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

Date: Wed, 30 Sep 1998 14:57:23 GMT
From: droby@copyright.com
Subject: Re: SRC: encrypt your Perl scripts! :-)
Message-Id: <6utgsj$hvi$1@nnrp1.dejanews.com>

In article <361121FE.373723A4@bbnplanet.com>,
  Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> wrote:
> Greg Bacon wrote:
>
> > # Copyright (c) 1998 Greg Bacon.  All Rights Reserved.
> > # This program is free software.  You may distribute it or modify
> > # it (perhaps both) under the terms of the Artistic License that
> > # comes with the Perl Kit.
>
> I don't know why, but I find this to be pretty ironic(r).
>

Indeed.  But not to worry.  Security by obscurity and all that ...

#! /usr/bin/perl -w

# Copyright (c) 1998 Don Roby.  All Rights Reserved.
# This program is free software.  You may distribute it or modify
# it (perhaps both) under the terms of the Artistic License that
# comes with the Perl Kit.
#
# Why you'd want to distribute it, modify it, or even use it I can't really
# imagine.  It is not useful at all unless someone has used Greg Bacon's
# encrypt script, being that this decrypts the product of his program.
# ;-)
#
# It in fact includes some code lifted from the encrypt program, which
# I hope is ok under the Artistic License.
#
use strict;
use integer;

foreach my $file (@ARGV) {
    unless (open FILE, $file) {
        warn "$0: failed open $file: $!\n";
        next;
    }

    $_ = '';		# Why do I need this?  It's silly to need this!
    $_ = <FILE> until (/my \$key/);
    s/\D+//;
    s/\;//;

    my $key = $_;

    $_ = <FILE>
        until /__END__/;

    local $/;
    my $out = pack "c*",
             map { $_ = $_ ^ $key }
             unpack "c*", <FILE>;

    close FILE;

    unless (open FILE, ">$file") {
        warn "$0: failed open >$file: $!\n";
        next;
    }

    print FILE $out;
    close FILE;;
}

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 30 Sep 1998 15:15:01 GMT
From: cypher5@die.spammers.yahoo.com (Cypher)
Subject: Stock paging, anyone seen this script?
Message-Id: <6uthtl$jjo$0@205.211.154.11>

Hi,
I have been working on a script to page delayed stock quotes to alpha
pagers. I have a command line paging program installed. I can't seem
to get the script to get the quotes and parse.....does anyone know of
a script that will do this?!
If not does anyone know of a way I might be able to do this?

Regards,
Cypher.
--
Always take life with a grain of salt,
 ..plus a slice of lemon
 ..and a shot of tequila.
--
To email me please take the (die.spammers) out of my address.


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

Date: Wed, 30 Sep 1998 14:27:39 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Substitution-Problem
Message-Id: <6utf4r$frj$1@nnrp1.dejanews.com>

In article <6ut90f$8fm$1@nnrp1.dejanews.com>,
  guelkev@de.polygram.com wrote:
> Hello everybody,
> I have a problem with substitution in perl. I want to cut the
> "http://serveradress" Part from an URL to become a local URL.
>
> I tried the following statement:
> $url =~ s@http://*/@/@;
> which should replace the http://..../ with a single /.
>
> The result is, that it replace the part of the string I wrote directly but not
> that part which is included in the "*".
[snip]

I'm not sure what you mean by a local URL (directory path?), but you
forgot to put the '.' "any character" character in front of the '*':

$url =~ s@http://.*/@/@;

will work, but doesn't seem very useful to me. Do you really want to
replace what matches with '/', or do you need to use a local directory
path? You may want to use a non-greedy in there on the '.*' (or maybe
not ... I don't know what you want to accomplish :)

Patrick Timmins
$monger{Omaha}[0]

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 30 Sep 1998 12:03:22 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
Subject: Re: Substitution-Problem
Message-Id: <x3yr9wtk2ph.fsf@tigre.matrox.com>


guelkev@de.polygram.com writes:

> 
> Hello everybody,
> I have a problem with substitution in perl. I want to cut the
> "http://serveradress" Part from an URL to become a local URL.
> 
> I tried the following statement:
> $url =~ s@http://*/@/@;
> which should replace the http://..../ with a single /.
> 
> The result is, that it replace the part of the string I wrote directly but not
> that part which is included in the "*".

In a regexp, * means to match zero or more of the preceeding
character, which happens to be a "/" in your regexp. So you are
actually matching "http:/" followed by zero or more "/"
characters. This will match "http://" only in an expression like:

http://www.somewhere.com/something

The regexp that you need would be:

s@http://.*/@/@;

But notice that * is a greedy matcher by default. Thus, in an
expression like:

http://www.somewhere.com/something/somedir/file.html

The above regexp will match
"http://www.somewhere.com/something/somedir/" which is probably not
what you want.

Try this:

s@http://[^/]+@@;

Hope this helps,
-- 
Ala Qumsieh             |  No .. not Just Another
ASIC Design Engineer    |  Perl Hacker!!!!!
Matrox Graphics Inc.    |
Montreal, Quebec        |  (Not yet!)


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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