[6991] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 616 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 16 17:17:14 1997

Date: Mon, 16 Jun 97 14:00:25 -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           Mon, 16 Jun 1997     Volume: 8 Number: 616

Today's topics:
     ADVAPI32 <roger@mantamedia.com>
     AWK to PERL converter? <GScharnagl@software-automation.com>
     Re: Big-Endian <--> little Endian conversion? <jward@csac.com>
     Re: Case Conversion (M.J.T. Guy)
     Checking existence of file in other people's directorie <keys@babylon5fan.com>
     faster regexps <usenet-tag@qz.little-neck.ny.us>
     How do you direct STDERR into a pipe? <joconnor@fwhre13.fwrdc.rtsg.mot.com>
     Re: libwww for Win32 <rheald@futuresource.com>
     merge_ext error on perl5.004 w/ IRIX 6.3 <jbharvey@gte.net>
     Re: Modify my perl script? <bryan@eai.com>
     Re: Module installation and usage without root access - (Steffen Beyer)
     Need help to create a Mail server <student.glcoop@ec.gc.ca>
     Perl and tar not cooperating in a shell script <bmurdock@wat.hookup.net>
     Re: Perl language question - a regular expressions. <sfairey@metrica.co.uk>
     Re: Perl to awk translator (Linux_User)
     Re: Printing Prime Numbers (Jay Flaherty)
     Repeating characters <naxos@rocketmail.com>
     Re: rounding off numbers <jbokma@caiw.nl>
     Sending e-mail using Perl for NT - don't wanna... gotta x@apocalypse.org
     Re: Sending e-mail using Perl for NT - don't wanna... g (Jim Esten)
     Re: Sending E-Mail with attachment from CGI? (Matthew Burnham)
     Sort equivalent in Perl (Thee Boon Hoo)
     Re: Sort equivalent in Perl <sfairey@metrica.co.uk>
     Re: Trouble building 5.,004 on Linux (Hans-Georg Rist)
     Re: Troubles with perl scripts <keys@babylon5fan.com>
     UserAgent w/ security enabled?!?! wynnytv@abc.com
     Re: What does "UNIX" stand for.. (Chad Glynn)
     Xsub: changing an already added library <jheck@merck.com>
     Your Secret Password ftbv4s47y@inet.it
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 16 Jun 1997 15:21:24 -0400
From: Roger Vernon <roger@mantamedia.com>
Subject: ADVAPI32
Message-Id: <33A59234.6510@mantamedia.com>

I wrote a very simple test Perl/CGI script.  I am running Perl/Win32. 
The script runs fine when I run it from the command line, but when I try
to call it from a browser I get this error:


The specified CGI application misbehaved by not returning a complete set
of HTTP headers. The headers it did return are:

Could not load ADVAPI32.dll


If anyone could explain even a part of this message to me, I'd really
appareciate it.  I'm not sure where else to turn for answers.

Thanks

Please Mail any suggestions to Roger@mantamedia.com


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

Date: 16 Jun 1997 17:29:32 GMT
From: "Gregg Scharnagl" <GScharnagl@software-automation.com>
Subject: AWK to PERL converter?
Message-Id: <01bc7a7a$adbb66f0$28101a26@scharnagl>

I hear a lot about an AWK to PERL conversion utility, but I can't seem to
locate it.  Can anybody help me?

Gregg Scharnagl
GScharnagl@Software-Automation.com


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

Date: Mon, 16 Jun 1997 04:00:55 -0500
From: Jerry Ward <jward@csac.com>
To: hartje@etech.hs-bremen.de
Subject: Re: Big-Endian <--> little Endian conversion?
Message-Id: <33A500C7.3FA6@csac.com>

Lets see, I believe that most procs are big-end and Intel and Vax are
little-end.  There are some pack templates "v and V" that are little 
endian for vax.  That should cover you on the 2 ints, the double is
a different problem.

You may try doing...

$fred = unpack( "b16b16", vec( $buf, 0, 16 ), vec( $buf, 16, 16 ) );
$result = pack( "d", $fred );

I haven't tried this before and I'm guessing that the mac has 16 bit 
integers (never worked on PCs).  Of course writing binary is a whole
other problem that I gave up on and went back to C!

--Jerry.


Dr. Michael Hartje wrote:
> 
> If I read a binary data file with sysread and use unpack to get the
> contents to varibles like:
> 
> sysread(INFILE, 16, $buf);
> ($a, $i, $j) = unpack ("d i i", $buf);
> 
> You get different results doing it on Macintosh an on PC because of
> "endianess". The lowest bytes are on lower adresses on one machine and
> on the highest position on the other machines.
> 
> Is there any switch / function / statement sequence solving this problem
> for unpack?
> 
> Thanks for thinking about my problem.
> 
> Preferred answer to : mailto:hartje@etech.hs-bremen.de
> 
> Michael Hartje
> --
> Hochschule Bremen                 Labor fuer Hochspannungstechnik
> Prof. Dr. Michael Hartje        Neustadtswall 30;    28199 Bremen
> Telefon: +49 421 5905-444                   FAX: +49 421 5905-476
> mailto:hartje@etech.hs-bremen.de          http://www.hs-bremen.de

-- 
=======================================================================
Jerry Ward                                TextEmail: 
ward@seas.smu.edu           
-----------------------------------------------------------------------
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: PGP for Personal Privacy 5.0

mQCNAzMMgUUAAAEEALoFWBmR+zOZLcFr/ebheUhDNVmTsmDZFYzzPFpQ8VkPnDcZ
PlxzcOYy5E5voxc2axhfl/1wBw7comQ0Pgs7sIFMiCfFuizUlG7P4+nNH9zP/ATM
F9aEXy4fO1xsKgdYZ0/LVPAhxeNq1j22117/bA4jQiVW8faqcr29CRzqw/D9AAUR
tBtKZXJyeSBXYXJkIDxqd2FyZEBjc2FjLmNvbT6JAJUDBRAznQpgvb0JHOrD8P0B
ATjGA/9euiwR8YEWGGIJyv/nrpBHiwZz5AEyDeQQwOBTxwfRsw2QZVlEHHaLqtCn
3nN+W2xAvAaoX0iaLp0DzPtdSQZc0cHWPHwWnDVOAET0eKMZUgWPPChcuPzi4uiR
B6hNMyl5uW6SvFpGrz/w9isd/h8zmTK+Ub58q3eFEhYph1x4nLQhSmVycnkgV2Fy
ZCA8andhcmRAcGF5bWVudGVjaC5jb20+tB9HZXJhbGQgV2FyZCA8d2FyZEBzZWFz
LnNtdS5lZHU+iQCVAwUQM50KRb29CRzqw/D9AQF/KAP8CbtpwXSUEIsw70Qw8+UU
VgAQCBwuL/cH7lV1HP1sSFnDqr0hGm5lRRoeCpE7FFMsheRkfoWkRkLp/qVjIWQE
XLnEe/MKG2+P2nVsHKfYFoja2ReKEFpjPBNmQQpYqHPWqt97YAqffDHHcvKUTLyE
u60w3ZyHaXG/I0Pm9bwXZLo=
=Nils
-----END PGP PUBLIC KEY BLOCK-----
=======================================================================


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

Date: 16 Jun 1997 18:44:41 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Case Conversion
Message-Id: <5o41ip$gtn@lyra.csx.cam.ac.uk>

Tom Phoenix  <rootbeer@teleport.com> wrote:
>On 15 Jun 1997, Dean Inada wrote:
>
>> In article <Pine.GSO.3.96.970614083429.4940V-100000@kelly.teleport.com>,
>> Tom Phoenix  <rootbeer@teleport.com> wrote:
>> >> 
>> >> 	$_ ^= lc($_) ^ uc($_);
>
>I'm claiming that the lc^uc method, while very clever, relies upon an
>idiosyncracy of the way that English letters are represented in ASCII. If
>you've got non-English letters or a non-ASCII coding, that algorithm can
>easily fail.

Not true.    As I pointed out in another posting, the exact assumption
being made is that for all characters x, either  x eq lc(x)  or
x eq uc(x).    I would consider a locale not satisfying this condition
to be seriously bent.

To spell out in detail

i)   x is a non-letter    x eq lc(x) eq uc(x)

ii)  x is upper case      x eq uc(x)

iii) x is lower case      x eq lc(x)

iv)  anything else is a letter, but neither upper case nor lower case.
     This is the possibility I consider to be broken.    It may even be
     ruled out by the locale standards  -  I haven't bothered to check.


Mike Guy


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

Date: Sun, 15 Jun 1997 18:05:47 -0600
From: Keys <keys@babylon5fan.com>
Subject: Checking existence of file in other people's directories...
Message-Id: <33A4835B.10770B27@babylon5fan.com>

I've written a simple Perl script that prints a list of a system's users
and links to their homepages, iff (if and only if) they exist.  The
problem is, when I run it from the webserver as a CGI, it works fine,
since the webserver has access to all web dirs, but when I execute it
under my uid (from my login shell or as a crontab), I don;t have the
permissions to go sniffing for index.html in others' webdirs...  Here is
the main part of the script, from the getpwent func at the beginning to
the actual section that looks for the indices:

while(($login,$passwd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell)=getpwent)
{
                next if $uid <=100;
                ($name,$office,$phone)=split(/,/,$gcos);
                $username{$login}=$name;
}
for (sort keys %username) {
        print <<"EOF";
</tr>
<tr><td><A HREF="/bwarden/fingerm?$_">$username{$_} ($_)</A></td>
<td><a
href="mailto:$_\@snafu.ch.uofport.edu">$_\@snafu.ch.uofport.edu</a></td>
EOF
                if (-r "/home/httpd/html/$_/index.html") {
                        print "<td><A
HREF=\"/$_/\">http://snafu.ch.uofport.edu/$_/\</A></td>";
                        }
}


To get around the permissions problem, my sysadmin suggested using lynx
-source servername/username/ to check each dir, but I shudder at the
thought of the server running lynx (and opening a socket on the
webserver simultaneously) once for each of about 250 user accounts... 
The webdirs are actually in the form /home/httpd/html/username/ but they
are also aliased as ~username/public_html/.  Does anyone have any other
ideas how I might check for the indices?  The directories exist for all
users (but not index.html), so I can't look for that (besides, I don't
have read permission in /home/httpd/html/ so I can't get a list anyway),
and most of the webdirs have permission 700 or 600...  The actual script
is available at http://snafu.ch.uofport.edu/bwarden/users.pl 
You can view the CGI output (running as uid nobody courtesy of
webserver) at http://snafu.ch.uofport.edu/bwarden/users
 ...and you can view a static page updated daily at
http://snafu.ch.uofport.edu/bwarden/users.html

I really appreciate anyone having read through this and any comments
anyone sends.  Thanks much!


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

Date: 16 Jun 1997 17:28:33 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: faster regexps
Message-Id: <5o3t41$5jg$1@news.netusa.net>

The FAQ says that there is an experimental module that can help
speed regexps. I'm guessing that what it does is make it easier to
cache compiled regexps when using lots of them. That would speed
one program I have considerably. Rewriting that program to minimize
the impact of RE compile delays would be a lot of work.

Anyway, I went to CPAN and found Devel:RegExp version 0.1. The
timestamp on it was from 1995. I tried making it but there are
loads of errors, mostly undefined varibles. There was no readme
or docs. CPAN offered a clever summary of "for gurus".

I'm guessing right now that the copy at CPAN is not compatible
with perl 5.004. Can anyone tell me if there is a version which
is compatible? Any other advice about module anyone want to share?

Elijah
------
regexp junkie


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

Date: 16 Jun 1997 14:03:05 -0500
From: Jim O'connor <joconnor@fwhre13.fwrdc.rtsg.mot.com>
Subject: How do you direct STDERR into a pipe?
Message-Id: <s81yb8axted.fsf@fwhre13.fwrdc.rtsg.mot.com>

Let's say I have a fragment like this in a PERL script:

 $ducmd   = "du | sort -n -r";
 open( DU, "$ducmd |") || die "Can't run $ducmd";
 while (<DU>) 
  {
  ..do stuff to $_, and maybe print it out
  }

When I run this, du writes error messages ("cannot open ...",
"bad status", etc) to stderr, which clutter up the output. I'd
like to redirect stderr to my PERL code, and handle the errors
in there.

How does one get PERL to redirect (not copy) stderr so it's 
available to the PERL script?

Any help much appreciated.

--
 Jim



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

Date: Mon, 16 Jun 1997 13:54:30 -0500
From: Rien-always-been-Heald <rheald@futuresource.com>
To: Howard Yen <howard.yen@mci2000.com>
Subject: Re: libwww for Win32
Message-Id: <33A58BE6.2822@futuresource.com>

Howard Yen wrote:
> 
> Is there a version (or some has one) of libwww for
> Win32 (Win95)?
> 
> I have perl install on my Win95 (from activeware
> http://www.perl.htp.com)
> 
> I have also download libwww5.07 for unix. i cannot seem to
> make it work under Win95 someone help me her?
> 
> hy

The most immediate way to get this would be to look at: 

http://www.sn.no/libwww-perl/

However, for future reference, and assuming perhaps by chance I didn't
give you the above, you might try using a search engine and looking for
Perl and Win32 and libwww and you'd come up w/ the same results (and
more!!!).
http://www.sn.no/libwww-perl/


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

Date: 16 Jun 1997 18:32:12 GMT
From: Justin B. Harvey <jbharvey@gte.net>
Subject: merge_ext error on perl5.004 w/ IRIX 6.3
Message-Id: <5o40rc$raq$1@news2.gte.net>

I have an SGI O2 running IRIX 6.3 and gcc 2.7.2.  When compiling perl5.004
here is what I get under Making DB_File (dynamic):

Running Mkbootstrap for DB_File ()
chmod 644 DB_File.bs
LD_RUN_PATH="/usr/local/lib" ld -o ../../lib/auto/DB_File/DB_File.none
DB_File.o    -L/usr/local/lib -ldb 
ld: FATAL 2: Internal: at ../../ld3264/relocate.c merge_ext returns nil
during relocation
make[1]: *** [../../lib/auto/DB_File/DB_File.none] Error 1
make[1]: Leaving directory `/security/jbharvey/perl5.004/ext/DB_File'
make: *** [lib/auto/DB_File/DB_File.none] Error 2

I made sure to not use nm to extract symbols and I even picked do not use
the Dynamic Loader.   I read somewhere that the above error is what you
get if you mix GCC and regular CC objects, but I didn't use CC anywhere.
Was anyone able to get around this?

Thanks,

j

-- 
Justin B. Harvey
jbharvey@gte.net
http://home1.gte.net/jbharvey


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

Date: Fri, 13 Jun 1997 16:54:05 -0500
From: Bryan Hart <bryan@eai.com>
To: Ron Ablang <cs008150@gaia.ecs.csus.edu>
Subject: Re: Modify my perl script?
Message-Id: <33A1C17D.167E@eai.com>

Ron Ablang wrote:
> 
> Could someone please help me modify this perl script file?  What it does
> is it takes an ascii file and sends it as a message to each member in
> another text file.  I need this file to just pause one second after it
> says
> "Message sent to: yada@yada.com" instead of me having to hit enter after
> every email address.  Thanks.
> 
> #!/sequoia/software/perl/bin/perl
> # SHPE distribution
> open(SOURCE,"distribution_list") || die "cannot open distribution_list";
> print "Enter file to distribute:  ";
> $distribution_file = <STDIN>;
> chop($distribution_file);
> print "Enter message subject string:  ";
> $subject = <STDIN>;
> chop($subject);
> while ($field = <SOURCE>) {
>     chop($field);
>     unless (fork) {
>         exec("mailx -s '$subject' $field < $distribution_file");
>     }
>     print "Message sent to: $field, press (Enter) to continue" ;
>     $espera = <STDIN> ;
> }
> close(SOURCE);

replace the 

$espera = <STDIN> ;

in the while loop above with 

sleep 1;

Bryan
-- 
-------------------------------
|  Bryan Hart                 
|  Network Products Engineer  
|  Engineering Animation Inc. 
|  Phone: (515) 296-5979
|  Fax: (515) 296-7025
|  Email: bryan@eai.com              
|  Web: http://www.eai.com/                          
-------------------------------
"A conclusion is simply the place where you got tired of thinking"


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

Date: 16 Jun 1997 13:47:16 GMT
From: sb@en.muc.de (Steffen Beyer)
Subject: Re: Module installation and usage without root access - Summary
Message-Id: <5o3g54$bgv$1@en1.engelschall.com>

"Followup-To:" set to "comp.lang.perl.modules" where this topic belongs.

Also the reason why I quoted the article in full length, so that readers
of "comp.lang.perl.modules" won't need to search for the original post.

Brian Lavender <brian@brie.com> wrote:
> After my inquiries regarding use of modules in local directories
> without root access I though I would summarize my findings. I think
> this would be great to include in the FAQ. Of course may it is and I
> missed it. If you have corrections to this post, please comment. The
> first part of this covers installation and the second part covers
> usage.

> PART I

> To install a module in a local directory use the following 

> >   1.Unpack the source into a temporary area. 

> >   2.   perl Makefile.PL PREFIX=~/perl
>            If your shell expands the ~ it will follow the path from
> your home directory. Someone also suggested to me to use 

>           perl Makefile.PL PREFIX=/your/local/directory

> for this step but it would not work on my system. So, since the first
> way worked I did not further inquire why.

Suppose the absolute path of your home directory is "/usr/home/hugo"
(assuming that your login is "hugo").

Then "PREFIX=~/hugo" and "PREFIX=/usr/home/hugo" are equivalent, provided
that your shell knows how to expand the tilde "~".

> >   3.    make

> >   4.    make test

> >   5.    make install


> PART II
> To use a module installed in a local directory insert the following in
> your code. Insert the following at the beginning of your script.
> Replace the path with the absolute path on your machine where the
> modules are installed.

> use lib "/usr/path/to/module/lib";

> Now the second way to do it, yet considered passe (ya know, there is a
> better way now) is:

The "better way" is using the "use lib" statement as shown above.

> BEGIN {
>   unshift(@INC,'/usr/dom/xbrie/brian/perl/lib/perl5/site_perl');
>  }

> Now don't get confused as I did and use the line

> use CGI "usr/path/to/module/lib";  #<-- don't do this

> because if you have the module in the search path and it will grab it
> from there. I was experimenting with CGI.pm and my virtual server has
> an older version of CGI.pm installed and I used the bad way. It gave
> me different results. 

> In the module CGI.pm, Lincoln Stein made it so you can verify the
> version with the variable (I guess you call it a variable or is it
> part of the package?)

I guess you can call it a package variable. :-)

(Because you have to specify the package's name, "CGI" in your example!)

> $CGI::VERSION

> That will give you the version. I think this should be included in
> every module.

MakeMaker strongly encourages module developers to supply it.

I don't even know what happens if you (as a module developer) don't
supply it. I guess Makemaker will complain loudly! :-)

So you can be pretty confident (but not absolutely certain, I suppose)
that this variable exists.

> Since often as versions advance and the possibility of
> grabbing the wrong version it is a good way to check. 

Note that since version 5.003 of Perl or so, you can also use the following
syntax:

use CGI qw(foo bar) 2.0;

which will check the variable $CGI::VERSION automatically for you and
complain if the version number of the module is smaller than what you
specified ("2.0" in this example).

> Hope this helps and good luck.

Me too. :-)

> "Have you heard of the new improbability drive?"

Tell me more! ;-)

Yours,
-- 
    Steffen Beyer <sb@sdm.de> http://www.engelschall.com/u/sb/
     "There is enough for the need of everyone in this world,
      but not for the greed of everyone." - Mahatma Gandhi
   >> Unsolicited commercial email goes directly to /dev/null <<


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

Date: 16 Jun 1997 18:42:44 GMT
From: "The Kid" <student.glcoop@ec.gc.ca>
Subject: Need help to create a Mail server
Message-Id: <01bc7a84$b5498fa0$eee4878e@Chartrandm.SID.NCR.DOE.CA>

Hi everybody

I wonder if someone know how i can write a mail server with perl
i mean that user can log, receive and send mail.
I was thinking about, may be, create a file with each mail
but ...


-- 
Yves Ferdinand
mailto://yves.ferdinanf@callisto.si.usherb.ca


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

Date: Mon, 16 Jun 1997 16:08:58 -0400
From: Matt Murdock <bmurdock@wat.hookup.net>
Subject: Perl and tar not cooperating in a shell script
Message-Id: <33A59D5A.793D7032@wat.hookup.net>

I've been having problems with my (homemade) backup system. 
Occasionally, tar is asked to back up file with spaces or other odd
characters in their names.  These files are _always_ lost in the
backup.  What I would like to do, is to encapsulate each filename within
quotes.  I.e., tar file1 file2 file number 3
 Would become: tar "file1" "file2" "file number 3" etc..

My backup currently does the following (basically):
	1. use "find" to grab all the files needed to be backed up and dump the
results into a temporary file.
	2. use "tar cf $backup_device `cat $temporary_file`" to backup the
files.

I would like to modify step 2:
	2. use "tar cf $backup_device `cat $temporary_file |
quoteEncapsulate.pl`" to backup the files.

I have been using the following as 'quoteEncapsulate.pl':
#!/usr/bin/perl -w

@LINES = <STDIN>;
foreach $line ( @LINES ) {
        $line =~ s/\n//;
        print STDOUT "'$line' ";
}


**THE PROBLEM**
tar _ALWAYS_ reports that it cannot find the files output by
quoteEncapsulate.pl.  I think that it is possible that the (') character
returned by the perl script may be of a different code value than that
expected by tar.  I have also tried (\") in place of (') in the above
code snippet.  Neither seem to work.

**MY QUESTION**
Should I be using a hex code in the above code snippet in place of (')
or (")?  Can anybody else get this system to work?

Matt


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

Date: Mon, 16 Jun 1997 18:06:07 +0100
From: Simon Fairey <sfairey@metrica.co.uk>
To: Henrik Schmiediche <henrik@stat.tamu.edu>
Subject: Re: Perl language question - a regular expressions.
Message-Id: <33A5727F.19A1@metrica.co.uk>

Henrik Schmiediche wrote:
> 
>     Hello,
> I am trying to configure a database server written in perl. I need
> to restrict access to the server from IP addresses:
> 
>     165.91.*.*
>     128.194.*.*
> 
> I do this by specifying a variable called AddressMask:
> 
>   AddressMask = 165\.91\.*
> 
> which would restrict access o the first of the two IP address
> ranges. Problem is I am not sure how to write the AddressMask
> so that both address ranges above are valid and no others.
> 
> The code in the perl program that checks for the correct address
> is:
> 
>         if ($Config{'AddressMask'}) { # Check address
>             unless ($inetaddr =~ /$Config{'AddressMask'}/) {
>                 print NS
>                     "010 Connections from address $inetaddr" .
>                         " not allowed on this server\n";
>                 close NS;
>                 exit;
>             }
>         }
> 
> Is there a Regular Expression I can create to allow access
> from both IP address ranges?
> 
> Thanks.
>      - Henrik
> --
> Henrik Schmiediche, Dept. of Statistics, Texas A&M, College Station, TX 77843
> E-mail: henrik@stat.tamu.edu  |  Tel: (409) 862-1764   |  Fax: (409) 845-3144

You could use:
  $inetaddr =~ /^(165.91|128.194)\./;
which should do the trick.

Have fun.

Simon


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

Date: 14 Jun 1997 02:01:36 GMT
From: amore@teleport.com (Linux_User)
Subject: Re: Perl to awk translator
Message-Id: <slrn5q3v0p.v2.amore@teleport.com>

In article <8crae611gb.fsf@gadget.cscaper.com>, Randal Schwartz wrote:
>>>>>> "Martin" == Martin Rvth <martin.roeth@mail.heyde.de> writes:
>Martin> Hello,
>Martin> I'm looking for an easy method to translate perl scripts to awk. I know
>Martin> about the a2p translator, but is there something like a p2a translator.
>
>It's not possible.  Perl is a semantic superset of awk.  You can go
>the other way almost mechanically because awk is, well, a subset of
>Perl.

Actually, it *is* possible. When the features used are of the common set :-)

-B

>Can we ask, why you need such a translator?

>print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
>## legal fund: $20,495.69 collected, $182,159.85 spent; just 444 more days
>## before I go to *prison* for 90 days; email fund@stonehenge.com for details
>
>-- 
>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@ora.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: 16 Jun 1997 19:53:15 GMT
From: fty@hickory.engr.utk.edu (Jay Flaherty)
Subject: Re: Printing Prime Numbers
Message-Id: <5o45jb$8ml$2@gaia.ns.utk.edu>

Abigail (abigail@fnx.com) wrote:
: 
: Here's an implementation:
: 
: #!/usr/local/bin/perl -wl
: use strict;
:  
: my ($prime, $max) = (2, shift || 50);          # First prime, max number.
: my @sieve = (0, 0, map {1;} ($prime .. $max)); # Init sieve.
:  
: while ((my $product = $prime * $prime) <= $max) {
:     do {$sieve [$product] = 0;} while (($product += $prime) <= $max);
:     do {$prime ++;}             while !$sieve [$prime];
: }
:  
: map {print if $sieve [$_];} (0 .. $max);
: __END__
: 

I tried the above and have the following result:
Global symbol "product" requires explicit package name at ./prime line 8.
Variable "$product" is not imported at ./prime line 8.
Global symbol "product" requires explicit package name at ./prime line 8.
"/pear/fty/.article" 53 lines, 1872 charactersn errors.

I remarked the "use strict" line and have the following result:
Use of uninitialized value at ./prime line 8.
3$5$7$9$11$13$15$17$19$21$23$25$27$29$31$33$35$37$39$41$43$45$47$49$

I print all odd numbers starting at 3. Am I missing something?

BTW...I ran this on a Sun Ultra1. I also ran Randal's code and it screams.
Way faster than anyone so far.

Jay

-- 
**********************************************
Jay Flaherty                       fty@utk.edu

If software was free, who would pay "THE BILL"
**********************************************

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

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


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

Date: Mon, 16 Jun 1997 11:35:42 -0700
From: chris smith <naxos@rocketmail.com>
Subject: Repeating characters
Message-Id: <33A5877E.1582@rocketmail.com>

I know this is an easy one, but danged if I can find it in any of my
books.

How do you get a repeat of a character, such as I want to place $x tab
spaces into a certain place.  What command will tell perl to insert $x
tab characters (or any other characters, for that matter).

Quick help is greatly appreciated.  My boss is breathing down my neck
for this program.


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

Date: 16 Jun 1997 16:50:07 GMT
From: "John Bokma" <jbokma@caiw.nl>
Subject: Re: rounding off numbers
Message-Id: <01bc7a75$7fb40dc0$d90ab2c2@tschai>



Brent Brookler <brent@mountainzone.com> wrote in article
<33A1965B.249@mountainzone.com>...
> Hey all
> 
> need a little help here in PERL
> 
> i have a number like this .0909098877666 and I want to to round it
up
> and move the decimal two places so that it's a percent
> 
> so that it now will be 9.1 percent 
> 
> any help would be greatly appreciated

muliply the number by 10 to the power (number of decimal places)
add 0.5
use int 
divide the number by 10 to the power (number of decimal places).

In your specific case:

$perc = int(0.5 + $perc * 1000) / 10

this gives you a percentage with one digit after the decimal point.

John


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

Need a Freelance Software Developer (MSc)? (CGI, Perl, Java, C, C++)

http://www.caiw.nl/~jbokma [Java demo's, Curriculum Vitae and
more...]

email: jbokma@caiw.nl  phone: +31 10 4291827



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

Date: Mon, 16 Jun 1997 12:36:17 -0600
From: x@apocalypse.org
Subject: Sending e-mail using Perl for NT - don't wanna... gotta
Message-Id: <866481687.19948@dejanews.com>

I'm being "forced" (no gun to my head... at least not literally)
to port some perl CGI scripts from Unix to NT. Sending e-mail
with perl on Unix is easy enough... open a pipe to sendmail... but
how would I send e-mail from perl on NT? Thanks.
P.S. Thanks to those who responded to my other recent post.
- Xochi

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 16 Jun 1997 13:30:53 -0500
From: jesten@earth.execpc.com (Jim Esten)
Subject: Re: Sending e-mail using Perl for NT - don't wanna... gotta
Message-Id: <5o40ot$gbf$1@earth.execpc.com>

Get a copy of blat.... lightweight and works well inside of scripts.

Jim



x@apocalypse.org wrote:
: I'm being "forced" (no gun to my head... at least not literally)
: to port some perl CGI scripts from Unix to NT. Sending e-mail
: with perl on Unix is easy enough... open a pipe to sendmail... but
: how would I send e-mail from perl on NT? Thanks.
-- 
Jim Esten
(temporarily between .sigs)


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

Date: Mon, 16 Jun 1997 18:47:16 GMT
From: danew@enterprise.net (Matthew Burnham)
Subject: Re: Sending E-Mail with attachment from CGI?
Message-Id: <33a54004.412910@194.72.192.4>

Asahi Japan Collectibles <asahijc@erols.com> wrote:

>I am an amateur programmer. I'm looking for a way to send e-mail (with attachment) from 
>CGI (Perl). 
This is sends mails uuencoded (it's from a larger script so looks a
mess, but it should give you a rough idea of how to do it - the really
crucial bit [the bit that I got stuck on] is the $sendMsg =~
s/\n/\r\n/mog; line which sorts the newlines out properly before
encoding.

	$mailprog = '|/usr/sbin/sendmail -t';
	$filename = 'file_to_be_sent';

	open(FILE, "<$filename");
	while(<FILE>)
	{
		$sendMsg = $sendMsg . $_;
	}
	close(HELP);

	$sendMsg =~ s/\n/\r\n/mog;
	$sendMsg = "begin 644 $filename\n" . pack("u", $sendMsg) .
"end\n";

	$sendSubject = $subject;

	open(MAIL,"$mailprog");
	print MAIL "To: whoever@whereever\n";
	print MAIL "From: whoever@whereever\n";
	print MAIL "Subject: Whatever\n\n";	# last header line
therefore \n\n

	print MAIL "$sendMsg\n\n";
	close (MAIL); # send



-- 
Matthew Burnham, Manager, MindWeb | danew@enterprise.net
Commercial web design and hosting, reasonable rates
UKP24/Mb/Year for DIY space | mindweb@pobox.co.uk
FTP, CGI, password protection, etc. too!
http://www.mindweb.co.uk/


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

Date: 16 Jun 1997 16:33:40 GMT
From: isc60289@leonis.nus.sg (Thee Boon Hoo)
Subject: Sort equivalent in Perl
Message-Id: <5o3pt4$575@nuscc.nus.sg>

Hi,

This may be a simple question; hope you all bear with me:),

I have a file that contains (line-by-line) Name of customer, Email
address, name of products and quantities. Each field is separated by a
colon. I intend to sort each line by the names of the customers (which is
the first field) in alphabetical order. I tried reading the man pages and
the CAmel book, and they said something like sort SUB LIST, with the
parameters in the subroutine as $a and $b, but i still couldn't find the
way to do it. Instead, by using Unix command, it can be done with

sort -f -t : <filename> 

CAn anyone give some tips? I'm really interested to know how to do it in 
Perl:)

--
boonhoo


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

Date: Mon, 16 Jun 1997 18:34:09 +0100
From: Simon Fairey <sfairey@metrica.co.uk>
To: Thee Boon Hoo <isc60289@leonis.nus.sg>
Subject: Re: Sort equivalent in Perl
Message-Id: <33A57911.353C@metrica.co.uk>

Thee Boon Hoo wrote:
> 
> Hi,
> 
> This may be a simple question; hope you all bear with me:),
> 
> I have a file that contains (line-by-line) Name of customer, Email
> address, name of products and quantities. Each field is separated by a
> colon. I intend to sort each line by the names of the customers (which is
> the first field) in alphabetical order. I tried reading the man pages and
> the CAmel book, and they said something like sort SUB LIST, with the
> parameters in the subroutine as $a and $b, but i still couldn't find the
> way to do it. Instead, by using Unix command, it can be done with
> 
> sort -f -t : <filename>
> 
> CAn anyone give some tips? I'm really interested to know how to do it in
> Perl:)
> 
> --
> boonhoo

Try having a look at the following:

http://www.perl.com/perl/everything_to_know/sort.html

combined with the Camel and the MAN pages it should provide you with
enough to go on.

Have fun.

Simon


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

Date: Mon, 16 Jun 1997 19:13:58 GMT
From: rist@zkrd.de (Hans-Georg Rist)
Subject: Re: Trouble building 5.,004 on Linux
Message-Id: <33a59051.1986312@news.uni-ulm.de>

bernie@rev.net (Bernard Cosell) wrote:

>I can't get 5.004 to run on our Linux system [1.2.13].  It seems to
>compile OK [only a lot of warnings about preprocessor redefine of
>ENDIAN] but make test failed in comp/use.t.  The test just hangs
>eating up CPU time and never completes.  When I try to run that test
>by hand I get:
>
>merlin:/usr/src/perl5.004/t$ ./perl comp/use.t
>1..14
>ok 1
>
>And after the 'ok 1' it is just gone, off someplace eating up CPU
>time.  I tried running the test with 'harness' and it didn't change
>anything: still just hangs in use.t

I have the same problem. My checks showed that it seems to be a
(s)printf problem but I didn't have the time for more debugging.
There are some more tests which use (s)printf and hang if you run them
separatly, e.g. './perl op/rand.t'.
BTW: perl5.003_97 compiled well and no test failed.

HG

| Hans-Georg Rist     ZKRD, Zentrales Knochenmarkspender-Register
| Helmholtzstr. 10    Deutschland, gGmbH
| P.O.B. 4244         German National Registry of Bone Marrow Donors
| D-89032 Ulm         http://www.zkrd.uni-ulm.de
| Phone: +49 731 95430-46, Fax: +49 731 95430-50, email: rist@zkrd.de


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

Date: Sun, 15 Jun 1997 17:47:07 -0600
From: Keys <keys@babylon5fan.com>
Subject: Re: Troubles with perl scripts
Message-Id: <33A47EFB.2CEC3226@babylon5fan.com>

Edison Montes X wrote:
> 
> I have a script that got a hit counter.
> When I execute it on UNIX it works OK.
> When I try to execute it on Netscape, it doesn't and it shows the code.

Your webserver does not recognize it as an executable file, probably
because it ends in .pl, which usually means nil to webservers.  Try
renaming it to whatever.cgi so the server will recognize it as a CGI
script and execute it (if you have CGI execute permission on that
account)...


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

Date: Mon, 16 Jun 1997 11:58:18 -0600
From: wynnytv@abc.com
Subject: UserAgent w/ security enabled?!?!
Message-Id: <866478021.16282@dejanews.com>

This is what I did before security...

   use LWP::UserAgent;
   use HTTP::Request;

   my $ua = new LWP::UserAgent;
   my $request = new HTTP::Request("GET", "http://nyanwebd/acs/vic.htm");
   my $response = $ua->request($request);
   print $response->content();

Now I need to plug in my username and password.
Do I do that with this function...
   $ua->credentials($netloc, $realm, $uname, $pass);

What to I put in for $netloc and $realm???!!?!?!?

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 16 Jun 1997 20:37:34 GMT
From: respect@voicenet.com (Chad Glynn)
Subject: Re: What does "UNIX" stand for..
Message-Id: <5o486e$j5j$1@news3.voicenet.com>

Bill (Gates) Erwin wrote:

> UNIX started out as "Castrated MULTICS" and was shortened from there.
> Check out the "UNIX Haters Handbook" for further details.
>
> Bill

	A joke among some friends of the Unix community about those
cult members from the San Diego is that they were very clueless... that
the reason that some of them castrated themselves was to "Eunich"
Programmers. :X


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

Date: Mon, 16 Jun 1997 13:07:59 -0400
From: "James J. Heck" <jheck@merck.com>
Subject: Xsub: changing an already added library
Message-Id: <33A572EF.41C6@merck.com>

I have an XSub library already built.  After I build it into the perl 
binary what happens if I want to change/add functions to the library?
Can I just need to change the library files?  Or do I have to rebuild 
PERL again before the changes take place?
	Please send any mailed responses to jheck@acm.org.
	TIA,

		James
--------------------
James J. Heck
jheck@acm.org
http://www.bucknell.edu/~jheck


       The contents of this message express only the sender's opinion.
       This message does not necessarily reflect the policy or views of
       my employer, Merck & Co., Inc.  All responsibility for the statements
       made in this Usenet posting resides solely and completely with the
       sender.


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

Date: 16 Jun 1997 18:42:32 GMT
From: ftbv4s47y@inet.it
Subject: Your Secret Password
Message-Id: <5o41eo$3qm@news1-alterdial.uu.net>


Get UNLIMITED FREE ACCESS to over 1200 of the 
Hottest Adult Sites on the Web!

Also get FREE UNLIMITED Live Video Sex and 
FREE XXX Chat Room Access!  

Stop paying to get into Adult Sites...  
This secret password gets you into them for FREE!!!  

http://205.199.212.240/secretpassword/


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

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

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