[7375] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1000 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 9 13:07:22 1997

Date: Tue, 9 Sep 97 10:00:24 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 9 Sep 1997     Volume: 8 Number: 1000

Today's topics:
     Re: A simple regular epression question. <mgiroux@icon.com>
     Arrays <kalpana@ece.vill.edu>
     Re: Arrays (Mike Stok)
     Can you escape from the debugger ? (Helmut Jarausch)
     Re: complex pattern?!? it shouldn't be, i think :) <friedman@uci.edu>
     Re: DNS lookup with gethostbyaddr? (Michael Budash)
     Re: Doubling up a character in a string <matthew.rice@ftlsol.com>
     Escaping Newline in a HERE-document - HowTo ? (Helmut Jarausch)
     Re: flock() problem <rootbeer@teleport.com>
     Re: Getting rid of \n in textarea input (Jay Flaherty)
     Re: Getting rid of \n in textarea input (dave)
     Re: HELP!  Subroutine is making me cry! <seay@absyss.fr>
     How do you set flow control via perl?  (Controlling a d (Jaye Mathisen)
     Looking for Report Generator yaron@netvision.net.il
     Q: bitwise operators and perl <cam@plain.co.nz>
     Re: Q: HOWTO - Manifest Constants <seay@absyss.fr>
     Re: Testing attempts fail.. <rootbeer@teleport.com>
     Re: Um... a bug? (Jason Gloudon)
     Re: Um... a bug? <rootbeer@teleport.com>
     Re: Undefined subroutine &main::CgiDie called at util.p <seay@absyss.fr>
     undump program for Linux/ELF <vvv@west-call.com>
     Weird things with perl conversions? <sbekman@iil.intel.com>
     Re: what has it got in its ssocketses? <qdtcall@esb.ericsson.se>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 09 Sep 1997 11:18:50 -0400
From: Mike Giroux <mgiroux@icon.com>
To: Zohar Tsaba <ztsaba@iil.intel.com>
Subject: Re: A simple regular epression question.
Message-Id: <341568DA.1690@icon.com>


Zohar Tsaba wrote:
> 
> Hi.
> 
> How can I match only 'not 00' ?
> 
> When I tried to use:
> 
> $x = "01010100001100" ;
> $x =~ s/[^00]/X/g ;     # I want to replace 'not 00' with X
>                         #
> 
> printf "$x\n" ;         # $x is '0X0X0X0000XX00'
>                         # which means, I replaced 'not 0 or not 0'

You're not using the character class properly.  A construct like
[^00]
or
[^a-z]
means to match any _one_ character that is NOT one of the characters
after the ^.  In the first case, that means anything but an '0', even
though the zero is in the class twice.  In the second case, it would
mean any _one_ character not in the range from a to z.  Changing the
second class to [^a-za-zzzzzqqqqsss] wouldn't change the set of
characters matched; it would still mean exactly the same thing as
[^a-z].

The general rule is that any [] character class matches exactly one
position, unless followed by +,*,?,{n},etc...

What you want to do is match 2 consecutive "not-'0'"'s.  To do that,
you'd need to do

$x~=s/[^0][^0]/X/g;
or
$x~=s/[^0]{2}/X/g;

I hope this helps, and that it wasn't too verbose...
--
Mike Giroux
mgiroux@icon.com (work)
rmgiroux@worldnet.att.net (home)


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

Date: Tue, 9 Sep 1997 11:01:41 -0400
From: Kalpana Reddy Kothapally <kalpana@ece.vill.edu>
Subject: Arrays
Message-Id: <Pine.SV4.3.95.970909110108.28793B-100000@fuzzy.ee.vill.edu>

Hi,

Can anybody tell me how can implement 2 dimensional array in PERL?

Thanks
 ..Kalpana



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

Date: 9 Sep 1997 15:34:32 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Arrays
Message-Id: <5v3qa8$k0t@news-central.tiac.net>

In article <Pine.SV4.3.95.970909110108.28793B-100000@fuzzy.ee.vill.edu>,
Kalpana Reddy Kothapally  <kalpana@ece.vill.edu> wrote:

>Can anybody tell me how can implement 2 dimensional array in PERL?

If you're using a reasonably modern perl then you can have arrays of
references to arrays which can be used as multidimensional arrays e.g.

  $array[1][5] = 27;

the perllol (list of lists) and perldsc (data structures cookbook) manual
pages should help.

Hope this helps,

Mike



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


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

Date: 9 Sep 1997 09:47:15 GMT
From: jarausch@numa1.igpm.rwth-aachen.de (Helmut Jarausch)
Subject: Can you escape from the debugger ?
Message-Id: <5v35v3$lug$1@news.rwth-aachen.de>

Hi,

for a quick test I very much like to use the debugger,
but this time it caught me and wouldn't let me go, again.
In both variants below I had to 'kill' it!

perl -de 0   #Variant I)

format STDERR =
@#@#
1,2
 .
q
(and ^C ^<bsp> ^A ^Z nearly anything you like -> no chance)

perl -de 0   Variant II)

format STDERR =
@#@# \
1,2   \
 .
q
(again no chance to escape)

Thanks for your solution,
Helmut.


-- 
Helmut Jarausch
Lehrstuhl f. Numerische Mathematik
Institute of Technology, RWTH Aachen
D 52056 Aachen, Germany


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

Date: 9 Sep 1997 05:47:00 GMT
From: "Eric D. Friedman" <friedman@uci.edu>
Subject: Re: complex pattern?!? it shouldn't be, i think :)
Message-Id: <5v2nsk$mkj@news.service.uci.edu>


In article <Pine.GSO.3.96.970905072521.15349M-100000@julie.teleport.com>,
Tom Phoenix  <rootbeer@teleport.com> wrote:
<
<On Fri, 5 Sep 1997, Markus Moll wrote:
<
<The syntax for comments isn't that simple. (Not that every browser
<author understands this stuff! :-)
<
<   <!-- This is a valid HTML comment > -- 
<	-- still a comment ---->
<	STILL part of the comment! --
<   >

Tom C's striphtml script will handle these:


#!/dcs/bin/perl5 -p0777
#
#########################################################
# striphtml ("striff tummel")
# tchrist@perl.com 
# version 1.0: Thu 01 Feb 1996 1:53:31pm MST 
# version 1.1: Sat Feb  3 06:23:50 MST 1996
# 		(fix up comments in annoying places)
#########################################################
#
# how to strip out html comments and tags and transform
# entities in just three -- count 'em three -- substitutions;
# sed and awk eat your heart out.  :-)
#
# as always, translations from this nacri rendition into 
# more characteristically marine, herpetoid, titillative, 
# or indonesian idioms are welcome for the furthering of 
# comparitive cyberlinguistic studies.
#
#########################################################

require 5.002;      # for nifty embedded regexp comments

#########################################################
# first we'll shoot all the <!-- comments -->
#########################################################

s{ <!                   # comments begin with a `<!'
                        # followed by 0 or more comments;

    (.*?)		# this is actually to eat up comments in non 
			# random places

     (                  # not suppose to have any white space here

                        # just a quick start; 
      --                # each comment starts with a `--'
        .*?             # and includes all text up to and including
      --                # the *next* occurrence of `--'
        \s*             # and may have trailing while space
                        #   (albeit not leading white space XXX)
     )+                 # repetire ad libitum  XXX should be * not +
    (.*?)		# trailing non comment text
   >                    # up to a `>'
}{
    if ($1 || $3) {	# this silliness for embedded comments in tags
	"<!$1 $3>";
    } 
}gesx;                 # mutate into nada, nothing, and niente

#########################################################
# next we'll remove all the <tags>
#########################################################

s{ <                    # opening angle bracket

    (?:                 # Non-backreffing grouping paren
         [^>'"] *       # 0 or more things that are neither > nor ' nor "
            |           #    or else
         ".*?"          # a section between double quotes (stingy match)
            |           #    or else
         '.*?'          # a section between single quotes (stingy match)
    ) +                 # repetire ad libitum
                        #  hm.... are null tags <> legal? XXX
   >                    # closing angle bracket
}{}gsx;                 # mutate into nada, nothing, and niente

#########################################################
# finally we'll translate all &valid; HTML 2.0 entities
#########################################################

s{ (
        &              # an entity starts with a semicolon
        ( 
	    \x23\d+    # and is either a pound (#) and numbers
	     |	       #   or else
	    \w+        # has alphanumunders up to a semi
	)         
        ;?             # a semi terminates AS DOES ANYTHING ELSE (XXX)
    )
} {

    $entity{$2}        # if it's a known entity use that
        ||             #   but otherwise
        $1             # leave what we'd found; NO WARNINGS (XXX)

}gex;                  # execute replacement -- that's code not a string

#########################################################
# but wait! load up the %entity mappings enwrapped in 
# a BEGIN that the last might be first, and only execute
# once, since we're in a -p "loop"; awk is kinda nice after all.
#########################################################

BEGIN {

    %entity = (

        lt     => '<',     #a less-than
        gt     => '>',     #a greater-than
        amp    => '&',     #a nampersand
        quot   => '"',     #a (verticle) double-quote

        nbsp   => chr 160, #no-break space
        iexcl  => chr 161, #inverted exclamation mark
        cent   => chr 162, #cent sign
        pound  => chr 163, #pound sterling sign CURRENCY NOT WEIGHT
        curren => chr 164, #general currency sign
        yen    => chr 165, #yen sign
        brvbar => chr 166, #broken (vertical) bar
        sect   => chr 167, #section sign
        uml    => chr 168, #umlaut (dieresis)
        copy   => chr 169, #copyright sign
        ordf   => chr 170, #ordinal indicator, feminine
        laquo  => chr 171, #angle quotation mark, left
        not    => chr 172, #not sign
        shy    => chr 173, #soft hyphen
        reg    => chr 174, #registered sign
        macr   => chr 175, #macron
        deg    => chr 176, #degree sign
        plusmn => chr 177, #plus-or-minus sign
        sup2   => chr 178, #superscript two
        sup3   => chr 179, #superscript three
        acute  => chr 180, #acute accent
        micro  => chr 181, #micro sign
        para   => chr 182, #pilcrow (paragraph sign)
        middot => chr 183, #middle dot
        cedil  => chr 184, #cedilla
        sup1   => chr 185, #superscript one
        ordm   => chr 186, #ordinal indicator, masculine
        raquo  => chr 187, #angle quotation mark, right
        frac14 => chr 188, #fraction one-quarter
        frac12 => chr 189, #fraction one-half
        frac34 => chr 190, #fraction three-quarters
        iquest => chr 191, #inverted question mark
        Agrave => chr 192, #capital A, grave accent
        Aacute => chr 193, #capital A, acute accent
        Acirc  => chr 194, #capital A, circumflex accent
        Atilde => chr 195, #capital A, tilde
        Auml   => chr 196, #capital A, dieresis or umlaut mark
        Aring  => chr 197, #capital A, ring
        AElig  => chr 198, #capital AE diphthong (ligature)
        Ccedil => chr 199, #capital C, cedilla
        Egrave => chr 200, #capital E, grave accent
        Eacute => chr 201, #capital E, acute accent
        Ecirc  => chr 202, #capital E, circumflex accent
        Euml   => chr 203, #capital E, dieresis or umlaut mark
        Igrave => chr 204, #capital I, grave accent
        Iacute => chr 205, #capital I, acute accent
        Icirc  => chr 206, #capital I, circumflex accent
        Iuml   => chr 207, #capital I, dieresis or umlaut mark
        ETH    => chr 208, #capital Eth, Icelandic
        Ntilde => chr 209, #capital N, tilde
        Ograve => chr 210, #capital O, grave accent
        Oacute => chr 211, #capital O, acute accent
        Ocirc  => chr 212, #capital O, circumflex accent
        Otilde => chr 213, #capital O, tilde
        Ouml   => chr 214, #capital O, dieresis or umlaut mark
        times  => chr 215, #multiply sign
        Oslash => chr 216, #capital O, slash
        Ugrave => chr 217, #capital U, grave accent
        Uacute => chr 218, #capital U, acute accent
        Ucirc  => chr 219, #capital U, circumflex accent
        Uuml   => chr 220, #capital U, dieresis or umlaut mark
        Yacute => chr 221, #capital Y, acute accent
        THORN  => chr 222, #capital THORN, Icelandic
        szlig  => chr 223, #small sharp s, German (sz ligature)
        agrave => chr 224, #small a, grave accent
        aacute => chr 225, #small a, acute accent
        acirc  => chr 226, #small a, circumflex accent
        atilde => chr 227, #small a, tilde
        auml   => chr 228, #small a, dieresis or umlaut mark
        aring  => chr 229, #small a, ring
        aelig  => chr 230, #small ae diphthong (ligature)
        ccedil => chr 231, #small c, cedilla
        egrave => chr 232, #small e, grave accent
        eacute => chr 233, #small e, acute accent
        ecirc  => chr 234, #small e, circumflex accent
        euml   => chr 235, #small e, dieresis or umlaut mark
        igrave => chr 236, #small i, grave accent
        iacute => chr 237, #small i, acute accent
        icirc  => chr 238, #small i, circumflex accent
        iuml   => chr 239, #small i, dieresis or umlaut mark
        eth    => chr 240, #small eth, Icelandic
        ntilde => chr 241, #small n, tilde
        ograve => chr 242, #small o, grave accent
        oacute => chr 243, #small o, acute accent
        ocirc  => chr 244, #small o, circumflex accent
        otilde => chr 245, #small o, tilde
        ouml   => chr 246, #small o, dieresis or umlaut mark
        divide => chr 247, #divide sign
        oslash => chr 248, #small o, slash
        ugrave => chr 249, #small u, grave accent
        uacute => chr 250, #small u, acute accent
        ucirc  => chr 251, #small u, circumflex accent
        uuml   => chr 252, #small u, dieresis or umlaut mark
        yacute => chr 253, #small y, acute accent
        thorn  => chr 254, #small thorn, Icelandic
        yuml   => chr 255, #small y, dieresis or umlaut mark
    );

    ####################################################
    # now fill in all the numbers to match themselves
    ####################################################
    for $chr ( 0 .. 255 ) { 
        $entity{ '#' . $chr } = chr $chr;
    }
}

#########################################################
# premature finish lest someone clip my signature
#########################################################

__END__

<title>Tom Christiansen's Mox.Perl.COM Home Page</title>
<BODY BGCOLOR=#ffffff TEXT=#000000>
<!--

<BODY BGCOLOR="#000000" TEXT="#FFFFFF"
      LINK="#FFFF00" VLINK="#22AA22" ALINK="#0077FF">

!-->



<A NAME=TOP>

<CENTER>
<h3>
<A HREF="#PERL">perl</a> /
<A HREF="#MAGIC">magic</a> /
<A HREF="#USENIX">usenix</a> /
<A HREF="#BOULDER">boulder</a>
</h3>
<BR>
The word of the day is <i>nidificate</i>.
</CENTER>

Testing: &#69; &#202; &Auml;
</a>

<HR NOSHADE SIZE=3>

<A NAME=PERL>
<CENTER>
<h1>
<IMG SRC="/deckmaster/gifs/camel.gif" ALT="">
<font size=7>
Perl
</font>
<IMG SRC="/deckmaster/gifs/camel.gif" ALT="">
</h1>
</a>

DOCTYPE START1
<!DOCTYPE  HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"
  -- This is an annoying comment > --
>
END1

DOCTYPE START2
<!DOCTYPE  HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"
  -- This is an annoying comment  --
>
END2



<I>
<BLOCKQUOTE>
<DL><DT>A ship then new they built for him
<DD>of mithril and of elven glass...
</DL>
</I>
</BLOCKQUOTE>
</CENTER>

<HR size=3 noshade>

<UL>
<LI>
<A HREF="/perl/CPAN/README.html">CPAN
(Comprehensive Perl Archive Network)</a> sites are replicated around the world; please choose
from <A HREF="/perl/CPAN/CPAN.html">one near you</a>.
The <A HREF="ftp://mox.perl.com/pub/perl/CPAN/modules/01modules.index.html">CPAN index</a>
to the <A HREF="ftp://mox.perl.com/pub/perl/CPAN/modules/00modlist.long.html">full modules file</a>
are also good places to look.

<LI><IMG SRC="/deckmaster/gifs/new.gif" WIDTH=26 HEIGHT=13 ALT="NEW">
Here's a table of perl and CGI-related books and publications, in either 
<A HREF="/perl/info/books.html"><SMALL>HTML</SMALL> 3.0 table format</a>
or else in 
<A HREF="/perl/info/books.txt">pre-formatted</a> for old browsers.

-- 
Eric D. Friedman
friedman@uci.edu


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

Date: Mon, 08 Sep 1997 22:06:19 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: DNS lookup with gethostbyaddr?
Message-Id: <mbudash-0809972206190001@d203.pm6.sonic.net>

In article <5v2gm8$24g$1@ha1.rdc1.sdca.home.com>, "Peter Tiemann"
<peter@preview.org> wrote:

>> I found the solution myself (in someone's script)
>> 
>> $ip = "207.36.32.122";
>> @numbers = split(/\./, $ip);
>> $address = pack("C4", @numbers);
>> ($nam) = (gethostbyaddr($address, 2))[0];
>> this works - although I still do not understand why the stuff below is
>> wrong.
>> 
>> 
>> >At first, I tried a piece of code like this:
>> >
>> >----------
>> >print "Content-type: text/html\n\n";
>> >print "<html>\n <head>\n  <title>GET</title>\n </head>\n";
>> >print "<BODY>Start:<BR>\n";
>> >
>> >$paddr = "207.36.32.122";
>> >($a, $b, $c, $d) = split(/\./, $paddr);
>> >$address = pack('C4', $a, $b, $c, $d);
>> >($nam, $alias, $addrtype, $leng, @add) = gethostbyaddr($address, AF_INET);
>> >print "$nam,$alias,$addrtype,$leng\n";
>> >
>> >print "<BR>End</BODY>";
>> >----------

I just went thru the same exercise a few weeks ago - see where you used
AF_INET in your original example? Mine looked like that and didn't work
either until I changed that AF_INET to 2. Now it works fine...

                   _____________________________

                       Michael Budash, Owner
                     Michael Budash Consulting
                           707-255-5371
                   http://www.sonic.net/~mbudash
                         mbudash@sonic.net
                   _____________________________


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

Date: Mon, 08 Sep 1997 15:57:02 -0400
From: Matthew Rice <matthew.rice@ftlsol.com>
To: salvatore.sferrazza@ubs.com
Subject: Re: Doubling up a character in a string
Message-Id: <3414588E.C8DA86AD@ftlsol.com>

Salvatore Sferrazza wrote:
> sub double_up {
 <whew!!!>
>     return $new_str;
> }
> >
> >provided that I pass it a ' as an argument.  I was looking into using
> >substitution with s//, but I heard that will only give me back:

It work's for me (you shouldn't listen to hearsay).

#!/usr/bin/perl -w

$_ = "Bob's wife is married to Mike's cousin.\n";
print;
s/'/''/g;
print;

-- 
Matthew Rice                             e-mail: matthew.rice@ftlsol.com


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

Date: 9 Sep 1997 11:25:51 GMT
From: jarausch@numa1.igpm.rwth-aachen.de (Helmut Jarausch)
Subject: Escaping Newline in a HERE-document - HowTo ?
Message-Id: <5v3bnv$o29$1@news.rwth-aachen.de>

Hi,

using a HERE-document and within it the famous construct
@{[....]} it's sometimes desirable to escape the newline like in

print STDERR  <<EOS;
at @{[printf("%2.2i/%2.2i/%2.2i %2.2i:%2.2i:%2.2i",
   @{[gmtime(time)]}[5,4,3,2,1,0])]} I couldn't get rid of the newline
   characters above.
EOS

Unfortunately the construct   \
doesn't work. Is this a bug, omission or a feature?

Thanks for your hints,
Helmut.

(This is perl 5.00403)

-- 
Helmut Jarausch
Lehrstuhl f. Numerische Mathematik
Institute of Technology, RWTH Aachen
D 52056 Aachen, Germany


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

Date: Tue, 9 Sep 1997 08:55:21 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Lutz Albers <lutz@muc.de>
Subject: Re: flock() problem
Message-Id: <Pine.GSO.3.96.970909085432.27604M-100000@julie.teleport.com>

On Mon, 8 Sep 1997, Lutz Albers wrote:

> >open(FILE,"< /tmp/junk");
>            ^^^^^
> This looks bogus. 

It's not bogus. 

> And check the return code of open.

Good advice!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 9 Sep 1997 12:40:45 GMT
From: fty@hickory.engr.utk.edu (Jay Flaherty)
Subject: Re: Getting rid of \n in textarea input
Message-Id: <5v3g4d$6m9$1@gaia.ns.utk.edu>

Sendu (ahr@hotmail.com) wrote:
: Javier Figueroa wrote:
: > 
: > I need to know how to get rid of carriage returns put in by users in
: > textarea so I can put it in one continuous line in my database file.
: > 
: In a ||r case I used chop($str) to get rid the \n at the end of the
: input string 

look at the chomp() function. It explicitly removes newline codes. chop() 
removes the last character of a string (wether it's a newline or not).

Jay

-- 
**********************************************************************
Jay Flaherty                                               fty@utk.edu
I want to peacefully die in my sleep, like my grandfather did, 
not screaming like the passengers in his car did!
**********************************************************************

Version: 2.6.2

iQCVAwUBM2jQn1OdOzizdT/5AQHaWwP/bECLFr26GWHmszDuKUXCABW9cBuhqD9z
+JrJY+jRxF8yiV8ofkbma2vXi833RFDOz4vWZRetmjSV46MiDv5xzUatjyJnr57m
DadIYs9h0geGS6WOhJyy9dRI+YqQreQRa0QUW6NhYjdJJSrN/naYhPOfgS1mGhHX
P0RIJXP5JKI=
=edAe
-----END PGP SIGNATURE-----


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

Date: Tue, 09 Sep 1997 01:35:57 GMT
From: over@the.net (dave)
Subject: Re: Getting rid of \n in textarea input
Message-Id: <3414a60f.1318584@news.one.net>

Sendu <ahr@hotmail.com> wrote:

>Javier Figueroa wrote:
>> 
>> Please if anybody can help me I would really appreciate it.
>> 
>> I need to know how to get rid of carriage returns put in by users in
>> textarea so I can put it in one continuous line in my database file.
>> 
>> I tried
>> 
>> $FORM{'information'} =~ s/\n/ /g;
>> 
>> but it does not work, the carriage return is still being displayed in my
>> database file.
>> 
>> Please if you can post an answer or write me email I would greatly
>> appreciate it.
>> 
>> Thank you very much,
>> 
>> Javier Figueroa
>> figue@tld.net
>
>In a ||r case I used chop($str) to get rid the \n at the end of the
>input string 
>
>Hope this works for you too
>Sendu

I think you have to tell perl to allow a string to contain multiple
lines (treat as one string), as in:

	s{/n}{ }gs

I tried it and it worked.

Dave
|
| Please visit me at http://w3.one.net/~dlripber
|
| For reply by email, use:
| dlripber@one.net
|________


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

Date: Tue, 09 Sep 1997 12:21:10 +0200
From: Doug Seay <seay@absyss.fr>
To: jenifer west <jwest@pixelny.com>
Subject: Re: HELP!  Subroutine is making me cry!
Message-Id: <34152316.6428544D@absyss.fr>

[posted and mailed]

jenifer west wrote:
> 
> I am writing a script which sends images via sendmail to lucky
> recipients based on user (form) inputs.

This isn't some evil "spam your enemies" page, is it?  Put in limits to
avoid how many times people get sent things to limit the potential for
abuse.


> Everything works perfectly with
> the mailing and boundries, the mime attachemnts - my error checking, etc
> - all fine.
> Only I need to do some remedial logging of how many of each images are
> sent. The simple routine i'm using to open and write to my count.file
> works fine if it is called alone. But when it's after the sendamil sub
> it is ignored. I've tried everything I can think of - Is there something
> I should be flushing after closing my mail program?

Do you open the file handle before launching the sendmail?  You could
have problems with multiple processes having copies of the same file,
but that doesn't sound right.  That usually causes duplication.


> It's strange, I have my successful redirect in the sendmail sub and it's
> seemless - but appending my <&count_these;> is ignored - or won't
> increment.
> 
> As I said the counting sub works fine if called alone.

Post the code.  Your description isn't enough to debug it.  A 10-20 line
snip of the critical area would be great.


> So - I'm going going to be out of a job if I don't get this right and
> right quick! no suggestion to silly! (almost)

Quit.  If you have stupid management that doesn't handle little errors,
then bail out.  Nobody should work in a software sweatshop.

- doug


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

Date: 9 Sep 1997 06:01:03 GMT
From: mrcpu@schizo.cdsnet.net (Jaye Mathisen)
Subject: How do you set flow control via perl?  (Controlling a device from perl)
Message-Id: <5v2omv$49$1@news-1.meganews.com>


FreeBSD 3.0, perl 5.00401.

I have a script using the POSIX routines, and I want to do some simple 
manipulation of a modem port.

Looking through some C-code to set flow control, they
use things like CCTS_OFLOW | CRTS_IFLOW, and others.

however, these constants don't exist apparently in this POSIX module, and 
from a perldoc of the POSIX manual, there are no real equivalents
that I can see for the c_cflag values.

So how do I set these up?  Or barring the use of the POSIX module, 
what am I supposed to use in it's place?


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

Date: Tue, 09 Sep 97 08:32:26 PDT
From: yaron@netvision.net.il
Subject: Looking for Report Generator
Message-Id: <NEWTNews.873819233.25106.yaron@dialup.netvision.net.il>


Hi

I'm looking for a Report Generator for relational databases, that 
have some of the capabilities of the commercial products, such as R&R.

It should do something like this:
A table of data is given (constant number of fields and unlimited length),

The Report Generator with  some pre-defined data performs:
 * use the fields to sort the table.
 * recognize the beginning and end of  "groups" of data according 
	to a change in field (or fields combination) value 
	(from one line to the other).
 * print headers and footers at the beginning and end of  "groups".
 
Some very useful features could be:
 * ability to define private fields, and have them change their values 
	according to the table data.
 * ability to control the printing of lines and fields according to values 
	of other fields.

Of course there are a lot of things that can be done, I will be happy 
with the basic things.

Thanks you all . Yaron.




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

Date: Tue, 09 Sep 1997 16:55:11 +1200
From: Cameron Hart <cam@plain.co.nz>
Subject: Q: bitwise operators and perl
Message-Id: <3414D6AF.57B47944@plain.co.nz>

Hi, I am wondering if anyone can help me with perl bitwies operations

My senario is I have an array of an array of two 32 bit unsigned
integers that I get from a database. An individual record looks
something like this

$ARRAY[0] = [
          '3391401472',
          '4294967040'
        ];

I am trying to make a match with a given 32 bit unsigned integer going
through the entire array trying this (where $number = 3391401473):

if (($ARRAY[$i][1] & $addr) == $ARRAY[$i][0]) { do something interesting
};

If you perform an & on these numbers, like I tried in the perl debugger
you should get 

(4294967040 & 3391401473) = 3391401472

which would be a match. But for some reason 

($ARRAY[$i][1] & $addr) = 1243917825

What I want to know is why, and how can I get the value I am really
after?

Thanks in advance,

Cam

-- 
Cameron Hart                                     cam@plain.co.nz
Systems Programmer                      
Plain Communications Ltd                  Phone: +64-3- 364-5888
PO Box 7578                                  
CHRISTCHURCH                              http://www.plain.co.nz


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

Date: Tue, 09 Sep 1997 12:13:04 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Q: HOWTO - Manifest Constants
Message-Id: <34152130.5B5B586@absyss.fr>

Geoffrey Leach wrote:
> 
> Call me a throwback, but "$TRUE" bothers me.  It used to be that the
> following was the reccomended way of having a manifest constant,
> but this seems not to work anymore.  Any suggestions, short of
> creating an extension?  Version is 5.004

<snip>

	use     constant        TEST_BARE => 1;

	printf("TEST_BARE says: %d\n", TEST_BARE);
	printf("TEST_BARE() says: %d\n", TEST_BARE());

I get "1" for both of the printf()s.  Is this what you want?  Tom
Phoenix's "constant" module comes standard with 5.004 (IIRC).  "perldoc
constant" to get info.

- doug


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

Date: Tue, 9 Sep 1997 08:34:29 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Eric Hilding <eric@garlic.com>
Subject: Re: Testing attempts fail..
Message-Id: <Pine.GSO.3.96.970909082735.27604K-100000@julie.teleport.com>

On Mon, 8 Sep 1997, Eric Hilding wrote:

> I'm trying to modify a perl script which processes info from a web 
> form, but first testing the proposed mods first on my PC.  I've tried 
> various syntax combinations one at a time and would like to know where 
> I'm screwing up.  Thanks for any help.

> #$FORM{'e2'} eq "Test Name";
> #$FORM{'e2'} eq 'Test Name';

Those two expressions (commented out) are equivalent. (And they're
useless, unless you use the expression in some larger statement, of
course.) 

> #$FORM{'e2'} eq {'Test Name'};

This is making a reference to a defective anonymous hash and testing that
for string equality. Shouldn't work.

> #$FORM{'e2'} eq  /'Test Name'/;

This is doing a pattern match (against $_ by default) and seeing whether
the result of that matches the %FORM variable as a string. Maybe you
wanted =~ instead. Hope this helps! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 9 Sep 1997 15:31:07 GMT
From: jgloudon@bbn.com (Jason Gloudon)
Subject: Re: Um... a bug?
Message-Id: <5v3q3r$npj$1@daily.bbnplanet.com>

In article <j3eg1re65ap.fsf@alpha.hut.fi>,
Antti Rauramo  <arauramo@alpha.hut.fi> wrote:
>
>	Hello.
>
>	As far as I can see, the following program displays a very
>obvious bug in Perl. Tell me if I'm wrong. 
>	Works (doesn't work, that is to say) at least with Perl
>versions 5.004_01 and 5.003 in SunOS 5.5 and OSF1 v4.0.
>
>--- 8< --- clipety clap --- 8< ---
>#!/usr/local/bin/perl
>
>for($i=1;$i<7;$i+=0.1){
>    print "$i\t".int($i)."\n";
>}
>--- 8< --- clipety clap --- 8< ---

The problem is not Perl it's your computer! Seriously, this apparent
bug is just a nuisance of the way in which real numbers are represented 
in binary. man perlfaq4 for details. Try rewriting this loop in C using 
floats to store i, you should get similar output.

Jason Gloudon


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

Date: Tue, 9 Sep 1997 08:53:45 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Antti Rauramo <arauramo@alpha.hut.fi>
Subject: Re: Um... a bug?
Message-Id: <Pine.GSO.3.96.970909083944.27604L-100000@julie.teleport.com>

On 9 Sep 1997, Antti Rauramo wrote:

> Subject: Um... a bug?

No, roundoff error. 0.1 cannot be represented in a finite binary
bitstring. If this doesn't happen in some other language, it's because
that language is somehow hiding the ugly truth from you! :-) 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Tue, 09 Sep 1997 12:26:23 +0200
From: Doug Seay <seay@absyss.fr>
To: daveck@top.monad.net
Subject: Re: Undefined subroutine &main::CgiDie called at util.pl line 75.
Message-Id: <3415244F.77184ECF@absyss.fr>

[posted and mailed]

David Eck wrote:
> 
> Hi,
> I am using cgi-lib.pl.  I am getting this message wherever I try to call
> &CgiDie.
> > Undefined subroutine &main::CgiDie called at util.pl line 75.

Your code is in package "main" unless you specifically change it
(perldoc -f package).  All unqualified functions must be in the current
package.  Look at cgi-lib.pl and see if changes the package.  You may
need to call something like &CgiLib::CgiDie;  Note that this
specifically says that CgiDie() is in the CgiLib:: package.

Are you doing new development using cgi-lib?  Most (all?) of the heavy
hitters in this group recommend the Perl5 based CGI.pm to the ancient,
perl4 based cgi-lib.pl.  They say that it is much better (dunno, I don't
WWW programming).  Of course, you are free to do as you wish.

- doug


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

Date: Tue, 9 Sep 1997 15:33:14 +0400
From: "Valery Vybornov" <vvv@west-call.com>
Subject: undump program for Linux/ELF
Message-Id: <5v3bti$ot@graybox.west-call.com>

 Hello,

I wonder is there 'undump' program available for Linux?

(undump is supposed to make an executable from core dumped by 'dump label' perl command,
i.e. dump(2) system call).

Thanks,
Valery Vybornov
vvv@west-call.com






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

Date: Tue, 09 Sep 1997 11:50:24 +0300
From: Bekman Stanislav <sbekman@iil.intel.com>
Subject: Weird things with perl conversions?
Message-Id: <34150DD0.167E@iil.intel.com>

Hi,

I'm using perl cgi to collect clients name, adress and etc.
One of the entries is a Credit Card number (I'm validate that number
thru
cgi first)
Now I didn't want to store the plain Credit Card numbers on the disk
So I wrote a simple encrypt and decrypt function that remap each digit
from 0-9 to 0-127 char (7 bit). What has happened is when I decrypt
the numbers about half of them were screwed up and I have 2-3 digits 
more than in original number. I've checked with enourmous number of
valid Credit Card numbers (e.g. visa) that
decrypt(encrypt($number))==$number 
but when things were running thru CGI they have got screwed up somehow

The functions are:

sub EncryptCC(){
  local ($num) = @_;
  local ($tmp);

        # Encryption Algorithm
        # Split Digits
        # Foreach Digit
        # Digit :=itoa( ( ( Digit + 2 ) * ( Digit + 2 ) + 2 ) XOR 54)
  @digits=split("",$num);
  foreach $digit (@digits) {
    $digit=(($digit+2)**2+2)^54;
    $digit=sprintf("%c",$digit);
    $tmp.=$digit;
  }
}

sub DecryptCC(){
  local($num)=@_;
  local($tmp);

        # Decryption Algorithm
        # Split Digits
        # Foreach Digit
        # Digit := SQRT( ( atoi(Digit) XOR 54) - 2 ) - 2
  @digits=split("",$num);
  foreach $digit (@digits) {
    $digit=sqrt((ord($digit)^54)-2)-2;
    $tmp.=$digit;
  }
  
  return $tmp;
}


To show you what each digit is getting converted to:
1  2  3  4  5  6  7  8  9  0
=  $  - ^P ^E  t  e  P  M  0 # these a char representations

I thought that the problem was in control characters from 4 and 5
So I have simplified the encryption to

Digit :=itoa(Digit+59)

But once again some numbers has been screwed
It is checked that the original numbers were correct

I think that the problem has come from the web, May be some characters
has been inserted at the end?

Any ideas what went wrong and whether it's possible to restore the right
numbers?

Thank you for advise!




----------------------------------------------------------------------
Stas Bekman


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

Date: 09 Sep 1997 09:48:37 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: what has it got in its ssocketses?
Message-Id: <is202z7wru.fsf@godzilla.kiere.ericsson.se>

"Lloyd " <_lloyd_@vwv.com> writes:

> I am trying to initialise a Socket which in the end will connect to a
> listening POP3 port.

Is it just an exercise in socket programming, or something you're
going to use? If the latter, consider getting the Net::POP3 module and
saving yourself lots of work.

> (Haven't even got to the binding of the socket or the connecting
> etc...). Pretty simple stuff I thought!

Sockets are rather tricky. Using them becomes much easier if you let
others do the work for you :-) 

RTFM IO::Socket.

>   ($dummy1, $dummy2, $prototype) = getprotobyname("TCP");

Works, but it's ugly. $prototype = getprotobyname("tcp"); is enough
(see documentation for getproto* in the perlfunc manpage).

>   socket(SOCKET, 2, 1, $prototype) || do {&error("Socket not Initialised\n$!");};

What are those numbers doing there? You didn't read about socket() in
the perlfunc manpage, about socket programming in the perlipc manpage
or the documentation for the Socket module, did you?

Hint: those constants are OS-dependent.

-- 
		    Calle Dybedahl, UNIX Sysadmin
      qdtcall@esb.ericsson.se  http://www.lysator.liu.se/~calle/


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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 1000
**************************************

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