[6386] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 11 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 25 13:39:52 1997

Date: Tue, 25 Feb 97 10:00:18 -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           Tue, 25 Feb 1997     Volume: 8 Number: 11

Today's topics:
     bash to  perl script <buxx@buxx.com>
     Calling subroutines <ltorres@campus.ruv.itesm.mx>
     Re: File access time (Tad McClellan)
     Gross error in regular expression (...)? clause (Mark-Jason Dominus)
     Help with inplace editing (Milan Saini)
     Re: Help with Perl and Window95 <hanklem@ibm.net>
     Re: How to spam - legitimately (Mark-Jason Dominus)
     Re: how to write a Perl shell? <jander@ml.com>
     html parser <ioisgp@std.cpc.ku.ac.th>
     macperl help (2nd post) (JALOTTA)
     Re: make for windows NT ? (Nathan V. Patwardhan)
     Re: Need PERL script for web site to track activity <kato13@blinktech.com>
     Re: newbie problem with pipes <jander@ml.com>
     Re: Opening a file to an exact location HELP?! <hub@club-internet.fr>
     Re: Perl and win95 (Nathan V. Patwardhan)
     Re: Perl and win95 (Terence Jordan)
     Re: printing date of a file to html page (Matthew D. Healy)
     Re: Q: How to delete several files in one operation (ne <jander@ml.com>
     Reading formatted (13.6E) data <anders@ix.netcom.com>
     replaceing stuff (Vetle Roeim)
     Re: replaceing stuff (Terence Jordan)
     Re: replaceing stuff (Vetle Roeim)
     Re: running prog from within perl script <jander@ml.com>
     Strange question <janezz@balki.fer.uni-lj.si>
     Re: Using Perl with painful or carefree style? <tom@geronimo.uit.no>
     Writing a subroutine (Angel Leyva)
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: Tue, 25 Feb 1997 11:24:12 -0600
From: Steve Vandiver <buxx@buxx.com>
Subject: bash to  perl script
Message-Id: <3313203C.552D@buxx.com>

What is the perl equiv of this bash statment?  
I keep getting compile errors no matter which 
way I write it.

Need to detect if file exists then ... else ...  


if [ -f /var/run/ppp0.pid ] ; then
 {
  ...
 }
else
 {
  ...
 }
fi

Thx 
mailto://buxx@buxx.com


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

Date: Tue, 25 Feb 1997 10:40:02 -0600
From: Luis Torres <ltorres@campus.ruv.itesm.mx>
Subject: Calling subroutines
Message-Id: <331315E2.34A2@campus.ruv.itesm.mx>

Hello, I have a script that uses a module (calling it with use) and has
one subroutine inside it (the usual readparse sub)... how come when I
call the sub I get an error saying:

Undefined subroutine &main::parse_form_data called at multiplearchivo.pl

Do I have to include my sub in another file or what??

L.T.


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

Date: Tue, 25 Feb 1997 09:14:16 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: File access time
Message-Id: <8kvue5.si1.ln@localhost>

Jon Hamlin (jhamlin@ai.uga.edu) wrote:
: How can I get a file's access time (not modification time) in Perl?
                         ^^^^^^^^^^^
: utime allows it to be changed, but I need to read it, not write it.


I guess your implementation of grep must be broken.

On my system:

grep 'access time' *.pod

finds it...


'.pod' (Plain Old Documentation) is the free documentation that is 
included with the perl distribution.

We are not here to read the manual for you...


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


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

Date: 25 Feb 1997 15:55:48 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Gross error in regular expression (...)? clause
Message-Id: <5ev224$g8l@picasso.op.net>
Keywords: gang gelable hued vitriolic



I don't know whether the gross error is in Per's regular expressions,
or in me.  I suspect it's in me.  Maybe someone here can fix it.

This test program demonstrates my problem.  I have a regular
expression, which is supposed to match strings such as `United States
of America'.  I expected every string in @usalist would match the
pattern.  But two of them, including `United States', fail to match:

-------------------------------- SAMPLE PROGRAM
$RX_US = "U(\.|nited)?\s*S(\.|tates)?(\s*(of\s*)?A(\.|merica)?)?";

@usalist = ('USA', 'U.S.A.', 'US', 'USA', 'United States',
	    'United States of America', 'US of A', 'U.S. of A.', 'US of A.');
foreach $usa (@usalist) {
  if ($usa !~ /$RX_US/oi) {
    warn "WARNING: `$usa' did NOT match \$RX_US.\n";
  }
}
-------------------------------- END OF SAMPLE PROGRAM


-------------------------------- SAMPLE OUTPUT
WARNING: `United States' did NOT match $RX_US.
WARNING: `United States of America' did NOT match $RX_US.
-------------------------------- END OF  SAMPLE OUTPUT


Why didn't those two strings match?

My Perl is 5.003_22 + suid security patch.

-- 

mjd@pobox.com                                             Mark-Jason Dominus
mjd@plover.com                              Plover Systems, Philadelphia, PA



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

Date: 24 Feb 1997 23:59:23 GMT
From: milan@xilinx.com (Milan Saini)
Subject: Help with inplace editing
Message-Id: <5eta0r$dn5@mailman.xilinx>


Hi 

The following code does not work for me. The program seems to hang


 ..... code { 


# open(FH3," /home/milan/public/bugdata/plot/$psfile") or die "Cannot open
$psfile $!\n";
#     $^I = '.bak';
#  #select(FH3);
#     while (<>)
#     {
#         s/EndComments/End Comments 2/g;
#     }
#     continue {print;}
# close(FH3);

	  }



Basically I want to add a line to an existing file (inline).


Help would be appreciated

milan
-- 
  / 7\'7 Milan Saini (milan@xilinx.com)
  \ \ `  Xilinx                              Telephone: 408-559-7778
  / /    2100 Logic Drive                    Direct:    408-879-5300
  \_\/.\ San Jose, California 95124-3450     FAX:       408-879-4676


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

Date: Tue, 25 Feb 1997 01:39:52 -0700
From: Hank LeMieux <hanklem@ibm.net>
To: puzzled@cris.com
Subject: Re: Help with Perl and Window95
Message-Id: <3312A558.6B36@ibm.net>

Peter,

You can set up a local web server on your PC and have it serve HTML
pages that call the CGI script.  This way you can emulate on your local
PC how it will work on your web site.  That's what I do anyway, using
Netscape Fastrack 2.0.  There are only a few cases where this does not
work in Win95 (like when the script calls a mail utility such as BLAT,
because Win95 apparently can't open the additional socket necessary for
BLAT to send the mail.)

If you use Dejanews to search for keywords like "local, web server,
script, cgi, windows, etc.", you'll find that this topic has been
addressed several times in the newsgroups recently.

Peter Holtan wrote:
> I work on a perl script I write it in a text editor, FTP it to my
> site, use Netscape to check it out, debug it, FTP it again, and repeat
> the process over and over; meanwhile my phone is busy for hours.
> 
> Is there a way I can view my websites in Netscape using Windows95 and
> make Windows
> execute a cgi script (if present) and return the results to Netscape?
> Just like being on-line but without tying up the phone.


-- 

Hank LeMieux
Freelance Web Design/JavaScript/CGI
Santa Fe, NM, USA
(505) 986-8166
http://members.aol.com/HankWeb/



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

Date: 25 Feb 1997 16:10:44 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: How to spam - legitimately
Message-Id: <5ev2u4$hii@picasso.op.net>
Keywords: Assyriology ascendant committeewoman death


In article <330CB74B.43@ixlabs.com>,
Chris Schoenfeld  <chris@ixlabs.com> wrote:
>What is the most efficient way of sending these out without calling
>sendmail 18,000 times? 

The most efficient way to send 18,000 mails without calling sendmail
at all is to replace sendmail with Dan Bernstein's `qmail' mailer.
18,000 messages will bring sendmail to its knees.  qmail will chug
along just fine and deliver them quickly.

qmail is free, easy to install, easy to configure, extensively tested,
and has no security problems.  (A large cash reward is about to be
offered to the first person who demonstrates a serious security problem.)

See http://www.pobox.com/~djb/qmail.html for full details.


Here's qmail's blurb:
----------------------------------------------------------------
What is it?

qmail is a secure, reliable, efficient, simple message transfer agent. It is
meant as a replacement for the entire sendmail-binmail system on typical
Internet-connected UNIX hosts.

Secure: Security isn't just a goal, but an absolute requirement. Mail
delivery is critical for users; it cannot be turned off, so it must be
completely secure. (This is why I started writing qmail: I was sick of the
security holes in sendmail and other MTAs.)

Reliable: qmail's straight-paper-path philosophy guarantees that a message,
once accepted into the system, will never be lost. qmail also supports
maildir, a new, super-reliable user mailbox format. Maildirs, unlike mbox
files and mh folders, won't be corrupted if the system crashes during
delivery. Even better, not only can a user safely read his mail over NFS,
but any number of NFS clients can deliver mail to him at the same time.

Efficient: On a Pentium under BSD/OS, qmail can easily sustain 200000 local
messages per day---that's separate messages injected and delivered to
mailboxes in a real test! Although remote deliveries are inherently limited
by the slowness of DNS and SMTP, qmail overlaps 20 simultaneous deliveries
by default, so it zooms quickly through mailing lists. (This is why I
finished qmail: I had to get a big mailing list set up.)

Simple: qmail is vastly smaller than any other Internet MTA. Some reasons
why: (1) Other MTAs have separate forwarding, aliasing, and mailing list
mechanisms. qmail has one simple forwarding mechanism that lets users handle
their own mailing lists. (2) Other MTAs offer a spectrum of delivery modes,
from fast+unsafe to slow+queued. qmail-send is instantly triggered by new
items in the queue, so the qmail system has just one delivery mode:
fast+queued. (3) Other MTAs include, in effect, a specialized version of
inetd that watches the load average. qmail's design inherently limits the
machine load, so qmail-smtpd can safely run from your system's inetd.

Replacement for sendmail: qmail supports host and user masquerading, full
host hiding, virtual domains, null clients, list-owner rewriting, relay
control, double-bounce recording, arbitrary RFC 822 address lists,
cross-host mailing list loop detection, per-recipient checkpointing, downed
host backoffs, independent message retry schedules, etc. In short, it's up
to speed on modern MTA features. qmail also includes a drop-in ``sendmail''
wrapper so that it will be used transparently by your current UAs.

Why you'll love mailing lists under qmail

Mailing list management is one of qmail's strengths. Notable features:

   * qmail lets each user handle his own mailing lists. The delivery
     instructions for user-whatever go into ~user/.qmail-whatever.
   * qmail makes it really easy to set up mailing list owners. If the user
     touches ~user/.qmail-whatever-owner, all bounces will come back to him.
   * qmail supports VERPs, which permit completely reliable automated bounce
     handling for mailing lists of any size.
   * SPEED---qmail blasts through mailing lists an order of magnitude faster
     than sendmail. For example, one message was successfully delivered to
     150 hosts around the world in just 70 seconds, with qmail's
     out-of-the-box configuration.
   * qmail automatically prevents mailing list loops, even across hosts.
   * qlist, included in the qmail package, deals with subscription requests
     safely and automatically.
   * qmail allows inconceivably gigantic mailing lists. No random limits.
   * qmail handles aliasing and forwarding with the same simple mechanism.
     For example, Postmaster is controlled by ~alias/.qmail-postmaster. This
     means that cross-host loop detection also applies to aliases.

Efficiency

qmail's modular, lightweight design and sensible queue management make it
the fastest available message transfer agent. Here's how it stacks up
against the competition in five different speed measurements.

   * Scheduling: I sent a message to 8192 ``trash'' recipients on my home
     machine. All the deliveries were done in a mere 78 seconds---a rate of
     over 9 million deliveries a day! Compare this to the speed advertised
     for Zmailer's scheduling: 1.1 million deliveries a day on a
     SparcStation-10/50. (My home machine is a 16MB Pentium-100 under
     BSD/OS, with the default qmail configuration. qmail's logs were piped
     through accustamp and written to disk as usual.)
   * Local mailing lists: When qmail is delivering a message to a mailbox,
     it physically writes the message to disk before it announces
     success---that way, mail doesn't get lost if the power goes out. I
     tried sending a message to 1024 local mailboxes on the same disk on my
     home machine; all the deliveries were done in 25.5 seconds. That's more
     than 3.4 million deliveries a day! Sending 1024 copies to a single
     mailbox was just as fast. Compare these figures to Zmailer's advertised
     rate for throwing recipients away without even delivering the
     message---only 0.48 million per day on the SparcStation.
   * Mailing lists with remote recipients: qmail uses the same delivery
     strategy that makes LSOFT's LSMTP so fast for outgoing mailing
     lists---you choose how many parallel SMTP connections you want to run,
     and qmail runs exactly that many. Of course, performance varies
     depending on how far away your recipients are. The advantage of qmail
     over other packages is its smallness: for example, one Linux user is
     running 60 simultaneous connections, without swapping, on a machine
     with just 16MB of memory!
   * Separate local messages: What LSOFT doesn't tell you about LSMTP is how
     many separate messages it can handle in a day. Does it get bogged down
     as the queue fills up? On my home machine, I disabled qmail's
     deliveries and then sent 5000 separate messages to one recipient. The
     messages were all safely written to the queue disk in 23 minutes, with
     no slowdown as the queue filled up. After I reenabled deliveries, all
     the messages were delivered to the recipient's mailbox in under 12
     minutes. End-to-end rate: more than 200000 individual messages a day!
   * Overall performance: What really matters is how well qmail performs
     with your mail load. Red Hat Software found one day that their mail
     hub, a 48MB Pentium running sendmail 8.7, was running out of steam at
     70000 messages a day. They shifted the load to qmail---on a smaller
     machine, a 16MB 486/66---and now they're doing fine.

Feature list

Setup:

   * automatic adaptation to your UNIX variant---no configuration needed
   * AIX, BSD/OS, FreeBSD, HP/UX, Irix, Linux, OSF/1, SunOS, Solaris, and
     more
   * automatic per-host configuration (qmail-makectl)
   * quick installation---no big list of decisions to make

Security:

   * clear separation between addresses, files, and programs
   * minimization of setuid code (qmail-queue)
   * minimization of root code (qmail-start, qmail-lspawn)
   * five-way trust partitioning---security in depth
   * optional logging of one-way hashes, entire contents, etc. (QUEUE_EXTRA)

Message construction (qmail-inject):

   * RFC 822, RFC 1123
   * full support for address groups
   * automatic conversion of old-style headers to RFC 822 format
   * header line length limited only by memory
   * host masquerading (control/defaulthost)
   * user masquerading (MAILUSER, MAILHOST)
   * sendmail hook for compatibility with current user agents

SMTP service (qmail-smtpd):

   * RFC 821, RFC 1123, RFC 1651, RFC 1652, RFC 1854
   * 8-bit clean
   * 931/1413/ident/TAP callback (tcp-env)
   * relay control---stop unauthorized relaying by outsiders
     (control/rcpthosts)
   * no interference between relay control and forwarding
   * tcpd hook---reject SMTP connections from known abusers
   * automatic recognition of local IP addresses
   * per-buffer timeouts
   * hop counting

Queue management (qmail-send):

   * instant handling of messages added to queue
   * parallelism limit (control/concurrencyremote, control/concurrencylocal)
   * split queue directory---no slowdown when queue gets big
   * quadratic retry schedule---old messages tried less often
   * independent message retry schedules
   * automatic safe queueing---no loss of mail if system crashes
   * automatic per-recipient checkpointing
   * automatic queue cleanups (qmail-clean)
   * queue viewing (qmail-qread)
   * detailed delivery statistics (qmailanalog, available separately)

Bounces (qmail-send):

   * QSBMF bounce messages---both machine-readable and human-readable
   * HCMSSC support---language-independent RFC 1893 error codes
   * double bounces sent to postmaster

Routing by domain (qmail-send):

   * any number of names for local host (control/locals)
   * any number of virtual domains (control/virtualdomains)
   * domain wildcards (control/virtualdomains)
   * configurable percent hack support (control/percenthack)
   * UUCP hook

SMTP delivery (qmail-remote):

   * RFC 821, RFC 974, RFC 1123
   * 8-bit clean
   * automatic downed host backoffs
   * artificial routing---smarthost, localnet, mailertable
     (control/smtproutes)
   * per-buffer timeouts
   * passive SMTP queue---perfect for SLIP/PPP links (maildir2smtp)

Forwarding and mailing lists (qmail-alias):

   * address wildcards (.qmail-default, .qmail-foo-default, etc.)
   * sendmail/smail /etc/aliases compatibility (qmsmac, available
     separately)
   * mailing list owners---automatically divert bounces and vacation
     messages
   * VERPs---automatic recipient identification for mailing list bounces
   * Delivered-To---automatic loop prevention, even across hosts
   * automatic subscription management (qlist)

Local delivery (qmail-alias):

   * user-controlled address hierarchy---fred controls fred-anything
   * mbox delivery
   * reliable NFS delivery (maildir)
   * user-controlled program delivery: procmail etc. (qmail-command)
   * optional new-mail notification (qbiff)
   * optional NRUDT return receipts (qreceipt)
   * conditional filtering (condredirect)

POP3 service (qmail-popup, qmail-pop3d):

   * RFC 1939
   * UIDL support
   * TOP support
   * APOP hook
   * modular password checking (checkpassword, available separately)

What else would you like to see on this page?

Send me some mail and let me know.
-- 

mjd@pobox.com                                             Mark-Jason Dominus
mjd@plover.com                              Plover Systems, Philadelphia, PA



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

Date: 25 Feb 1997 10:37:19 -0500
From: Jim Anderson <jander@ml.com>
Subject: Re: how to write a Perl shell?
Message-Id: <wkb914cucb4.fsf@swapsdvlp15.i-did-not-set--mail-host-address--so-shoot-me>

Lu TONG <ltong@helios.phy.ohiou.edu> writes:

> Is there anyone know how to write a shell interpretor by Perl which can
> be invoked in a script file. like this:
> -------
> #!/home/ttt/hello
> p  'this is a file'.
> -------
> where hello is the interpretor by Perl. Thanks!

How about something like this:

perl -de '0'


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

Date: Tue, 25 Feb 1997 22:51:56 -0700
From: Sugree Phatanapherom <ioisgp@std.cpc.ku.ac.th>
Subject: html parser
Message-Id: <Pine.GSO.3.95.970225224535.27537A-100000@std.cpc.ku.ac.th>


Have anyone can help me to write some code to parse html? Now I really
need function that accepts a string and returns me next tag or any words
until next tag.

for example:
<a href=abc.html>hi all</a>

it should return:
<a href=abc.html>
hi all
</a>

I know it's every simple. However you should have to know I get a
doubtful now.

thanks.

--
Sugree Phatanapherom                     Everything you do today may
ioisgp@std.cpc.ku.ac.th                  take effect tomorrow.
http://203.155.125.134/~sugreep/
http://std.cpc.ku.ac.th/~ioisgp/
http://www.geocities.com/Tokyo/4744/



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

Date: 25 Feb 1997 17:28:23 GMT
From: jalotta@aol.com (JALOTTA)
Subject: macperl help (2nd post)
Message-Id: <19970225172800.MAA13098@ladder02.news.aol.com>

Greetings,

how can I run macperl with a command line interface using the mpw shell?


after creating a droplet, where do I look for the dropped file?  I look in
$ARGV[0] but it's not there.

why didn't this post the first time?


Joe Alotta


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

Date: 25 Feb 1997 15:53:19 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: make for windows NT ?
Message-Id: <5ev1tf$qoh@fridge-nf0.shore.net>

Paul S. Cutt (cutt@netcom.com) wrote:

: I am using makemaker on windows NT and I need to do a make on the 
: resulting makefile. Does anyone use makemaker on windows NT and what do 
: they do about the make ?

Using the Activeware port of NTPerl on my Windows 95 machine, I noticed
that perl Makefile.PL generates a makefile.  I noticed that there's a number
of GNU tools (like make, autoconf, and gcc) available at:
http://www.itribe.net/virtunix/

Bear in mind that I've never tried these, so their reliability is
unsolicited. :-)

HTH!

--
Nathan V. Patwardhan
nvp@shore.net
"Lane, I've been in high school for
seven years.  I'm no dummy"
	--Charles Demar from _Better Off Dead_


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

Date: Tue, 25 Feb 1997 10:42:25 -0600
From: Michael F Juhlin <kato13@blinktech.com>
To: "Arlyn K. Chesley" <arlyn@airmail.net>
Subject: Re: Need PERL script for web site to track activity
Message-Id: <33131671.2588@blinktech.com>

Arlyn K. Chesley wrote:
> 
> Help!!
> 
> I was wondering if anyone had knew where I might be able to locate a
> PERL script that would track a websites activity.  I've seen a few of
> these mentioned before, but had not had need of one until now.  If
> anyone has one, all original author credits will be unmodified.
> 
> Thanks, Arlyn
> 
> arlyn@airmail.net
check out
 http://accesswatch.com/

this is a very good stat program with simple configuration to your site. 
-- 
=====================================================
Michael Juhlin                  mjuhlin@blinktech.com
-----------------------------------------------------
Blink Technology Corporation        T = (847)374-0101
155 North Pfingsten Road            F = (847)317-0009
Deerfield, Illinois 60015           
-----------------------------------------------------
See What You Think   > > >   http://www.blinktech.com
=====================================================


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

Date: 25 Feb 1997 11:00:34 -0500
From: Jim Anderson <jander@ml.com>
Subject: Re: newbie problem with pipes
Message-Id: <wkb67zgub8d.fsf@swapsdvlp15.i-did-not-set--mail-host-address--so-shoot-me>

gerd4000@mailszrz.zrz.TU-Berlin.DE (Gerd Schering) writes:

> -- 
> Hello,
> I try to use a named pipe to pipe data to another programm, i. e. gnuplot.
> The fifo gets created but after opening it, the whole process hangs.
> What's wrong?
> 
> ######################################################################
> #!/usr/bin/perl -d
> 
> require "timelocal.pl";
> 
> $infile = 'somefile';
> open (IN, "<$infile") || die "Can't open $infile for reading: $!\n";
> 
> $FIFO = 'plotfifo';
> if (-p $FIFO) {unlink $FIFO;}
> 
> system ('mkfifo', $FIFO);
> 
> open (COMMAND, "|/usr/bin/gnuplot");
> print COMMAND "plot $FIFO with lines\n";
> 
> open(DATA, ">$FIFO") || die "Can't open $FIFO for writing: $!\n";
> 
> # never got after here!
> 
> while (<IN>) {
> 
> 	... process data ...
> 
> }
> close DATA;
> sleep (10);
> close COMMAND;
> #######################################################################

This seems a little "overly complicated to me" :) Why bother with
FIFOs at all? Why not try something like the following:

==============================================================
my $file = 'somefile';
my $pgm = "/usr/bin/gnuplot >$file";

open CMD, "| $pgm" or die "open pipe failed for $pgm: $!\n";
local $SIG{PIPE} = sub {die "pipe $pgm failed: $!\n"};
print CMD "plot stuff goes here";
close CMD or die "close pipe failed for $pgm: $!\n";

open IN, $file or die "open failed for $file: $!\n";
while (<IN>) {
   ...
}
close IN;
==============================================================


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

Date: Sun, 23 Feb 1997 06:09:28 +0100
From: Nicolas Hubert <hub@club-internet.fr>
To: Paul J Tomsic <pjtst5+@pitt.edu>
Subject: Re: Opening a file to an exact location HELP?!
Message-Id: <330FD108.123E635B@club-internet.fr>

@lines=<MYFILE>; just reads the contents of MYFILE into array @lines.
push(@lines, "this is $contents{'username'}; modifies your array but
doesn't touch the file. What you might do is something like :


$FILE = "myfile.txt";
$contents{'username'}='phil';

# first open file for reading
open (MYFILE, "< $FILE") or die "Unable to open file $FILE for
reading\n"; # err
@lines = <MYFILE>;
close MYFILE;

# Now open file for writing
open (MYFILE, "> $FILE") or die "Unable to open file $FILE for
writing\n"; # err

if ($contents{'username'} eq 'phil') {
    $user_type="<big-users>";
} else {
    $user_type="<little-users>";
}

$found=0;  # this is a flag that prevents from writing the data to the
file twice
for ($i=0; $i<=$#lines ; $i++) {
    print MYFILE $lines[$i];
    if ($lines[$i] =~ /^$user_type/ && !$found) {
        # The next block prints out any blank lines that follow the tag
        while ($i+1<=$#lines && $lines[$i+1]=~/^\s*$/ ) { 
            print MYFILE $lines[++$i]; 
        }
        print MYFILE "this is $contents{'username'}\n";
        $found=1;
    }
}

Hope this helps

Nicolas

Paul J Tomsic wrote:
> 
> I'm having a hard time opening a file and inserting information into an
> exact spot into that file..
> 
> I've got something like the following.....
> 
> $FILE = "myfile.txt";
> 
> ....
> 
> $contents{'username'};
> 
> .......
> 
> open(MYFILE, $FILE);
> seek(MYFILE,0,0);
> @lines = <MYFILE>;
> push(@lines, "this is $contents{'username'};
> close(MYFILE);
> 
> Now in MYFILE, I've got something like this......
> 
> <big-users>
> 
> this is dave
> this is pete
> this is mike
> 
> </big-users>
> 
> <little-users>
> 
> this is mark
> this is wayne
> this is pedro
> 
> </little-users>
> 
> I want to put that username in between those tags.  Like if 'username'
> was phil, then I'd want to put "this is phil" on a line by itself, in-between
> the <big-users> tags.
> 
> Any help would be great...
> 
> Thanks
> 
> Paul Tomsic


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

Date: 25 Feb 1997 15:50:25 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Perl and win95
Message-Id: <5ev1o1$qoh@fridge-nf0.shore.net>

Bas van Reek (basvreek@channels.nl) wrote:
: I'm looking for a webserver that 
: makes it possible to run perl scrips
: on a win95 machine.

Ah, another server question disguised as a Perl question.  :-)
Perl != CGI.  CGI is not a language.

Your question would be properly answered in the www servers newsgroups,
like comp.infosystems.www.servers.misc.  You might also do a yahoo
(or whatever) search for www servers, where you'll find a host of 
good PC-www products.

HTH!

--
Nathan V. Patwardhan
nvp@shore.net
"Lane, I've been in high school for
seven years.  I'm no dummy"
	--Charles Demar from _Better Off Dead_


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

Date: Tue, 25 Feb 1997 16:35:27 GMT
From: tjordan@ns15.cca.rockwell.com (Terence Jordan)
Subject: Re: Perl and win95
Message-Id: <3313141d.13764634@news>

On Tue, 25 Feb 1997 16:38:16 +0100, Bas van Reek
<basvreek@channels.nl> scripted:

>I'm looking for a webserver that 
>makes it possible to run perl scrips
>on a win95 machine.
>
>Has anybody the registration key or a tip
>for another win95 webserver witth perl support?

No registration keys, but try a different server, with real people at
tech support.
It's $150 to register their professional server, and runs perl just
fine.
It's ZBServer Pro, and is available at:
www.zbserver.com

I've had it for almost a year, with little complaints.




+--Terence Jordan(x7233)----------------+----------------------------+
|TJordan@NS15.CCA.ROCKWELL.COM          | "When in danger,     <O>   |
|(parenthesis)                          |  Or in doubt,         |    |
|---------------------------------------|  Run in circles,    _/ \   |
|Views expressed are Terence's          |  Scream and shout!"    /   |
+-----and of no other.------------------|----------------------------+


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

Date: Tue, 25 Feb 1997 11:08:55 -0500
From: Matthew.Healy@yale.edu (Matthew D. Healy)
Subject: Re: printing date of a file to html page
Message-Id: <Matthew.Healy-2502971108550001@pudding.med.yale.edu>

In article <biqhe5.4v1.ln@localhost>, tadmc@flash.net (Tad McClellan) wrote:

 ...

> : page.  I would like to be able to have this system automatically print
> : the last updated date of the files on the screen, rather than doing it
> : by hand each time.  Can this be done using perl?
>                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> Yes.
> 

However, there is a very good chance you can do it without using Perl
at all, if your httpd server is configured to support SSI (Server-Side
Includes).

Try something like the following example, which works on NCSA servers:

<HR>
Last modified: <!--#config timefmt="%d %B %Y" --><!--#flastmod virtual="/in
dex.html" --><BR>

Note that the /index.html will need to be changed so it points back at
whichever file is being displayed...

---------
Matthew.Healy@yale.edu
http://paella.med.yale.edu/~healy
Go and share the Gospel.  Use words only if necessary --St Francis


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

Date: 25 Feb 1997 16:39:39 +0000
From: Jim Anderson <jander@ml.com>
Subject: Re: Q: How to delete several files in one operation (newbie)
Message-Id: <wkbwwrwsuus.fsf@swapsdvlp15.i-did-not-set--mail-host-address--so-shoot-me>

sajaa@sn.no (Jarle Aasland) writes:

> Here is what I have done so far:
> 
> I have a script that generate text-files from user input. Then it
> reads all the text-files and put the content into dynamically
> generated web-pages (with x-number of files on each page).
> 
> Then, I have a script that lists all the generated text-files (output
> to another html-page). From here, it's possible to edit or delete each
> individual text-file.
> 
> Problem: I can now delete each file by itself (by clicking it's
> respective "Delete" link), but what I want to do is choose several
> files, and then "Delete all marked files".

You're posting to the wrong newsgroup. Repost to

	comp.infosystems.www.authoring.cgi


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

Date: Tue, 25 Feb 1997 08:02:15 -0800
From: Jerry Anders <anders@ix.netcom.com>
Subject: Reading formatted (13.6E) data
Message-Id: <33130D07.208@ix.netcom.com>

The data that I'm trying to read is formatted in 10 columns and is in 13.6E format. The following is an example:

 0.111000E+01-0.112000E+01 0.113000E+01 0.114000E+01 0.115000E+01 0.116000E+01 0.117000E+01 0.118000E+01 0.119000E+01-0.111000E+01
 0.121000E+01 0.122000E+01 0.123000E+01-0.124000E+01 0.125000E+01 0.126000E+01 0.127000E+01 0.128000E+01 0.129000E+01 0.121000E+01
 0.131000E+01 0.132000E+01 0.133000E+01 0.134000E+01 0.135000E+01 0.136000E+01
 0.111000E+01 0.112000E+01-0.113000E+01 0.114000E+01 0.115000E+01 0.116000E+01-0.117000E+01 0.118000E+01 0.119000E+01 0.111000E+01
 0.121000E+01 0.122000E+01 0.123000E+01 0.124000E+01 0.125000E+01 0.126000E+01 0.127000E+01 0.128000E+01 0.129000E+01 0.121000E+01
-0.131000E+01 0.132000E+01 0.133000E+01 0.134000E+01 0.135000E+01 0.136000E+01
 .
 .

If the data came across the net properly you should see blocks of data in 10 columns and each block has 26 numbers.

My question is, instead of reading the file line by line and then breaking that line ($_) down into numbers, can I read the file
number by number. Can I modify the input record separator ($/) such that it interprets 13.6E format instead of creating elaborate loops 
which read every character or blocks of 13 characters? Is there and easier way to extract the data number by number? 

An example of what I'm doing with the data is, lets say, extract every 3, 6, 10-15, 20-22, number from each block and stuff them into and 
array (i.e., extract protions of this data and save them in an array). Since I have lots of data which uses strict formats (engineering data) 
as shown above, I'd like a solution which uses formats such as %13.6E. I understand how to print using formats, but can I read using formats?

Thanks in advance for all suggestions.

Jerry Anders
anders@ix.netcom.com


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

Date: 25 Feb 1997 17:14:30 +0100
From: vetler@ifi.uio.no (Vetle Roeim)
Subject: replaceing stuff
Message-Id: <5ev356$20p@refil.ifi.uio.no>


hi!
i'm trying to write a script that extratcs links from html-documents.
the only problem i have, is that i don't know how i should
delete everything exept the link from a variable.
ex: a line says; <A HREF="http://www.perl.org">Perl</A>, and i want it to
say "http://www.perl.org".

help, please :)

-- 
----- Vetle Roeim -------
e!mail: vetler@ifi.uio.no
-------------------------


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

Date: Tue, 25 Feb 1997 17:23:56 GMT
From: tjordan@ns15.cca.rockwell.com (Terence Jordan)
Subject: Re: replaceing stuff
Message-Id: <33131f70.16664575@news>

On 25 Feb 1997 17:14:30 +0100, vetler@ifi.uio.no (Vetle Roeim)
scripted:

>ex: a line says; <A HREF="http://www.perl.org">Perl</A>, and i want it to
>say "http://www.perl.org".
>

ok, let's set up the following situation:

$var1="It's not unusual to be loved by anyone...\n";
$var2=substr($var1,9,7);
print "$var1\n Ok, maybe it is $var2";

>help, please :)
No problem.



+--Terence Jordan(x7233)----------------+----------------------------+
|TJordan@NS15.CCA.ROCKWELL.COM          | "When in danger,     <O>   |
|(parenthesis)                          |  Or in doubt,         |    |
|---------------------------------------|  Run in circles,    _/ \   |
|Views expressed are Terence's          |  Scream and shout!"    /   |
+-----and of no other.------------------|----------------------------+


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

Date: 25 Feb 1997 18:50:36 +0100
From: vetler@ifi.uio.no (Vetle Roeim)
Subject: Re: replaceing stuff
Message-Id: <5ev8pc$5p3@refil.ifi.uio.no>


In article <33131f70.16664575@news>, tjordan@ns15.cca.rockwell.com (Terence Jordan) writes:
> On 25 Feb 1997 17:14:30 +0100, vetler@ifi.uio.no (Vetle Roeim)
> scripted:
> 
> >ex: a line says; <A HREF="http://www.perl.org">Perl</A>, and i want it to
> >say "http://www.perl.org".
> >
> 
> ok, let's set up the following situation:
> 
> $var1="It's not unusual to be loved by anyone...\n";
> $var2=substr($var1,9,7);
> print "$var1\n Ok, maybe it is $var2";
> 
> >help, please :)
> No problem.

thanks, but it's not quite what i'm looking for.
you're piece of code requires me to know exactly where the
string i want is located and how long it is.
what i do know, is that it starts with http:// and ends with either
a " or a >.
 .. so it's not exactly what i'm looking for.

what i've tried so far, is
this:

          $line =~ /http.*"/;
          print $&."\n";

but it doesn't work exactly the way i want it.

i want it to stop when it hits a " _or_ a >. how can i do that?

-- 
----- Vetle Roeim -------
e!mail: vetler@ifi.uio.no
-------------------------


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

Date: 25 Feb 1997 10:34:14 -0500
From: Jim Anderson <jander@ml.com>
Subject: Re: running prog from within perl script
Message-Id: <wkbbu98ucg9.fsf@swapsdvlp15.i-did-not-set--mail-host-address--so-shoot-me>

Iqbal Gandham <igandham@prestel.net> writes:

> Hi
> 
> I have a program called pngen
> the oupt from this is password: encryptpass
> 
> I need to runthis program from another perl script. How do
> I do this . I want to store the values to a string.

Something like this: (untested)

===============================================================
my $pgm = 'pngen';
open PGM, "$pgm |" or die "open pipe failed for $pgm: $!\n";
local $SIG{PIPE} = sub {die "pipe failed for $pgm: $!\n"};
my @data = <PGM>;
close PGM or die "close pipe failed for $pgm: $!\n";
chomp @data;
===============================================================


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

Date: Tue, 25 Feb 1997 17:12:15 +0100
From: Janez <janezz@balki.fer.uni-lj.si>
Subject: Strange question
Message-Id: <33130F5F.22D2@balki.fer.uni-lj.si>

It seems strange to me that none of Win32 language implementations
support select() in a C or C-like fashion (meaning ActiveWare Perl,
Python1.4 and Cygnus GCC)... Or am I wrong?


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

Date: 25 Feb 1997 17:48:29 +0100
From: Tom Grydeland <tom@geronimo.uit.no>
Subject: Re: Using Perl with painful or carefree style?
Message-Id: <ofbwwrwbzmq.fsf@geronimo.uit.no>

"Sam Inala" <sami@microsoft.com> writes:

> use -w, use strict, and include function prototypes.
> 
> I must enjoy pain. [...] Are there
> people out there who actually practice both a carefree
> style and a somber style?

Certainly.  You wouldn't say

perl -Mstrict -wpie 's/foo/bar/' files

would you?

> and do not reflect the official views of Microsoft Corporation

Hmm..

-- 
//Tom Grydeland <Tom@nospam.eiscat.no>  # delete 'nospam.' for valid address


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

Date: Tue, 25 Feb 1997 10:52:27 -0500
From: airborne@cybernex.net (Angel Leyva)
Subject: Writing a subroutine
Message-Id: <33240944.95248399@news.cybernex.net>

I want to write a subroutine that accepts a text string and returns it in a new
form.

Basically, I want to strip some characters and replace others. For example, I
want to strip leading and trailing spaces and newlines.

I am sure that there are several ways to do this, but the two ways that I am
interested in are first, have the string that I pass in get the new values
automatically, like as a global variable. The second way would be assign it back
to itself as I call the routine, then have the routine return the result. I want
the result to replace what was passed in. Please provide examples on how to call
the routines, as well as the snip of code for the routine.

EXAMPLE:

$variable1 = &StripExtraChars($variable1);
# note the same variable name

The other way being simply

&StripExtraChars($some_global_variable);
#$some_global_variable now has the new string and no trace of the old one.


All help and suggestions appreciated.


Angel Leyva
(airborne@www2.cybernex.net)

http://cybernex.net/~airborne


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

Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 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.

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

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