[7010] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 635 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 19 11:18:07 1997

Date: Thu, 19 Jun 97 08:00:36 -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           Thu, 19 Jun 1997     Volume: 8 Number: 635

Today's topics:
     -Nude Teenage girls *ten.jpg a;slfkjsa;oiruweoi@;asldfjasld;fj.com
     Re: [HELP] PERL/Shell scripting project (Hal Larson)
     Re: appending two files into one? <ajohnson@gpu.srv.ualberta.ca>
     Re: appending two files into one? (Nathan V. Patwardhan)
     Re: appending two files into one? (Magnus Bodin)
     Re: Broken Pipe (Nathan V. Patwardhan)
     delayed Output (J|rgen Mangler)
     Re: help needed with DB_File (Paul Marquess)
     Help! upload from Netscape through AOL (Charles Shehadi)
     Re: Help! upload from Netscape through AOL (Nathan V. Patwardhan)
     libwww, how to define routines for new tags? (Calle ]sman)
     Re: Logical XOR <merlyn@stonehenge.com>
     MIME encoding <schramm@one.net>
     Re: MIME encoding (Nathan V. Patwardhan)
     Re: multiple white spaces (Gabor)
     Re: Perl and HTML forms question (Brett Borger)
     Re: Perl and HTML forms question <jbokma@caiw.nl>
     PERL/CGI Database <darren.shilson@wago.de>
     Problem reading lines with Win95 (Dick Sisco)
     Re: Q: Can I interpret a string as a variable name? (Andrew M. Langmead)
     Re: scalar vs array <zenin@best.com>
     Re: Scanning for Low & High ASCII in a text file (M.J.T. Guy)
     Re: Script to verify email addresses? (John Strange)
     Re: Sorting Associative Array? (Urgent) <zenin@best.com>
     Re: Sorting Associative Array? (Urgent) (Calle ]sman)
     Re: sybperl DBlib question mpeppler@mbay.net
     Re: Traslate or other method? <sfairey@metrica.co.uk>
     Re: what module to use for sysopen? (Tad McClellan)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 19 Jun 1997 13:45:40 GMT
From: a;slfkjsa;oiruweoi@;asldfjasld;fj.com
Subject: -Nude Teenage girls *ten.jpg
Message-Id: <5obd64$j5p@mtinsc05.worldnet.att.net>


Check out this site, it has tons of Cheerleaders Fucking and Sucking Cock.

Are you ready to cum on a Cheerleaders Face?


Then check out:



		http://www.nasty-cheerleaders.com









All models represented on Nasty-Cheerleaders are 18 years of age or older.






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

Date: Thu, 19 Jun 1997 13:33:51 GMT
From: hlarson@mail.hesch-prod.com (Hal Larson)
Subject: Re: [HELP] PERL/Shell scripting project
Message-Id: <33a9342b.4179173@allnews.nr.infi.net>

sehrlich@shore.net (Scott R. Ehrlich) wrote:

>Here's my project -
>
>I would like to send weather pages to myself from data which I am
>anonymously FTPing from a weather site. All are ASCII files.
>
>Part one will be to get the files. Part two will be to compare sizes
>(newly transfered files from existing copy). If the sizes are the same,
>don't do anything. If they are different (meaning there is a change in
>the data), process them. Part three will be to send them to my pager. 
>
>Here is the breakdown:
>
>- FTP one of each file (hourly update, zone forecast, and alert) manually
>to set the foundation.  Since a couple of the files have the same name, I
>will name the hourly update one 'hourly', the zone forecast one 'zone',
>and the alert 'alert'.
>
>- FTP (via ncftp?) files on a regular basis and compare the new files to
>the existing ones.  To prevent file overwrites, I'll rename these new
>files hourly-new, zone-new, and alert-new.  If the new and old copies are
>the same, do nothing.  But, if there is a difference, meaning something
>has changed...
>
>- extract just the rows and columns I want each from the hourly, zone, and
>alert files, and pipe the results to a new files (i.e. hourly-extract,
>zone-extract, alert-extract)
>
>- Once the final extracted files have been created, since the e-mail ->
>pager gateway of the paging service truncates at 230 characters, the final
>step will be to extract every 230 characters from hourly-extract,
>zone-extract, and alert-extract, to a new file (hourly.1, hourly.2,
>zone.1, zone.2, etc), with hourly.1 containing the first 230 chars,
>hourly.2 containing the next 230 chars, etc, until the full message has
>been broken down.  Finally, sending each multi-part file to the gateway to
>cirumvent their 230 character restriction, permitting me to get the whole
>message in multiple parts. 
>
>- run a cron job to automate the above script.
>
>Thanks for any help, guidance, assistance, etc.
>
>-- 
>Scott Ehrlich				sehrlich@shore.net
>Scott Ehrlich Consulting		Amateur Radio Callsign: wy1z
>


Scott,
Everything you mention is do-able within Perl or any of the standard shells
(c,k,bourne).  If you know or sure that the sizes will differ between
current and new files, you might want to use the ls command in your ftp
script and compare sizes before downloading.  This will speed up your
program unless the files are so small that download time is minimal.

Check out the man page for ftp.  Last time I checked, it had a very nice
little example of how to script ftp transfers.


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

Date: Wed, 18 Jun 1997 16:51:24 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: appending two files into one?
Message-Id: <33A8585C.6CADB728@gpu.srv.ualberta.ca>

Mike Stok wrote:
> 
> In article <5o8phc$gc@fridge-nf0.shore.net>,
> Nathan V. Patwardhan <nvp@shore.net> wrote:
> >Magnus Bodin (Magnus.Bodin@tychonides.se) wrote:
> >
> >: foreach $appfile (@ARGV) {
> >:         open(TMP,$appfile);
> >
> >Ouch.
> >
> >perl -e 'while(<>) { print; }' filename filename >> out.txt
> 
> Ouch ;-)
> 
> perl -pe '' filename filename >> out.txt
> 

Ouch 8^)

perl -pe '' filename filename > out.txt

regards
andrew


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

Date: 19 Jun 1997 14:02:07 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: appending two files into one?
Message-Id: <5obe4v$sob@fridge-nf0.shore.net>

Blake Winton (bwinton+spam@incontext.ca) wrote:

: < filename < filename > out.txt

: (hey, works in my shell... ;)

Oh.  Well, it's not Perl, but I'm giving you a B for creativity.  :-)

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: Thu, 19 Jun 1997 14:13:48 GMT
From: Magnus.Bodin@tychonides.se (Magnus Bodin)
Subject: Re: appending two files into one?
Message-Id: <33a93e6e.30303934@news1.telenordia.se>

nvp@shore.net (Nathan V. Patwardhan) wrote:

>Magnus Bodin (Magnus.Bodin@tychonides.se) wrote:
>
>: foreach $appfile (@ARGV) {
>:         open(TMP,$appfile);
>
>Ouch.
>
>perl -e 'while(<>) { print; }' filename filename >> out.txt
>

OK. Ouch. But I just HAD to show how to read files. Should really have
included the perl -e version too. 


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

Date: 19 Jun 1997 14:05:43 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Broken Pipe
Message-Id: <5obebn$sob@fridge-nf0.shore.net>

Alex `Taker` Pircher (pircher@informatik.tu-muenchen.de) wrote:
: I got "Broken Pipe" after I opened & closed several Connections
: to my (with perl created) Socket.

Hmm.  Something must be broken with your code.

: What I'm making wrong?

Since my telepathic senses are failing me today (due to a sinus
infection), please post some code to this newsgroup, and we'll all try
and analyze it.  :-)

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 19 Jun 1997 14:33:17 GMT
From: a4431ndm@pcserv.univie.ac.at (J|rgen Mangler)
Subject: delayed Output
Message-Id: <5obfvd$1cjc@www.univie.ac.at>

I want to create a cgi-programm that prints characters (e.g. 10) into the 
browser window with a delay of 1 second. But the browser always waits until 
the whole document is created (for example 10 seconds for these 10 characters) 
and then he loads in the whole page in one peace. Is there a way to reach
this 'slowly-reading-the-characters-in' effect?

Thanks J|rgen



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

Date: 19 Jun 1997 11:38:52 GMT
From: pmarquess@bfsec.bt.co.uk (Paul Marquess)
Subject: Re: help needed with DB_File
Message-Id: <5ob5oc$3m7$1@pheidippides.axion.bt.co.uk>

Yuan-fang Wang (yfwang@cs.ucsb.edu) wrote:
: Folks:

: I hope someone can help me with the following:

: 1. I used dbmopen and dbmclose to manage hash data from CGI.  However, I
: noticed that the the key/value pairs are limited to 1024 bytes total.
: Is there a way to enlarge the 1024 limit?  Also, the Perl Camel book
: mentions that there is no way to lock/unlock with dbmopen. Then what
: happens with multiple simultaneous accesses, will that introduce 
: inconsistency into the hash data file?

: 2. I also look into DB_File which seems to overcome the above
: difficulties: that DB_File allows key/value pairs to be of any size and
: provides a locking and unlocking mechanism for mutual exclusive access
: to a hash file.  However, 'Use DB_File' returns an error message (meaning
: that DB_File is not installed on our site). I went to CPAN and followed the
: link ftp://ftp.cdrom.com/pub/perl/CPAN/modules/by-module/DB_File/ only
: to find an ILYAZ directory which doesn't seem to contain DB_File. Can
: anyone tell me where to get DB_File?  

DB_File comes with Perl. If you haven't already got Berkeley DB, Perl
will not build/install DB_File.

Alternatively, look in CPAN/authors/id/PMQS/ for DB_File-1.14.tar.gz

: 3. If I would like to have (1) key/value pairs to be of any size and
: (2) a locking and unlocking mechanism for mutual exclusive access
: to a hash file, is DB_File the way to go? Any other ways? 
: I tried SDBM_File and NDBM_File, but cannot figure out how
: to do locking with them.  

Locking in DB_File isn't perfect, but the method documented in the man
page seems to work for most people.

GDBM_File doesn't have the size restriction. Can't remember about
locking though.

Paul


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

Date: 19 Jun 1997 13:54:20 GMT
From: cshehadi@panix.com (Charles Shehadi)
Subject: Help! upload from Netscape through AOL
Message-Id: <cshehadi-1906971000220001@cshehadi.dialup.access.net>

Hi... I'm under the gun here... any help would be appreciated.

I'm writing a cgi script to handle a file upload using Netscape's
multipart form feature.

It works fine when you are running Netscape off of a connection through an
internet service provider.  

but...

I just tested it running Netscape through a "Winsock" connection with AOL
and it will only work for text files of about 50 characters or less.  Any
file that's larger gets hung up, and won't upload.

This web site is scheduled to be finished by June 26, and needs to be
working for paying customers by then, so there's a bit of urgency to this
question.

Thanks

-Charlie


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

Date: 19 Jun 1997 14:08:30 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Help! upload from Netscape through AOL
Message-Id: <5obegu$sob@fridge-nf0.shore.net>

Charles Shehadi (cshehadi@panix.com) wrote:

: I'm writing a cgi script to handle a file upload using Netscape's
: multipart form feature.

Please see comp.infosystems.www.authoring.cgi.  Although your script
*may* be written in Perl, it's not a Perl language issue so it doesn't
belong here.

You might also contact your AOL representative and ask them why their
server is munging your uploads.  :-)

Hope this helps!

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 19 Jun 1997 15:31:11 +0200
From: md4calle@mdstud.chalmers.se (Calle ]sman)
Subject: libwww, how to define routines for new tags?
Message-Id: <w7p205yd8io.fsf@fraggel54.mdstud.chalmers.se>

I want to define new routines for comments (<!--) and some new tags.
How do I do this?
To redefine old subroutines works fine, but I don't know how to make new ones.

/Calle




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

Date: 19 Jun 1997 04:20:42 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Stuart Cooper <stuartc@ind.tansu.com.au>
Subject: Re: Logical XOR
Message-Id: <8cen9yg7p1.fsf@gadget.cscaper.com>

>>>>> "Stuart" == Stuart Cooper <stuartc@ind.tansu.com.au> writes:

Stuart>   By the way, Perl newsgroupers; how about the names 'Red' and 'Blue'
Stuart> to describe the Perl 4 and Perl 5 Nutshell books. I've seen names like
Stuart> "Turquoise","Aqua" etc bandied about; for those of us not working
Stuart> with colourmaps; could "Red" and "Blue" be used? Otherwise I'll throw
Stuart> in "Peuss" for the Perl 4 coloured book...

During the rewrite, I occasionally referred to them as "pink" and
"blue", as in "girl book" and "boy book".  (I'm not sure how
cross-cultural this is... :-)

On a more formal note, I think of the second edition as "the camel
book" and the first edition as "the classic camel book".

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 439 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: Thu, 12 Jun 1997 20:42:16 -0400
From: "R. Schramm" <schramm@one.net>
Subject: MIME encoding
Message-Id: <5nq34r$er7$1@news.one.net>

Since no one seems to live in the comp.mail.mime ng, I am posting this
message here for those who have created MIME mail messages with HTML from
perl, maybe you can help.

I am writing an app that will send HTML formatted e-mail to several users. 
I sent myself an email message from IE4 in HTML format and looked at the
headers and duplicated them in the body of my message.  It uses quoted
print format as opposed to base64.

The encoding and decoding of the actual HTML seems to work OK, but the
headers are not being read properly by the mail client (again IE4) so the
client displays the HTML in the message instead of interpretting it and it
displays all the MIME headers in the message as well.  My client receives
HTML mail all the time, so it is not problem there, it must be my message
format.

If anyone has any example code or knows of anywhere where this is explained
more I would appreciate  it.

Thanks!




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

Date: 19 Jun 1997 13:59:42 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: MIME encoding
Message-Id: <5obe0e$sob@fridge-nf0.shore.net>

R. Schramm (schramm@one.net) wrote:
: Since no one seems to live in the comp.mail.mime ng, I am posting this
: message here for those who have created MIME mail messages with HTML from
: perl, maybe you can help.

Use the MIME::Lite module.

http://www.perl.com/CPAN/modules/by-module/MIME/

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 19 Jun 1997 13:18:13 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: multiple white spaces
Message-Id: <5obbil$l3m$1@flint.sentex.net>

Scott Blanksteen (sibsib@hotmail.com) wrote:
: Tri Duy Tram wrote:
: > 
: > I am wondering how do you change multiple white spaces to just one single
: > white space?  Lets suppose I have a string

: To change multiple white space chars into one space char (' '):

:     s/\s+/ /g;

This will also squash newlines.  If that was the intention then fine,
but if he just meant space and tab then you need something like

s/[ \t]+/ /g;

--
Gabor Egressy : gabor@quickweb.com
    No, I am not going to explain it.  If you can't figure it out, you
    didn't want to know anyway...  -- Larry Wall, 1991


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

Date: 19 Jun 1997 13:48:28 GMT
From: bxb121@psu.edu (Brett Borger)
Subject: Re: Perl and HTML forms question
Message-Id: <5obdbc$v66@r02n01.cac.psu.edu>

In article <33A84FEC.BAC73FE5@interport.net>, megspace@interport.net 
says...
>
>Is there a way to store the 'name' variable so that it can be read into
>webform2.cgi? Thanks for any suggetions.

In the HTML, include a line like:
<input type=HIDDEN name=name value=foobar>
THen in your webcgi2, simply read the value of name as you would any other 
variable coming into the form.  In webcgi be sure to make it so 
value=foobar has foobar set to whatever your variable was.  Also be sure 
to look out for "'s, since they pooch up the HTML pretty well, not to 
mention messing up print statements.

-=SwiftOne=-



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

Date: 19 Jun 1997 14:01:15 GMT
From: "John Bokma" <jbokma@caiw.nl>
Subject: Re: Perl and HTML forms question
Message-Id: <01bc7cb9$6644a520$d50ab2c2@tschai>



Barry Kaplan <megspace@interport.net> wrote in article
<33A84FEC.BAC73FE5@interport.net>...
> Perl newbie here. Sorry if this isn't very clear. I have a HTML
form
> from which the information is parsed though a perl script and
that's
> working fine. I also have the perl script outputting a second form
to
> request additional information from the user. This information then
gets
> passed off  to a second perl script. The problem is I can't figure
out
> if there is a way to pass off the information from the first form
to the
> second perl script. Here's a condensed example of what I'm trying
to do.
> 
> *******************************************************************
> 
> This is webform.html:
> 
> <FORM ACTION="cgi-bin/webform1.cgi" METHOD="POST">
> <P>Please enter your name:<BR>
> <INPUT TYPE="text" NAME="name" SIZE=30 MAXLENGTH=50>
> <P><INPUT type='submit' value='submit' ></FORM>\n";
> 
>  This is webform1.cgi:
> 
> #!/usr/bin/perl
> require 'cgi-libs/cgi_handlers.pl' ;
> &get_request();
> print "Hello", $rqpairs{'name'}, "!\n";
> 
> # here's the second outputted form from within the script.
> print "<FORM ACTION='webform2.cgi' METHOD='POST'>";
> print "<P>Please enter your email address:<BR>\n";
> print "<INPUT TYPE='text' NAME='email' SIZE=30 MAXLENGTH=50>\n";
> print "<P><INPUT type='submit' value='submit' ></FORM>\n";

Put the extra info you want to pass in hidden fields:

<INPUT type="hidden" NAME="yourname" VALUE="yourvalue">

These won't show up in the form (however! the user can see them in
the HTML
source!!). You can use get_request to obtain these hidden values..


> 
> This is webform2.cgi:
> 
> #!/usr/bin/perl
> require 'cgi-libs/cgi_handlers.pl' ;
> &get_request();
> print "Hello", $rqpairs{'name'}, "!\n";  # This is the variable
that
> won't carry over from the first form!
> print "Your address is", $rqpairs{'email'},"\n";
> 
> ******************************************************************
> 
> Is there a way to store the 'name' variable so that it can be read
into
> webform2.cgi? Thanks for any suggetions.

add:

print qq(<INPUT TYPE="hidden" NAME="name" VALUE="), $rqpairs{'name'},
qq(">\n);

qq() quotes the stuff between the brackets, so you can use " inside
the string.
AFAIK TYPE='hidden' is not valid HTML (single quotes). 

Regards,

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: Thu, 19 Jun 1997 13:56:45 +0100
From: Darren Shilson <darren.shilson@wago.de>
Subject: PERL/CGI Database
Message-Id: <33A92C8D.592C@wago.de>

Hi,

Does anyone know where I can get hold of examples of databases written
in PERL/CGI.

I want to write an Employee database, but need examples to work with.

I'd be grateful for any help

Thanks

Darren Shilson
Webmaster
Wandel & Goltermann
http://www.wg.com/


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

Date: Thu, 19 Jun 1997 07:09:21 -0600
From: dsisco@learningco.com (Dick Sisco)
Subject: Problem reading lines with Win95
Message-Id: <dsisco-1906970709220001@mecc3167.mecc.com>

Please excuse me if the following is a dumb question.  I am new to perl
programming.

I have written the following program to add HTML tags to a text file.

--------------------BEGIN PROGRAM--------------------------
$/ = "\x0d\x0a";                 # switch to MS-DOS line seperators
(doesn't help)
while ($line = <>) {
    chop($line);
    print ("DEBUG:",$line,"END\n");  #DEBUG: see what read line looks like
   # check for material descripter
    if ($line =- /^([A-Za-z ]+):(.+)$/) {
       print("<LI><B>",$1,":</B>",$2,"\n");
    # if blank line seperator
    } elsif ($line eq "") {
        print("<BR CLEAR=ALL>\n");
        print("<HR>\n");
        print("</UL>\n");
        print("</BODY>\n");
        print("</HTML>\n");
    # otherwise must be name of fly
    } else {
        print("<HTML>\n");
        print("<HEAD>\n");
        print("<TITLE>",$line,"</TITLE>\n");
        print("</HEAD>\n");
        print("<BODY BGCOLOR=\"#FFFFFF\" LINK=\"#00009C\"
VLINK=\"#00009C\" ALINK=\"#FF0000\">\n");
        print("<H2 ALIGN=CENTER>",$line,"</H2>\n");
        print("<HR>\n");
        print("<IMG SRC=\"none.jpg\" ALIGN=RIGHT>\n");
        print("<UL>\n");
    }
}
--------------------END PROGRAM--------------------------

When given the following input (via c:perl test.pl caddis.1 >test.html) 
consisting of several groups of lines seperated by a blank line, the program
prints "DEBUG:", the entire input file,  "END", the section beginning "BR CLEAR
=ALL", a 0, and finally, the section beginning "<HTML>".

It sure looks to me like perl is not recognizing end of line seperators--
which I have verified are 0x0d and 0x0a in the text file. That was why I
tried to force MS-DOS line seperators.  That made no difference at all.

I am using Perl 5 for Windows 95 build(?) 306.  I have read the man pages 
that come with that release.  I have worked through the examples
in the first couple of chapters of the Sams book "Teach Yourself Perl in
21 Days".  Examples in the Sams book on file reading seem to display the
same problem as above.

This sure seems to me to be a problem with my instalation of the perl package
on my machine (it was automatic: perlw32-install.bat executed without errors)
so I have reread the release notes several times and perused several perl for
Win95 web pages without finding a clue.

If anyone can tell me why I can't seem to be able to read a single line at
a time from a file, or point me fairly specificly to a resource that will
give me that information, I would appreciate it greatly.

Thanks for any help you can offer.

-- 
--------------------------------------------------------------------
Dick Sisco         dsisco@primenet.com         dsisco@learningco.com
--------------------------------------------------------------------


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

Date: Thu, 19 Jun 1997 13:55:31 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Q: Can I interpret a string as a variable name?
Message-Id: <EC100J.IBF@world.std.com>

Ronald Fischer <rfi@uebemc.siemens.de> writes:
>Nothing on earth is so strange that it can't be solved in perl. As a
>starter:
>   perl -e '$v="x"; $w="y"; $xy="it works\n"; print eval(q($).$v.$w);'
>outputs:
>   it works

The trick is, to find the best one. Using symbolic references is much
faster, 

perl -e '$v="x"; $w="y"; $xy = "it works\n"; print ${ $v . $w }'

If you benchmark like this:

#!/usr/bin/perl

use Benchmark;


timethese(100000, {
  eval_way => '$v="x"; $w="y"; $xy="it works\n";  eval(q($).$v.$w);',
   ref_way => '$v="x"; $w="y"; $xy = "it works\n";  ${ $v . $w }'
});

you'll see results like this:

Benchmark: timing 100000 iterations of eval_way, ref_way...
  eval_way: 37 secs (35.79 usr  0.06 sys = 35.85 cpu)
   ref_way:  2 secs ( 1.53 usr  0.00 sys =  1.53 cpu)

-- 
Andrew Langmead


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

Date: 19 Jun 1997 10:01:18 GMT
From: Zenin <zenin@best.com>
Subject: Re: scalar vs array
Message-Id: <5ob01e$qkd$1@nntp2.ba.best.com>

Mats Larsson <matlar@rsv.se> wrote:
> I tried to call a subroutine in a "smart" way like this, i.e I want
> the subrotine to recieve the minussign when no arguments given.
>   &fil_utskr (@ARGV||"-") unless $opt_P;
	>snip<
> It's just interesting to know if there is some way to force ARGV to be 
> array or is it incompatible whith the || operator.
	Just call it like this:

	&fil_utskr (@ARGV ? @ARGV : '-') unless $opt_P;

> I want to write out information on every file opened that's why I transfer
> the filenames to the subroutine instead of just using (<>) for reading.
	You're working to hard.  Check out $ARGV in the perlvar man page.
	Maybe also want to look at eof() in the perlfunc page.
-- 
-Zenin
 zenin@best.com


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

Date: 19 Jun 1997 12:07:05 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Scanning for Low & High ASCII in a text file
Message-Id: <5ob7d9$s6o@lyra.csx.cam.ac.uk>

Keith Christian <keith_christian@smtpgate.tais.com> wrote:
>
>          unless (m/0x00-0x1f/ || m/0x7f-0xff/) {

The form of hex characters substituted in a double-quoted string or regex,
is  \x1f, so that line needs to be

           unless (m/\x00-\x1f/ || m/\x7f-\xff/) {


Mike Guy


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

Date: 19 Jun 1997 12:25:33 GMT
From: jstrange@imtn.dsccc.com (John Strange)
Subject: Re: Script to verify email addresses?
Message-Id: <5ob8ft$ab5@camelot.dsccc.com>

You could ask the SMTP deamon to check the address.
Check  RFC 821 for commands.

	or try this code snippett

/************************************************************************
*
*	ckeaddr.pc -- network server test driver
*
*
************************************************************************/

	/**************************************************************
	*
	*	include definitions
	*
	**************************************************************/

#include <sys/types.h>			/* data type definitions		*/
#include <limits.h>			/* system limits definitions		*/
#include <stdlib.h>			/* malloc,.....				*/
#include <stdio.h>			/* standard in/output			*/
#include <errno.h>			/* errno/strerror def			*/
#include <netdb.h>			/* /etc/hosts table entries		*/
#include <signal.h>			/* sig_pipe defs			*/
#include <string.h>			/* strcpy,...				*/
#include <syslog.h>			/* openlog, syslog,....			*/
#include <time.h>			/* get date/time info			*/
#include <unistd.h>			/* sleep, getpid, getppid definition	*/
#include <netinet/in.h>			/* sockaddr_in structure		*/
#include <sys/systeminfo.h>		/* sysinfo def,.....			*/
#include <sys/socket.h>			/* sockaddr,socket,bind,accept		*/
#include <sys/utsname.h>		/* utsname definitions			*/
#include <sys/stat.h>			/* umask settings			*/
#include <sysexits.h>

#include "local.h"			/* local defines and includes		*/


	/************************************************************************
	*
	*	Global function declarations
	*
	************************************************************************/

static int read_smtp () ;		/* read a line from socket	*/
static int send_smtp () ;		/* write a line to the socket	*/
static void echo_string () ;		/* echo send/read strings	*/

	/************************************************************************
	*
	*	Global variable declarations
	*
	************************************************************************/

static	int			end_of_server ;			/* end of server flag			*/
static	int			cnt ;			        /* number of bytes I/O			*/
	int			sock_1 ;
	char			crlf [6] ;
	char			read_msg[256] ;
	char			toke_str[256] ;
	char			err_msg[256] ;
	char			send_msg[256] ;
	char			node[20] ;
	char			mail_status [15] ;
static char   			message[] = "Hi there." ;
static struct sockaddr_in	sock2_name ;
struct hostent			hostentstruct ;
	char			*ptr ;
struct hostent			*hostentptr ;
static char			hostname[256] ;
	int    			flag ;
	int    			shut = FALSE ;
static	int    		 	 lint_rtn ;                      /* lint return code             */
static	char    		 *lint_ptr ;                     /* lint return pointer          */
	long int		msg_size ;
static	int			optval = 1 ;			/* used by setsockopt			*/
static	int			optlen = sizeof (optval) ;	/* used by setsockopt			*/

int main (int argc, char **argv)
{
	lint_rtn = sprintf (crlf, "\r\n") ;

	lint_rtn = sysinfo (SI_HOSTNAME, node, sizeof (node)) ;
	if (lint_rtn < 0)
	{
	  sprintf (send_msg, "sysinfo SI_HOSTNAME: %s", strerror (errno)) ;
	  fprintf(stderr, "%s%s", crlf, err_msg) ; 
	  _exit (EXIT_FAILURE) ;
	}


	sock_1 = socket (AF_INET, SOCK_STREAM, 0) ;
	if ( sock_1 == -1)
	{
	  sprintf (err_msg, "socket: %s", strerror (errno)) ;
	  fprintf(stderr, "%s%s", crlf, err_msg) ; 
	  _exit (EXIT_FAILURE) ;
	}


	lint_rtn = setsockopt (sock_1, SOL_SOCKET, SO_REUSEADDR, (char *) &optval, optlen) ;
	if (lint_rtn < 0)
	{
	  lint_rtn = fprintf (stderr, "setsockopt failure %s\n", strerror (errno)) ;
	  exit (errno) ;
	}

	hostentptr = gethostbyname (node) ;
	if ( hostentptr == NULL)
	{
	  sprintf (err_msg, "gethostbyname: %s", strerror (errno)) ;
	  fprintf(stderr, "%s%s", crlf, err_msg) ; 
	  _exit (EXIT_FAILURE) ;
	}

	hostentstruct = *hostentptr ;

	sock2_name.sin_family = hostentstruct.h_addrtype ;
	sock2_name.sin_port = IPPORT_SMTP ;
	sock2_name.sin_addr = * ((struct in_addr *) hostentstruct.h_addr) ;

	lint_rtn = connect (sock_1,  (struct sockaddr *) &sock2_name, sizeof (sock2_name)) ;
	if (lint_rtn)
	{
	  sprintf (err_msg, "connect: %s", strerror (errno)) ;
	  fprintf(stderr, "%s%s", crlf, err_msg) ; 
	  cleanup (shut, sock_1) ;
	}

	flag = 0 ;

	send_msg[0] = '\0' ;


	if (sock2_name.sin_port != IPPORT_ECHO)
	  lint_rtn = read_smtp () ;

	lint_rtn = sprintf (send_msg, "VRFY rra@stanford.edu%s", crlf) ;
	lint_rtn = send_smtp (send_msg) ;

	if (strcmp (mail_status, "250") != 0 )
	  lint_rtn = fprintf (stdout, "%s\n", read_msg) ;

	lint_rtn = sprintf (send_msg, "VRFY jughead@dsun2.dsccc.com%s", crlf) ;
	lint_rtn = send_smtp (send_msg) ;

	if (strcmp (mail_status, "250") != 0 )
	  lint_rtn = fprintf (stdout, "%s\n", read_msg) ;

	shut = TRUE;
	cleanup (shut, sock_1) ;

	return (EXIT_SUCCESS) ;

} /* end main */

cleanup (int shut, int socket)
{
	if (shut)
	{
	  lint_rtn = sprintf (send_msg, "QUIT%s", crlf) ;
	  lint_rtn = send_smtp (send_msg) ;

	  lint_rtn = shutdown (socket, 2) ;
	  if (lint_rtn == -1)
	    perror ("shutdown") ;
	}

	lint_rtn = close (socket) ;
	if (lint_rtn)
	  perror ("close") ;

	_exit (EXIT_SUCCESS);

} /* end cleanup */

static int send_smtp ()	/* write a line to the socket	*/
{
	cnt = write (sock_1, send_msg, strlen (send_msg)) ;
	if (cnt < 0)
	{
	  lint_rtn = fprintf (stderr, "send_smtp: write failure %s\n", strerror (errno)) ;
	  lint_rtn = close (sock_1) ;
	  end_of_server = TRUE ;
	  lint_rtn = errno ;
	}

	lint_rtn = read_smtp () ;

	return (lint_rtn) ;
	
} /* end send_smtp */

static int read_smtp ()		/* read a line from socket	*/
{
	cnt = read (sock_1, read_msg, sizeof (read_msg)) ;
	if (cnt < 0)
	{
	  lint_rtn = fprintf (stderr, "read_smtp: read failure %s\n", strerror (errno)) ;
	  lint_rtn = close (sock_1) ;
	  lint_rtn = EOVERFLOW ;	/* value too large to be stored in data type */
	  _exit (EXIT_FAILURE) ;
	}

	read_msg[cnt] = '\0' ;		/* terminate message */

	lint_ptr = strncpy (toke_str, read_msg, cnt) ;

	lint_ptr = strtok (toke_str, " ") ;

	lint_ptr = strcpy (mail_status, lint_ptr) ;

	if (strcmp (lint_ptr, "220") == 0 )
	  return (EXIT_SUCCESS) ;

	if (strcmp (lint_ptr, "250") == 0 )
	  return (EXIT_SUCCESS) ;

	return (EXIT_FAILURE) ;

} /* end read_smtp */



Russ Allbery (rra@stanford.edu) wrote:
: In comp.lang.perl.misc, Jim Esten <jesten@earth.execpc.com> writes:

: > Tom Christiansen wrote one called addrcheck earlier this year...  I hung
: > onto that one... mail me direct if you can't find it...

: Tom Christiansen's addrcheck script produces both false positives and
: false negatives, as he's aware.  It's about the best that one can do in
: terms of static verification of e-mail addresses, but it *doesn't* work
: all of the time and has its own caveats and problems.

: -- 
: #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
: $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
:  00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
: rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print

--
This posting represents the personal opinions of the author. It is not the
official opinion or policy of the author's employer. Warranty expired when you
opened this article and I will not be responsible for its contents or use.


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

Date: 19 Jun 1997 10:05:19 GMT
From: Zenin <zenin@best.com>
Subject: Re: Sorting Associative Array? (Urgent)
Message-Id: <5ob08v$qkd$2@nntp2.ba.best.com>

Wesley Miaw <wesley@woais.com> wrote:
	>snip<
> Well, the sort is only one step farther.
> foreach $key (sort keys %hash) {
> 	$key_sorted_hash{$key} = %hash{$key};
> }

	Er, no.  This won't work.  It's just a really
	slow way to make a copy of %hash.  The new
	hash will be just as "unsorted" as the first.

-- 
-Zenin
 zenin@best.com


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

Date: 19 Jun 1997 16:32:07 +0200
From: md4calle@mdstud.chalmers.se (Calle ]sman)
Subject: Re: Sorting Associative Array? (Urgent)
Message-Id: <w7psoyell3s.fsf@fraggel54.mdstud.chalmers.se>

Missed the whole beginnig of this post, but this is what the perlfaq says:

Internally, hashes are stored in a way that prevents you from imposing an
order on key-value pairs. Instead, you have to sort a list of the keys or
 values: 

    @keys = sort keys %hash;    # sorted by key
    @keys = sort {
                    $hash{$a} cmp $hash{$b}
            } keys %hash;       # and by value

Here we'll do a reverse numeric sort by value, and if two keys are identical,
sort by length of key, and if that fails, by straight ASCII comparison of the
keys (well, possibly modified by your locale
-- see the perllocale manpage). 

    @keys = sort {
                $hash{$b} <=> $hash{$a}
                          ||
                length($b) <=> length($a)
                          ||
                      $a cmp $b
    } keys %hash;



If that wasn't at all what you wanted, well, nevermind...

all best,

/Calle

**************************************************************************
*         *         My homepage about the author Tom Holt:               *
*        /_\        http://www.mdstud.chalmers.se/~md4calle/holt/        *
*     { ~._.~ }                                                          *
*      (  Y  )      other things like OnLine Guitar Archive linkpage     *
*     ( )~*~( )     and heaps of musiclinks can be found at              *
*     (__)-(__)     http://www.mdstud.chalmers.se/~md4calle/             *
**************************************************************************



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

Date: Thu, 19 Jun 1997 09:48:10 -0600
From: mpeppler@mbay.net
To: tim@hcirisc.cs.binghamton.edu
Subject: Re: sybperl DBlib question
Message-Id: <866731135.5519@dejanews.com>

In article <t0oh933old.fsf@hcirisc.cs.binghamton.edu>,
  tim@hcirisc.cs.binghamton.edu wrote:
>
> I inherited some sybperl code and I have a slight problem.
> The code creates a database handle like this
> $dbh = new Sybase::DBlib $login $password $database || die "Can't Open
> database";
>
> If for some reason the server that holds that database is down then
> the script does not die with the die message but gives a DBlibrary
> error and dumps out of the script.  How can I catch the DBlibrary
> error and output my own message?  I tried removing the '|| die ...'
> and putting an unless around the statement but that didn't work.
>

You should take a look at the dbmsghandle() and dberrhandle() functions
in sybperl, and check their respective documentation in Sybase's
OpenClient/C - DBlibrary manuals. The Sybase manuals are on line at
http://sybooks.sybase.com/cgi-bin/nph-dynaweb/con11103/dblib/1.toc

Michael

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


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

Date: Thu, 19 Jun 1997 11:34:27 +0100
From: Simon Fairey <sfairey@metrica.co.uk>
To: David Cheitel <david1@earthlink.net>
Subject: Re: Traslate or other method?
Message-Id: <33A90B33.167E@metrica.co.uk>

David Cheitel wrote:
> 
> I am trying to convert a alphanumeric string to ascii equiv.
> 
> I would like to use a tr/A-Z/027-053/ but as it stands perl looks at
> that as 0 2 7 as individual substitutions.
> 
> I would like a string ie. CR000027 converted to the ascii equiv.
> 
> Thanks.

Quick but probably unecesarily long winded idea.

Try setting up an associative array of (character, ascii value) pairs
then loop over the characters in your string.
i.e.
  foreach $char ( split(//,$string) ) {
    $newstring .= $ascii{$char};
  }

There is probably a better way ( possibly using the s///e method ) but
this will get you started in the event of nothing better.

Have fun.

Simon


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

Date: Thu, 19 Jun 1997 06:43:43 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: what module to use for sysopen?
Message-Id: <f16bo5.vk.ln@localhost>

Pui Ming WONG (s11976@net2.hkbu.edu.hk) wrote:

: I simply tried out the example listed in the FAQ. Here it is:
: Use Fcntl;
  ^
  ^

use Fcntl;


: sysopen(FH,"/tmp/filename", O_WRONLY|O_EXCL|O_CREAT, 0644);

: The error that came up is:
: Undefined subroutine &main::sysopen called at line 3


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

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

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