[7723] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1349 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 20 17:07:22 1997

Date: Thu, 20 Nov 97 14:00:31 -0800
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, 20 Nov 1997     Volume: 8 Number: 1349

Today's topics:
     ! ? NEED HELP ? ! please =] <cbt@federation.addy.com>
     Re: $a='001' ; $a++ ; print$a (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     Re: $a='001' ; $a++ ; print$a (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     Re: -e switch rets@meta3.com
     ^D not working <egley@albany.net>
     Another s/// question <vfox@nbnet.nb.ca>
     Are there any viewgraphs on Perl? (Igor Chudov @ home)
     date <indu@healtheon.com>
     Re: File attachments using sendmail <eryq@zeegee.com>
     Funny variable behavior? <henry@DotRose.com>
     Re: giving up on flock <markm@nortel.ca>
     Help: What dir am I in (David J. Boyd)
     Learning Perl in win95 (Pearl Fox)
     Make Word print to a file <lgd@192.255.255.255>
     Re: NDBM .pag and .dir (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     Perl 5's glob() function jathan@nastything.com
     Re: Perl 5's glob() function (Tad McClellan)
     Re: Perl 5's glob() function <usenet-tag@qz.little-neck.ny.us>
     Perl for NT Bug ? <amias@mindless.com>
     Please help with user log (Pearl Fox)
     Re: Q: perl5 flock an AFS file/solaris 2.5.1 <markm@nortel.ca>
     Re: Ques: (Tad McClellan)
     Re: Ques: (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     Reading single lines from a file . . . <jt@cs.pdx.edu>
     Rename Ref file (Bruce Davidson)
     Re: Returning information from an nslookup ?? (Burt Lewis)
     Re: Returning information from an nslookup ?? <libeson@pdb.pdb.bnl.gov>
     Re: s/// Question <eryq@zeegee.com>
     Re: s/// Question (Tad McClellan)
     Re: s/// Question <usenet-tag@qz.little-neck.ny.us>
     Re: s/// Question (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     sockets <sakalauk@coam.usm.edu>
     Re: Split rets@meta3.com
     Win32 and Word (Steve Riddle)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 18 Nov 1997 22:50:43 -0800
From: ric <cbt@federation.addy.com>
Subject: ! ? NEED HELP ? ! please =]
Message-Id: <34728C42.4D48@federation.addy.com>

HELLO !!! 

I am looking for help on a program that I have down loaded from mike
free software! 

Chat Pro 1.1 and Voteing system made by the same person!
BOTH scripts have take all my hair out of my head And into the palm of
my hand!!
The script deals with pearl and cgi. I am do not understand pearl. I
have limted use of cgi, enough though to  put  in a few messagebaords on
my web site!
And the url of the script is for the chat room,
http://jvm.com/cbt/chatpro/chatpro.cgi
and the voteing both,
http://jvm.com/cbt/vote/vote.shtml

Anyways, I am in need of help with this script? If anyone that can help,
please mail me.
And I can give you more details. Or post my message!
Iknow this is very vage on the subject but i did not want to load an
entire script on to a news group!
But if you go to those url's you can see for your self that the scripts
are not working right!

Thanks for your time and hope to here from you soon!

Admin Ric of
Comic Outpost
http://jvm.com/cbt


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

Date: Thu, 20 Nov 97 15:14:45 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: $a='001' ; $a++ ; print$a
Message-Id: <34749a94$2$ofn$mr2ice@speaker>

In <347415BE.7936@bigfoot.com>, on 11/20/97 at 11:49 AM,
   Koos Pol <koos_pol@bigfoot.com> said:
+-----
| $a='001';
| $a++;
| print $a;
| This nicely yields '002'. I was very positively shocked about this:-) ! Is
| this correct behaviour ?
+--->8

Look for "magic autoincrement" in the Fine Manual.  It works, it's deliberate,
but it's probably not quite what you think.  (Which doesn't mean it won't do
what you want....)

-- 
brandon s. allbery           [Team OS/2][Linux][JAPH]        bsa@void.apk.net
cleveland, ohio              mr/2 ice's "rfc guru" :-)                  KF8NH
"Never piss off a bard, for they are not at all subtle and your name scans to
 `Greensleeves'."  ---unknown, quoted by Janet D. Miles in alt.callahans



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

Date: Thu, 20 Nov 97 15:58:00 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: $a='001' ; $a++ ; print$a
Message-Id: <3474a58f$3$ofn$mr2ice@speaker>

In <eli$9711201421@qz.little-neck.ny.us>, on 11/20/97 at 06:35 PM,
   Eli the Bearded <usenet-tag@qz.little-neck.ny.us> said:
+-----
| > > This nicely yields '002'. I was very positively shocked about this:-) !
| > > Is this correct behaviour ?
| > You might want to check man page perlop, section about auto-increment.
| > The ++ is magical on strings.
| :r! perl5.00401 -we '$section="4.2.07"; $section++; print "$section\n";'
| 5.2
| Not what one might expect reasonably....
+--->8

But correct and documented.  Magical autoincrement only works on strings with
specific contents; a period isn't one of the permitted characters.  As such,
Perl handles it via a string-to-number conversion, dropping anything in the
string that can't be parsed into the number (the second "." and everything
after it), then increments the resulting number.

Expanding the scope of magical autoincrement isn't a good idea, BTW:  you end
up with a conflict as to the interpretation of "$section = '4.01';
$section++;" --- should it be handled as in earlier versions of Perl, or
according to magical autoincrement rules?

-- 
brandon s. allbery           [Team OS/2][Linux][JAPH]        bsa@void.apk.net
cleveland, ohio              mr/2 ice's "rfc guru" :-)                  KF8NH
"Never piss off a bard, for they are not at all subtle and your name scans to
 `Greensleeves'."  ---unknown, quoted by Janet D. Miles in alt.callahans



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

Date: Thu, 20 Nov 1997 15:33:17 -0600
From: rets@meta3.com
Subject: Re: -e switch
Message-Id: <880061119.23314@dejanews.com>

I had trouble with this before as well.  The -e switch is fairly straight
forward.  Say I have a file (data.txt) which contains rows of pipe
delimited fields (Ken|Holm|META3, Inc)	If I want just a list of those
elements in the first 'field', I can use the perl script:

#!/usr/bin/perl5 -w

$file = "data.txt";
open(F, $file);
while (<F>) {
    chomp;
    (@List) = split(/\|/, $_);
    print $List[0], "\n" if ($List[0]);
}
close F;
exit;

I modify the script to get the following:

/usr/bin/perl5 -we '$file = "data.txt";open(F, $file);while (<F>)
{chomp;(@List) = split(/\|/, $_);print $List[0], "\n" if ($List[0])}close
F;exit'

Here are the modifications:
* Remove the #! before the /path/to/perl
* "Wrap" the script in single quotes(')
* Don't use 's in your script (use q! or the like)

Those are the basics.  I am certain there are more, complicated things
you can do with it.  After figuring it out (with much looking over
Randal's .sigs,) I find the -e switch very helpful.

-K

In article <34739DD8.812C1DFB@pipeline.com>,
  jsrk@pipeline.com wrote:
>
> I'm having the damndest time trying to figure out how to use perl
> straight from the command line. There are times when I just need a
> little loop or what have you, but I've not been able to find a clear
> example of how the -e switch is used.
>
> Anyone care to give me an example?
>
> Thanks a lot...

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


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

Date: Thu, 20 Nov 1997 09:26:52 -0500
From: "Skip Egley" <egley@albany.net>
Subject: ^D not working
Message-Id: <652a63$9mi$1@gamera.albany.net>

Let me try this again. I must not have explained myself well the first time.
I'm just learning perl, going through "Teach Yourself Perl in 21 Days".
According to the book, I can do something as simple as,

@array = <STDIN>;

and perl will keep stuffing array with lines from standard input until a ^D
(Control-D). Mine doesn't work. The ^D simply prints a weird character on
the screen. It doesn't interrupt the receiving of data from standard input.
Am I doing this right? Is there something wrong with my version of perl? I
downloaded the latest one for Win95, I believe it was 5.004_02.

Thanks,
Skip Egley




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

Date: Thu, 20 Nov 1997 16:42:58 -0400
From: "Vaughn Fox" <vfox@nbnet.nb.ca>
Subject: Another s/// question
Message-Id: <6527gg$5v8$1@usenet85.supernews.com>

hi all

I'm new with Perl and am trying to replace an empty space in a variable with
a "?" and haven't had much luck with the following:

$variable =~ s/ /?/gi;

am I on the right track, or is there another way I should go about this?

Thanks

Vaughn





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

Date: Thu, 20 Nov 1997 15:40:26 -0600
From: ichudov@algebra.com (Igor Chudov @ home)
Subject: Are there any viewgraphs on Perl?
Message-Id: <slrn679bi9.5l4.ichudov@manifold.algebra.com>

Hi,

I'd like to offer a little class on Perl to my coworkers. For better
teaching efficiency I would like to use some viewgraphs. I am curious
if there are any viewgraphs publicly available that give a decent
introduction into Perl.

Please post or email (or both) your answer. Thanks a lot!!!!

-- 
	- Igor.

----------------------------------------------------------------------------
char*p="char*p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}



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

Date: Thu, 20 Nov 1997 13:30:09 -0800
From: Indu Bingham <indu@healtheon.com>
Subject: date
Message-Id: <3474ABE1.18164626@healtheon.com>

Anyone know how I could get a script to get a date range for a week.

For example I have a week 46 and I would like to get the the begin date
of the week 46 and the end date.

>date '%W' -> will give the week

I would like to pass this week value and get the date range...

any suggestions??

Thanks

--
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Happiness is not getting what you want, but wanting what you have.

 Indu Bingham
 Healtheon Corporation
 indu@healtheon.com
*/




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

Date: Thu, 20 Nov 1997 13:57:46 -0500
From: Eryq <eryq@zeegee.com>
To: Dave <dave@docsoftware.com>
Subject: Re: File attachments using sendmail
Message-Id: <3474882A.752F@zeegee.com>

Dave wrote:
> 
> How can I attach a file to a mail message using sendmail in a perl
> script?
> 
> Here is the script I am using.
> 
> open(MAIL,"|$mailprog -t");
> print MAIL "To: $CONFIG{'eaddress'}\n";
> print MAIL "From: $CONFIG{'recipient'}\n";
> print MAIL "Subject: Confirmation\n";
> print MAIL "\n...etc\n";
> close (MAIL);
> 
> Please e-mail me directly it you have any ideas.

Use MIME::Lite (which uses sendmail internally, and will work
nicely in a Unix setting):

	# Create a new multipart message:
        $msg = new MIME::Lite 
                    From    =>'me@myhost.com',
                    To      =>'you@yourhost.com',
                    Cc      =>'some@other.com, some@more.com',
                    Subject =>'A message with 2 parts...',
                    Type    =>'multipart/mixed';

        # Add parts (each "attach" has same arguments as "new"):
        attach $msg 
                    Type     =>'TEXT',   
                    Data     =>"Here's the GIF file you wanted";  
        attach $msg 
                    Type     =>'image/gif',
                    Path     =>'aaa000123.gif',
                    Filename =>'logo.gif';

	# Send it (Unix only):
	$msg->send;

For software and more info:

	http://www.enteract.com/~eryq/CPAN/MIME-Lite/

Hope that helps,
-- 
   ___  _ _ _   _  ___ _   Eryq (eryq@zeegee.com)
  / _ \| '_| | | |/ _ ' /  President, Zero G Inc.
 |  __/| | | |_| | |_| |   
  \___||_|  \__, |\__, |___/\  Visit STREETWISE, Chicago's newspaper by/
            |___/    |______/ of the homeless: http://www.streetwise.org


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

Date: Thu, 20 Nov 1997 14:01:49 -0500
From: Henry Hartley <henry@DotRose.com>
Subject: Funny variable behavior?
Message-Id: <3474891D.775F7A76@DotRose.com>

I have a Perl script which asks the user for a proposal number and
associated password.  It then compares these two entries with a database
and if they match a record the user goes to the next page, if not the
form is redisplayed with an error message so they can try again.  It
works, almost.

Most combinations of proposal number and password generate the proper
response (either acceptance or generated error message) but I happened
to setup a proposal number in the database of w97 with a password of 1.
When I enter this in the form, I get an error message that says, "w97 is
not defined".  If I enter W97 or some other text that does not match the
database contents I simply get the appropriate error message from my
code.

The code that displays the form is as follows:
  <form name=proposal method="POST"
action="/WesPressCGI/ProjectPassword.pl">
  <table cellpadding=0 cellspacing=0 border=0>
  <tr><td>Enter the Proposal Number:
      <td><input type="text"     name="propnumber" size=12
VALUE='$propid'>
      <td><img src="/Images/1x1.gif" hspace=15></IMG></td>
      <td rowspan=2><font color="#FF0000">$message</font></td></tr>
  <tr><td>Enter the Proposal Password:
      <td><input type="password" name="password"   size=12
VALUE=$proppw></tr>
  <tr><td>
      <td align=center><input TYPE="submit" value="  Go   ">
          <input name=reset TYPE="submit" value="Reset">
      <td><img src="/Images/1x1.gif" hspace=15></IMG></td>
      <td><input name=getout TYPE="submit" value="   Exit   "></tr>
  </table>
  </form>


The code that reads in the information from the form is as follows:
  $input = new CGI;  # Get a CGI object #######CGI::ReadParse;
                     # put to a scalar variable (called input)

  $propid  = $input->param('propnumber');
  $proppw  = $input->param('password');

The error message mentioned above points to the line above that says "#
put to a scalar variable (called input)".  Now I realize that "1" is not
much of a password and "w97" is not actually an example of a proposal
number but I'd like to understand what's going on.

In the database, both fields are type "text" and I didn't have this
problem earlier when I used as a proposal number 12345 with password
wes5.

Any ideas?

Henry Hartley
Westat





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

Date: 20 Nov 1997 14:39:29 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: giving up on flock
Message-Id: <lq1afez73ta.fsf@bmers2e5.nortel.ca>

tadmc@flash.net (Tad McClellan) writes:
> Mark Mielke (markm@nortel.ca) wrote:
> : flock() should work on just about anything that calls itself unix. Perl
> [snip]
> : unlock the file... all done. here's some pseudo-type code..
> 
> :    sub append_to_file
> :    {
> :       if (open_the_file_for_writing) {
> :          if (request_exclusive_lock_on_the_open_file) {
> :             seek_to_the_end_of_the_file; <-- NECESSARY!!!!!!!!!!!!!!!
> :             print_your_stuff_to_the_filehandle;
> :             release_the_lock_on_the_open_file; <-- OPTIONAL
> Never use this option  ;-)

I forgot one part... :-) Just after the seek or before...
    f->autoflush(1);

The case where it would be optional is if you were going to use it again
later... like multiple entries in the logfile. it's up to the implementation.

> You could lose your time slice right here, while you still have stuff
> in the file buffers, and have not yet closed the file. ie. you are
> not finished writing the file, yet you no longer have a lock!

Very true. Must flush()/sync() the file :-)

> Don't unlock. Just close the file, it will unlock it for you.

That is what i would do... but in certain cases you may wish to keep it
open... and if so... do the autoflush(1).

cya,
mark

P.S. Thanks Tom.

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: Thu, 20 Nov 1997 19:59:05 GMT
From: djboyd@nospam.sam.on-net.net (David J. Boyd)
Subject: Help: What dir am I in
Message-Id: <34749627.6627953@news.on-net.net>

How does one go about determine what directory I am from perl?  Where the
directory script is?

 ...
TIA


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

Date: Thu, 20 Nov 1997 18:26:42 GMT
From: fox@securenet.net (Pearl Fox)
Subject: Learning Perl in win95
Message-Id: <651jq3$m29$2@news.securenet.net>

 If there is a site where I can get the information that I need to get
me  started in learning how to program in Perl with win 95
environment, I  would really appreciate it.  I downloaded the Perl
program but don't know how to use it with win 95?

Thanks
Pearl

Pearl S. Fox,
Montreal (Que.)
http://www.securenet.net/members/fox/index.html



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

Date: 20 Nov 1997 21:46:49 +0000 (GMT)
From: Luke Diamand <lgd@192.255.255.255>
Subject: Make Word print to a file
Message-Id: <zCw*YVshn@news.atml.co.uk>


Maybe no-one else will ever care, but after many hours of fruitless searching
of the web, I have finally figured out how to persuade Microsoft Word v7 to
print to a file from perl using OLE.

For reasons that are not altogether clear to me, you can't just call the
word basic FilePrint method as advertised in the word basic help, cos the
parameters are all wrong. Instead the parameters are as shown below:

    my $word = CreateObject OLE 'Word.Basic';
    $word->FileOpen( 'foobar.doc' );

    $word->FilePrint( 0,         # background
                     "1",        # ?
                     "1",        # ?
                     0,          # append to print file
                     0,          # range
                     $PrToFileName, 
                     "",         # from
                     "",         # to
                     0,          # type
                     1,          # number of copies 
                     "2",        # pages
                     0,          # order
                     $PrintToFile+0,   # print to file
                     0,          # collate 
                     "");        # ?

(where PrToFileName is 0 or 1 according to whether you want to print to a file
or not, and PrintToFile is the name of the file to print to)

THEN IT ALL WORKS! HURRAH! I CAN GO HOME AT LAST!

Luke Diamand
-- 
Advanced Telecommunications Modules Ltd
Cambridge
+44 1223 577230


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

Date: Thu, 20 Nov 97 16:04:43 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: NDBM .pag and .dir
Message-Id: <3474a6af$4$ofn$mr2ice@speaker>

In <6507n2$ftq$1@fu-berlin.de>, on 11/20/97 at 02:36 AM,
   hartwig@inf.fu-berlin.de (Thomas Hartwig) said:
+-----
| How in the hell do I get rid of the '.dir' and '.pag' extensions if I'm
| using the NDBM_File module:
> ( . . . )
| After some hours of confusing the enlightment was that these files are hard
| linked. But why and who done this ;-)
+--->8

On Linux, ndbm is emulated by gdbm --- but gdbm doesn't actually create ndbm
files; you get one gdbm file with hard-linked ndbm compatibility names.  If it
really bothers you, consider using GDBM_File or DB_File instead (assuming your
Perl supports it, which it should).

-- 
brandon s. allbery           [Team OS/2][Linux][JAPH]        bsa@void.apk.net
cleveland, ohio              mr/2 ice's "rfc guru" :-)                  KF8NH
"Never piss off a bard, for they are not at all subtle and your name scans to
 `Greensleeves'."  ---unknown, quoted by Janet D. Miles in alt.callahans



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

Date: Thu, 20 Nov 1997 13:32:37 -0600
From: jathan@nastything.com
Subject: Perl 5's glob() function
Message-Id: <880053618.14457@dejanews.com>

Ladies and Gentlemen of the Perl world,

I have just finished writing a script on a test machine making use of Perl
5's functionality and specifically, the GLOB function.

However, our production machine does not have Perl 5, but Perl 4 and
therefore the code dependent upon the output of GLOB will not work.
Basically, the script itself will not work.

Is there an equivalent function to GLOB for Perl 4?  Or perhaps some code
I could use to match this:

>
>@WorkingFiles = glob("$WorkingDir/$FileExt");
>
>open(LOG, '>>$LogFile');
>foreach $FileName (@WorkingFiles)

>

I'm working with files and filenames so the output of my script is
dependent upon the data GLOB returns. :*(

PLEASE ASSIST!!

JaTHaN (aka John Jacob Jingleheimer Shmidt)
<o_/

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


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

Date: Thu, 20 Nov 1997 14:29:41 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Perl 5's glob() function
Message-Id: <lj6256.qa2.ln@localhost>

[ I don't see any Unix stuff in here. Followups trimmed ]


jathan@nastything.com wrote:

: I have just finished writing a script on a test machine making use of Perl
: 5's functionality and specifically, the GLOB function.

: However, our production machine does not have Perl 5, but Perl 4 and
               ^^^^^^^^^^^^^^^^^^

That must be those spiffy DX2-66s that were top-of-the-line when 
Perl 4 was used  ( just to give a little context  ;-)

There are security risks with versions of Perl before 5.004.

Upgrade or be cracked...

(besides that, nobody cares about two year old versions of software,
 it's gonna be hard to get answers to questions, unless there is a
 historian lurking nearby
)


: Basically, the script itself will not work.

That happens a lot with Perl 4 scripts. 

That's why they developed Perl 5  ;-)


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: 20 Nov 1997 20:45:30 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Perl 5's glob() function
Message-Id: <eli$9711201631@qz.little-neck.ny.us>

In article <880053618.14457@dejanews.com>,  <jathan@nastything.com> wrote:
> However, our production machine does not have Perl 5, but Perl 4 and
> therefore the code dependent upon the output of GLOB will not work.

Two things:

Do your production work on an identically configured machine.

Upgrade all of your perls to at least 5.004.


> Is there an equivalent function to GLOB for Perl 4?  Or perhaps some code
> I could use to match this:

There is always readdir.

Elijah
------
doesn't find glob too useful


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

Date: Thu, 20 Nov 1997 19:42:17 +0000
From: Amias <amias@mindless.com>
Subject: Perl for NT Bug ?
Message-Id: <34749299.7E51B612@mindless.com>

Hello Perl people

I am having a problem with PERL on NT .
When i run my perl program through my webserver it ignores my while loop
but if run from the command line its fine , the source is as follows .
open FILE,"$fil";
 while (!eof(FILE))
     {
        $data=<FILE>;
        # stuff with $data
    }
Its not an user rights thing as i've run it from the command line as the
IUSR for my machine (the webserver). It seems to just skip the while
loop . This approach works with the PERL program i pasted it from on the
same machine just to annoy me . is this a bug ?

Toodle-pip
Amias

http://www.homeusers.prestel.co.uk/amias
ICQ 3099152
Anyone spamming me _will_ have problems with their server




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

Date: Thu, 20 Nov 1997 18:23:20 GMT
From: fox@securenet.net (Pearl Fox)
Subject: Please help with user log
Message-Id: <651jjq$m29$1@news.securenet.net>

I have this user log file on my webpage to log the users.  However I
would like to exclude my own entry when visiting my page.  How would I
do this?  I'm not including the whole log file to save space.
I imagine that I would insert the extra piece of code just before the
line 
beginning "if(/<!--begin-->/) {
" and put in:
if $ENV{'REMOTE_HOST'}eq "fox@securenet.net" close(FILE);
and then put in an elsif(/<!--begin-->/) 
{
print FILE "<!--begin-->\n"    
print FILE "<tt>When:</tt> $date<br>\n";     
print FILE "Who: $ENV{'REMOTE_HOST'}<br>\n"     
print FILE "Browser: $ENV{'HTTP_USER_AGENT'}<br></tt>\n"	
print FILE "<hr width=75%>";
	print FILE "\n";


else {
print FILE $_;

print FILE "</BODY>\n</HTML>\n";
close(FILE);

Am I on the right track?
Thanks Pearl


{
	

Pearl S. Fox,
Montreal (Que.)
http://www.securenet.net/members/fox/index.html



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

Date: 20 Nov 1997 14:33:11 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: Q: perl5 flock an AFS file/solaris 2.5.1
Message-Id: <lq1btzf743s.fsf@bmers2e5.nortel.ca>

jzawodn@wcnet.org (Jeremy D. Zawodny) writes:
> [original author automagically cc'd via e-mail]
> On 20 Nov 1997 12:14:31 GMT, fmailer@smail.Uni-Koeln.DE (Felix Mailer)
> wrote:
> >on solaris 2.5.1:
> >- flock'ing an AFS file within a perl5 script has no effect. <===
> >- flock'ing a local file within the perl5 script works.
> >- flock'ing an AFS file whithin a C program works.
> >on aix/hp-ux ...
> >- flock'ing an AFS file within a perl5 script works.
> >(the perl5 call is: flock(<file handle>,2);)
> What, *exactly* are you asking?

He's asking if this is a perl bug or what? And if it is... (from the
information given i would assume it is) He would report it with perlbug
or something :-)

mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: Thu, 20 Nov 1997 13:46:26 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Ques:
Message-Id: <i24256.j62.ln@localhost>

Jeremy D. Zawodny (jzawodn@wcnet.org) wrote:
: [original author automagically cc'd via e-mail]

: On Thu, 20 Nov 1997 12:23:15 -0500, yu ju <yju2@cs.umbc.edu> wrote:

: >Hello,
: >Can anyone tell me what does the following code mean? 
: >
: >%states = ($startNode => ["user"],
: >           "kernel" => ["kernel"],
: >           "idle" => ["idle"],
: >           "sync" => ["sync"]
: >           );
: >
: >
: >I can find the description of "=>" and "[ ]".

: Pick yourself up a copy of Learning Perl or read the on-line manual
: pages.

: Rather than give you a fish, I figure it's better to learn to fish for
: yourself. :-)


Pssst! I know a good fishing spot.

   grep -c '=>' perldata.pod            # 11 fish in this pond

   grep -c 'anonymous array' perlref.pod # only 4 lunkers in this spot

;-)


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Thu, 20 Nov 97 16:10:53 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: Ques:
Message-Id: <3474a819$5$ofn$mr2ice@speaker>

In <Pine.SGI.3.91.971120122116.1146A-100000@spike.cs.umbc.edu>, on 11/20/97 at
12:23 PM,
   yu ju <yju2@cs.umbc.edu> said:
+-----
| Can anyone tell me what does the following code mean? 
| I can find the description of "=>" and "[ ]".
+--->8

>From which I deduce that you're looking at Perl 4 documentation.  Upgrade to
Perl 5 and all will be explained.

(Short form:  "=>" is like ",", except that its LHS is implicitly quoted if
it's a bareword.  [ ] returns a reference to an anonymous array; references
are a cleaner alternative to the symbol-table munging some of us used to be
(in)famous for under Perl4.  Get the Perl5 documentation, read perlref.pod.)

-- 
brandon s. allbery           [Team OS/2][Linux][JAPH]        bsa@void.apk.net
cleveland, ohio              mr/2 ice's "rfc guru" :-)                  KF8NH
"Never piss off a bard, for they are not at all subtle and your name scans to
 `Greensleeves'."  ---unknown, quoted by Janet D. Miles in alt.callahans



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

Date: Thu, 20 Nov 1997 11:23:25 -0800
From: Jon Turner <jt@cs.pdx.edu>
Subject: Reading single lines from a file . . .
Message-Id: <34748E2D.86138774@cs.pdx.edu>

I thought I understood perl enough to do this without trouble, but once
again I am humbled.

I am trying to process a number of newsgroup messages that have been
saved as files.  For each message I want to get various info from the
header fields and write them to a file for import into a database. So, I
have a procedure that opens each file in turn, and _should_ grab a line
at a time from the file and do some processing (see code below). But,
I have found that it doesn't always read just 1 line at a time.  When I
step through it with the debugger I often get 5-6 lines in my variable
$line. There are clearly '\n's at the end of the lines, and when I run
it through a Korn shell script it easily seperates each line. So, why
isn't perl seperating the lines?  I really hate the idea of running the
output of a ksh script to feed a perl script, when it seems that it
would be so much easier to do it all in perl. btw, I am using Perl5.

Any help would be appreciated,
Jon Turner -- jt@cs.pdx.edu



foreach $filenm (@FILE_LIST) {
  open(FILE, $filenm) or die "Unable to open $filenm: $!/n";

  while ($line = <FILE>) {
      SWITCH: {
	. . . pattern matching on From:, Subject, etc . . .
	. . . and write results to seperate file . . . 
      }
  }
}


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

Date: Thu, 20 Nov 1997 21:08:30 GMT
From: b.davidson@webforums.net (Bruce Davidson)
Subject: Rename Ref file
Message-Id: <880060267.13418.0.nnrp-07.9e982204@news.demon.co.uk>

I have two scripts which want to use the contents of a reference file.
When I exit the first script I want to rename the file so that the
second script can read its contents, but it will disable the first
script from access to the ref file again.

Would apprecite an example of
sub rename_file {
rename file-a file-b
}

thanks
Bruce Davidson
b.davidson@webforums.net



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

Date: 20 Nov 1997 18:52:43 GMT
From: burt@ici.net (Burt Lewis)
Subject: Re: Returning information from an nslookup ??
Message-Id: <6520tr$7pc$1@bashir.ici.net>

Thanks, I tried that and I get this:

Server: [207.180.0.20] Address: 207.180.0.20 Name: [207.180.0.20] Address: 
207.180.0.20 

>print "Content-type: text/html\n\n";


>$return = `nslookup 207.180.0.20`;
>print "$return";

I'm getting closer but it's not returning the Domain Name.

Burt

In article <347369D5.4BB3DD3E@pdb.pdb.bnl.gov>, libeson@pdb.pdb.bnl.gov 
says...
>
><HTML>
>Burt Lewis wrote:
><BLOCKQUOTE TYPE=CITE>Hi,
>
><P>I'm capturing IP's using "$ENV{'REMOTE_HOST'} from an SSI page.
>
><P>I want to then do an nslookup to capture the domain as a variable that
>I can read back to the
><BR>webpage and write to file.
>
><P>I have this but I don't know how to return the answer.
>
><P>print "Content-type: text/html\n\n";
>
><P>system "nslookup 207.180.0.20";
>
><P>Appreciate any help on this.
>
><P>Burt Lewis</BLOCKQUOTE>
>&nbsp;Try the following instead of system:
>
><P>$return = `nslookup 207.180.0.20`;
>
><P>then filter the output saved in $return.
><BR>&nbsp;
><PRE>--&nbsp;
>libeson</PRE>
>&nbsp;</HTML>
>



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

Date: Thu, 20 Nov 1997 15:11:40 -0500
From: libeson <libeson@pdb.pdb.bnl.gov>
To: Burt Lewis <burt@ici.net>
Subject: Re: Returning information from an nslookup ??
Message-Id: <3474997C.BC3CA82B@pdb.pdb.bnl.gov>

Burt Lewis wrote:
> 
> Thanks, I tried that and I get this:
> 
> Server: [207.180.0.20] Address: 207.180.0.20 Name: [207.180.0.20] Address:
> 207.180.0.20

Do you have a name server ? If you do not this will not work for
you. nslookup will take as a second arguement the address of a
nameserver. Try adding a second argument with a name server address
and see what happens.


-- 
libeson


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

Date: Thu, 20 Nov 1997 14:06:47 -0500
From: Eryq <eryq@zeegee.com>
To: Paul Plowman <paulp@jumper.mcc.ac.uk>
Subject: Re: s/// Question
Message-Id: <34748A47.3AEB@zeegee.com>

Paul Plowman wrote:

> Is there any way of using the result of a match in the match itself? For
> instance, if you want to search for a capital letter, followed by a
> number, followed by the same letter. Could you do something like:
> 
> $test =~ s/([A-Z])[0-9]$1/whatever/g;
> 
> If not, how would you do this?

Ooooo... *So* close!  :-)
Try this...

	$test =~ s/([A-Z])[0-9]\1/whatever/g;

See the perlre manpage for details.

-- 
   ___  _ _ _   _  ___ _   Eryq (eryq@zeegee.com)
  / _ \| '_| | | |/ _ ' /  President, Zero G Inc.
 |  __/| | | |_| | |_| |   
  \___||_|  \__, |\__, |___/\  Visit STREETWISE, Chicago's newspaper by/
            |___/    |______/ of the homeless: http://www.streetwise.org


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

Date: Thu, 20 Nov 1997 13:35:29 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: s/// Question
Message-Id: <1e3256.r32.ln@localhost>

Paul Plowman (paulp@jumper.mcc.ac.uk) wrote:
: I know that when you do a substitution using s/// you can use a matched 
: pattern in the substitution by using $1, $2 etc. For Example:

: $test =~ s/My (.*) is small/My $1 is big/g;

: Is there any way of using the result of a match in the match itself? For 
: instance, if you want to search for a capital letter, followed by a 
: number, followed by the same letter. Could you do something like:

: $test =~ s/([A-Z])[0-9]$1/whatever/g;

: If not, how would you do this?


   $test =~ s/([A-Z])[0-9]\1/whatever/g;
                          ^
                          ^ 

Just like it says in the 'perlre' man page (search for 'backreference')


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: 20 Nov 1997 20:41:02 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: s/// Question
Message-Id: <eli$9711201629@qz.little-neck.ny.us>

Posted and mailed.

Paul Plowman  <paulp@jumper.mcc.ac.uk> wrote:
> $test =~ s/([A-Z])[0-9]$1/whatever/g;
> If not, how would you do this?

$test =~ s/([A-Z])[0-9]\1/whatever/g;

Elijah
------
read perlre for more details


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

Date: Thu, 20 Nov 97 16:18:14 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: s/// Question
Message-Id: <3474a949$7$ofn$mr2ice@speaker>

In <3474E9D8.35F5@jumper.mcc.ac.uk>, on 11/20/97 at 05:54 PM,
   Paul Plowman <paulp@jumper.mcc.ac.uk> said:
+-----
| followed by the same letter. Could you do something like:
| $test =~ s/([A-Z])[0-9]$1/whatever/g;
+--->8

    $test =~ s/([A-Z])[0-9]\1/whatever/g;

-- 
brandon s. allbery           [Team OS/2][Linux][JAPH]        bsa@void.apk.net
cleveland, ohio              mr/2 ice's "rfc guru" :-)                  KF8NH
"Never piss off a bard, for they are not at all subtle and your name scans to
 `Greensleeves'."  ---unknown, quoted by Janet D. Miles in alt.callahans



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

Date: Thu, 20 Nov 1997 13:08:09 -0600
From: Peter Sakalaukus <sakalauk@coam.usm.edu>
Subject: sockets
Message-Id: <34748A99.7DE14518@coam.usm.edu>

In using the socket examples in the O'Reilly book "Advanced Perl
Programming", (pages 192-193), I am able to launch the server with
no problem. When I launch the client though, I get:

Socket could not be created. Reason: Bad file number

The client code is simple enough:

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

use IO::Socket;

$sock = new IO::Socket::INET (PeerHost => 'some.machine.com',
                              PeerPort => 8080,
                              Proto    => 'tcp');

die "Socket could not be created. Reason: $!\n" unless $sock;

foreach(1 .. 10)
  {
  print $sock "Msg $_: How are you?\n";
  }

close($sock);

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


The sample server is:

use IO::Socket;

$sock = new IO::Socket::INET (LocalHost => 'some.machine.com',
                              LocalPort => 8080,
                              Proto     => 'tcp',
                              Listen    => 5,
                              Reuse     => 1);

die "Socket could not be created. Reason: $!" unless $sock;

while($new_sock = $sock->accept())
  {
  while(defined ($buf = <$new_sock>))
    {
    print $buf;
    }
  }

close($sock);

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

Any insight would be GREATLY recieved.

Thanks ...Pete

sakalauk@coam.usm.edu


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

Date: Thu, 20 Nov 1997 15:02:10 -0600
From: rets@meta3.com
Subject: Re: Split
Message-Id: <880059462.21308@dejanews.com>

#!/usr/bin/perl5 -w

# Schplitz
# Copyright(C) 1997 Kenneth A. Holm III
# All rights reserved
#
# See Licensing Info at http://www.metamall.com/rets/license.html
# If you find this script useful please send lots of money to
# Ken Holm
# POB 97536
# Jackson, MS 39288-7536
# rets@meta3.com

	# Lets declare our variables
my ($user_name, $user_email, $userdomain);

	# Lets define the string with which we're working
my $a = 'Craig Davis|cdavis\@cnp.net';

	# Split $a using / or @
($user_name, $user_email, $userdomain) = split(/\||\@/, $a);

	# Print for posterity.
print "[$user_name][$user_email][$userdomain]\n\n";

	# You are ever in one's debt.
exit;


In article <64tucq$hoj$2@uni00nw.unity.ncsu.edu>,
  "cadavis" <cadavis@spam.eos.ncsu.edu> wrote:
>
>  I have
>
> Craig Davis|cdavis@cnp.net
>
> and need to get
>
> $user_name = "Craig Davis"
> $user_email = "cdavis"
> $userdomain = "cnp.net"
>
> if you guys can help I'll be forever in your debt.
>
> thanks in advance.
> Craig Davis
> Computer Network Power

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


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

Date: Thu, 20 Nov 1997 19:17:31 GMT
From: Steve.Riddle@NetSpace.Bentley.com (Steve Riddle)
Subject: Win32 and Word
Message-Id: <34758c7b.12054062@unix.integrityol.com>

I have been trying to write a beginner script for doing some minor
manipulations to a Microsoft Word document using Perl under WindowsNT.
I have reviewed the examples delivered that work with Excel and have
researched many of the links at the Perl home page. The enclosed
script opens an instance of Word and displays the application, but I
have not seen any other activity. Any kick-starts will be much
appreciated.


    use OLE;

    $WordApp = CreateObject OLE 'Word.Application' || die $!;
    $WordApp->{'Visible'}=1; 
# Everything works up to this point - a word instance is created and 
# displayed

# None of these statements appear to do anything
    $WordApp->FileOpen('testfile.doc');
    $WordApp->AppMaximize(); 
    $WordApp->Insert('This is a test'); 

# The Quit statement works by closing the application but has been
# commented to view the results

    #$WordApp->Quit(); 


Steve Riddle
sriddle@HiWAAY.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 1349
**************************************

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