[7832] in Perl-Users-Digest
Perl-Users Digest, Issue: 1457 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 11 19:07:18 1997
Date: Thu, 11 Dec 97 16:00:29 -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, 11 Dec 1997 Volume: 8 Number: 1457
Today's topics:
/string/o <blakem@seas.upenn.edu>
Re: 5.004_04 Out of Memory bug <zenin@best.com>
A ^M question. <jonestl@Dont-even-try-it.com>
Re: A ^M question. <reibert@mystech.com>
Re: a certain bug...!!! <zenin@best.com>
Re: Call chmod in cgi script? <"anonymous"@\"/dev/null\".>
Re: Can't 'print' large (> 6M) files <zenin@best.com>
Re: Download Question - Yes Please (brian d foy)
Re: Download Question - Yes Please <dtlgc@deletethisstringanddot.flash.net>
Encryption <ian@king.igs.net>
Re: Encryption (Mike Stok)
Re: Encryption (brian d foy)
FREE Source code and demos here! <chizl@SPAMkarland.com>
Re: HASH trouble ? *precious help* (brian d foy)
Re: how do I make perl script interact with shall comma <luu_tran@geocities.com>
Re: is there anyway around this ssi problem with "query (brian d foy)
Re: is there anyway around this ssi problem with "query <zenin@best.com>
Re: last element in an array? <reibert@mystech.com>
Re: Learning Perl - How to start <allie@icct.net>
Re: Memory leak (perl 5.004_04) <bowlin@sirius.com>
Re: Memory leak (perl 5.004_04) <brian@posthuman.com>
Most Common Web dev tools? (Jay Quinn)
Most common Web Dev tools? (Jay Quinn)
Re: Most Common Web dev tools? (I R A Aggie)
need help! <ngyat@isu.edu>
Re: need to know what browser the client is using <dharris@drh.net>
Perl 5 on Win95 and Serial Ports... (Kevin Ow-Wing)
Perl mail attachments <henrym@image.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 11 Dec 1997 22:30:37 GMT
From: "Blake D. Mills IV" <blakem@seas.upenn.edu>
Subject: /string/o
Message-Id: <66ppid$n5k$1@netnews.upenn.edu>
I just inherited some code that has:
m/constant/o
all over the place. I understand the benefit of the /o modifier when
the regex could change (but you know it wont)... ie:
m/$var/o
However, perl does quite a bit behind the scenes and I wouldn't be
surprised if m/constant/ was equivalent to m/constant/o since the regex
can't be modified.
I looked in the documentation, and didn't find the answer. I suppose
I'll try benchmarking the two snippets to see if there is any difference
in performance... unless someone out there knows the answer. ;-)
Thanks.
-Blake
------------------------------
Date: 11 Dec 1997 22:42:51 GMT
From: Zenin <zenin@best.com>
Subject: Re: 5.004_04 Out of Memory bug
Message-Id: <881880390.891991@thrush.omix.com>
lighta@gcm.com wrote:
: I am having an "Out of Memory" problem with certain Perl 5.004.04 scripts.
: It seems that certain scripts will consume HUGE amounts of memory
: (50-200MB).
>snip<
I seem to have fixed this on my system (FreeBSD 2.2.5-STABLE). At
least for me it was a fu^H^Hunexpected login.conf and ulimit
problem. Check your system's user resource limits and personal
resource (ulimit) limits.
It doesn't seem to be perl itself.
--
-Zenin
zenin@best.com
------------------------------
Date: Thu, 11 Dec 1997 16:37:15 -0500
From: "T. Jones" <jonestl@Dont-even-try-it.com>
Subject: A ^M question.
Message-Id: <34905D0A.8BBFD64C@Dont-even-try-it.com>
What is a way to delete those stupid ^M's at the end of each line of my
downloaded flat files?
Thanks,
Tj
--
Very funny scotty! Now beam down the rest of my clothes.
------------------------------
Date: Thu, 11 Dec 1997 16:08:41 -0700
From: "Mark S. Reibert" <reibert@mystech.com>
Subject: Re: A ^M question.
Message-Id: <34907279.57DD1F22@mystech.com>
T. Jones wrote:
> What is a way to delete those stupid ^M's at the end of each line of my
> downloaded flat files?
>
> Thanks,
> Tj
>
> --
> Very funny scotty! Now beam down the rest of my clothes.
The ^M's are the famous carriage-return/line-feed combinations that
DOS/Windows uses to designate end of line. I presume you "binary"
transferred the files from DOS/Windows to UNIX. The simplest ways to handle
this problem is to transfer the files as ASCII or "text", which should take
care of the newline conversion for you. If this is not an option, most
UNIX's have some kind of utility to convert the CR-LF combination to the
simple LF that UNIX uses. If this also is not an option, just strip the CR
and leave the LF. Since CR is ASCII character number 13, the following Perl
script will do the trick.
#!/usr/local/bin/perl
$CR = chr(13);
while ( <> ) {
s/$CR//;
print;
}
That's all there is to it! Assuming the script is called 'filter', just
invoke it as a standard UNIX filter ('cat file | filter > new_file') or
give the file name on the command line ('filter file > new_file').
Hope this helps,
Mark Reibert
-----------------------------
Mark S. Reibert, Ph.D.
Mystech Associates, Inc.
3233 East Brookwood Court
Phoenix, Arizona 85044
Tel: (602) 732-3752
Fax: (602) 706-5120
E-mail: reibert@mystech.com
-----------------------------
------------------------------
Date: 11 Dec 1997 23:00:32 GMT
From: Zenin <zenin@best.com>
Subject: Re: a certain bug...!!!
Message-Id: <881881452.43003@thrush.omix.com>
brian d foy <comdog@computerdog.com> wrote:
: In article <348FEBAA.4157246F@inria.fr>, Christian Khoury <Christian.Khoury@inria.fr> wrote:
: ut then, i wouldn't call it (+>) Read-Write mode...it's
: >Read-Write-Create mode...:-)
:
: unless it doesn't create the file...
The exact mode is still O_RDWR|O_TRUNC|O_CREAT. "+<" would
be Read-Write (O_RDWD only) mode.
--
-Zenin
zenin@best.com
------------------------------
Date: Thu, 11 Dec 1997 18:21:53 -0800
From: Ray Bush <"anonymous"@\"/dev/null\".>
Subject: Re: Call chmod in cgi script?
Message-Id: <66pssl$4tl@btc3.up.net>
David Richards wrote:
>
> In article <348E09C6.2F5E@nowhere.com>, <none@nowhere.com> wrote:
> >Is it possible to call the UNIX system command 'chmod' in a cgi script?
>
> Yes, in fact per has a built-in 'chmod' command.
>
> >My purpose is to temporarily give a file write permission, write to it
> >via the script, then reset the file permission to read only to prevent
> >unwanted tampering. I'm trying to do it like this:
>
> That is _NOT_ a good idea. Your idea provides only the illusion of security,
> with anybody who can write a few lines of code being able to get through
> your 'protection'.
>
> >...earlier stuff...
> >`chmod 666 myfile.htm`; # set permissions to read and write for all
> >...write to the file...
> >`chmod 644 myfile.htm`; # set permissions back to read only for others
>
> You should instead use:
>
> chmod(0666,"/path/to/myfile.htm");
> chmod(0644,"/path/to/myfile.htm");
>
> That leading '0' (zero) is required so Perl will know the argument is octal.
>
> >But when I execute this (with myfile's permission initially 644) the
> >chmod commands within my script have no effect and the file does not get
> >written to.
>
> What I don't understand is, if the script has permission to change the mode
> (permissions) on the file to allow writing, then it would already have
> sufficient permissions to have written to the file before the chmod().
>
> >Is there some limitation here I'm not aware of? Am I not
> >using correct syntax? Is there another way to achieve the same result?
>
> I'm guessing that 'myfile.htm' isn't in the 'current working directory'
> of the script, thus the chmod commands are failing.
>
> Or the script is trying to change permissions on a file that isn't owned
> by the userid the program is running as.
>
> Just as you cannot write to a file you do not own (unless permissions are
> set to group or world write) you also cannot change permissions on a file
> you do not own, for similar reasons.
Isnt it all artificial anyway because all the cgi's run as the same
user thus anyone who can write a few lines of code can kill anyone elses
files/cgis on the box.
Dont you need something like suexec for this kind of approach to be
even partly worthwhile.
Isnt there some directive for vitual hosts to run as user with a
usermask setting? Course we dont even know it that's apply here. Seems
a friend of mine mentioned such a thing but it may be just a hack module
he made.
--Ray
------------------------------
Date: 11 Dec 1997 23:15:14 GMT
From: Zenin <zenin@best.com>
Subject: Re: Can't 'print' large (> 6M) files
Message-Id: <881882333.555037@thrush.omix.com>
Brian Atkins <brian@posthuman.com> wrote:
: Hmm, this might be the answer to the problem I having (see my
: "Memory leak (Perl5.004_04) message. If you find anything out,
: could you let me know? I will do likewise!
For both of you guys, what does "ulimit -a" (or just "limit" if
you're running a C-Shell of some kind) print out?
--
-Zenin
zenin@best.com
------------------------------
Date: Thu, 11 Dec 1997 16:09:50 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Download Question - Yes Please
Message-Id: <comdog-ya02408000R1112971609500001@news.panix.com>
In article <349014E8.2CF6@deletethisstringanddot.flash.net>, Steve <dtlgc@deletethisstringanddot.flash.net> wrote:
>I have the excat same question.
>
>I have been looking at MIME Headers, Content-type
>Content-ID, Content-Description
>but have not found a way yet.
>
>Must be something simple, eh?
it is, and the persons in a newsgroup devoted to CGI or HTTP might
tell you if you asked nicely :)
of course, it might be easier to get an answer if you had a valid
email address...
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Thu, 11 Dec 1997 15:51:52 -0800
From: Steve <dtlgc@deletethisstringanddot.flash.net>
Subject: Re: Download Question - Yes Please
Message-Id: <34907C98.46D7@deletethisstringanddot.flash.net>
Brian,
Thanks for the reply.
It's a valid email address, just modified for spam-related reasons.
dtlgc@flash.net
I'll do some more checking, but of course I appreciate any assistnace.
Thanks,
Steve
brian d foy wrote:
>
> In article <349014E8.2CF6@deletethisstringanddot.flash.net>, Steve <dtlgc@deletethisstringanddot.flash.net> wrote:
>
> >I have the excat same question.
> >
> >I have been looking at MIME Headers, Content-type
> >Content-ID, Content-Description
> >but have not found a way yet.
> >
> >Must be something simple, eh?
>
> it is, and the persons in a newsgroup devoted to CGI or HTTP might
> tell you if you asked nicely :)
>
> of course, it might be easier to get an answer if you had a valid
> email address...
>
> --
> brian d foy <comdog@computerdog.com>
> NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
> CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Thu, 11 Dec 1997 16:14:44 -0500
From: "Ian Duchesne" <ian@king.igs.net>
Subject: Encryption
Message-Id: <66pl1j$4le$1@news.igs.net>
Hi all,
Here's my situation. I'm using perl 5.001. Trying to use the crypt program.
I am able to crypt a word but I cannot uncrypt the crypted word.
Some help would be appreciated.
Thanks .
ian
------------------------------
Date: 11 Dec 1997 16:45:35 -0500
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Encryption
Message-Id: <66pmtv$1jt$1@stok.co.uk>
In article <66pl1j$4le$1@news.igs.net>, Ian Duchesne <ian@king.igs.net> wrote:
>Hi all,
>
>Here's my situation. I'm using perl 5.001. Trying to use the crypt program.
>
>I am able to crypt a word but I cannot uncrypt the crypted word.
Are you using the crypt program or the crypt function. Perl's crypt calls
the C library crypt, and the usual way to check whether a user has entered
a correct password is to encrypt it with the same salt used to generate
the original encrypted version and see if the encrypted attempt matches
the "master" copy. The original salt is the first 2 characters of the
encrypted password.
If this is your real question then try searching at
http://www.dejanews.com, if not sorry to have wasted your time.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Thu, 11 Dec 1997 17:11:44 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Encryption
Message-Id: <comdog-ya02408000R1112971711440001@news.panix.com>
In article <66pl1j$4le$1@news.igs.net>, "Ian Duchesne" <ian@king.igs.net> wrote:
>I am able to crypt a word but I cannot uncrypt the crypted word.
it's a one way function. see the crypt man page for details.
you might also try
perldoc -f crypt
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 11 Dec 1997 05:45:09 GMT
From: Chizl<chizl@SPAMkarland.com>
Subject: FREE Source code and demos here!
Message-Id: <66nul5$au2$31@news.unicomp.net>
Over 31 languages all free source and demos.. Check it all out..
http://www.karland.com/code/ - Missiouri, USA
http://www.sourcesite.simplenet.com/ - California, USA
Get programming tools at http://www.karland.com/
We are trying to start a Visual Components (OCX) Directory at http://www.karland.com/VisualComponents/ so if you have some that you would like to donate or get please check it out.. We don't have any up yet because we want to know if this is what people would like and want to see if people are willing to donate so we can get this quite huge..
L8r,
Chizl
------------------------------
Date: Thu, 11 Dec 1997 16:07:34 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: HASH trouble ? *precious help*
Message-Id: <comdog-ya02408000R1112971607340001@news.panix.com>
In article <34901CB5.4C18@writeme.com>, philc@writeme.com wrote:
>while ( ($k,$v) = each (%fiche) )
>{
> $f=$k.".txt" ;
> $t = ` cat $f ` ;
> $fiche{'$k'}=$t;
i'm guessing that you meant
$fiche{$k}=$t;
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 10 Dec 1997 18:34:08 GMT
From: "Luu Tran" <luu_tran@geocities.com>
Subject: Re: how do I make perl script interact with shall command?
Message-Id: <35774.4407789352luutrangeocitiescom@207.217.244.78>
On Tue, 09 Dec 1997, Matthew Cravit <mcravit@best.com> wrote:
>Why do you need to use the htpasswd command to do this? If you write the
>htpasswd file entry yourself, you save the overhead of spawning off two
>processes, plus you don't need to play games to feed input to htpasswd on
>a terminal, which is what it expects (and why your example doesn't work).
>
>Try something like this:
>
> print "Enter your username: ";
> chomp($username = <STDIN>);
> while (1) {
> print "Enter your password: ";
> chomp($password = <STDIN>);
> print "Confirm your password: ";
> chomp($passcheck = <STDIN>);
> last if ($passcheck eq $password);
> print "Passwords do not match. Please re-enter your password\n";
> }
> $encrypted_pw = crypt $password, substr($username, -2);
> open (HTPASSWD, ">>/path/to/htpasswd") or die "Could not open file:
$!\n";
> print HTPASSWD, "$username:$encrypted_pw\n";
> close HTPASSWD;
>
This wouldn't work for me since perl's crypt doesn't give the same result
as htpasswd (for one thing, the latter's is about twice as long).
I'm using freebsd, apache, perl 5.003.
-- luu
http://www.bayscenes.com/np/mdonline/
Please remove the underscore _ in my address when replying by email
------------------------------
Date: Thu, 11 Dec 1997 16:02:03 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: is there anyway around this ssi problem with "query_String?
Message-Id: <comdog-ya02408000R1112971602030001@news.panix.com>
In article <348feca7.13315138@snews.zippo.com>, 4823@283423 (283492834) wrote:
>i have an ssi
><!--#exec cmd="/home/user/go/html/cgi-bin/perl.pl?miscinfo"-->
the value of th ecmd directive is a string that the shell will execute.
unless your filename is /home/user/go/html/cgi-bin/perl.pl?miscinfo, the
shell won't find anything to execute.
perhaps you missed the documentation for SSIs, which are listed in the
CGI Meta FAQ. there you should find such things as #include, which
do what you want.
if that doesn't help, a newsgroup devoted to your server product would
be a better place to ask such questions.
good luck :)
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 11 Dec 1997 23:18:18 GMT
From: Zenin <zenin@best.com>
Subject: Re: is there anyway around this ssi problem with "query_String?
Message-Id: <881882507.188838@thrush.omix.com>
283492834 <4823@283423> wrote:
: i have an ssi
: <!--#exec cmd="/home/user/go/html/cgi-bin/perl.pl?miscinfo"-->
Use either one of these:
<!--#exec cmd="/home/user/go/html/cgi-bin/perl.pl miscinfo"-->
<!--#exec cgi="/cgi-bin/perl.pl?miscinfo"-->
But note the second version will be expected to at least
print out a Content-Type header first.
--
-Zenin
zenin@best.com
------------------------------
Date: Thu, 11 Dec 1997 15:36:16 -0700
From: "Mark S. Reibert" <reibert@mystech.com>
Subject: Re: last element in an array?
Message-Id: <34906ADF.E37E3394@mystech.com>
snailgem@aol.com wrote:
> In order to do this, I need to be able to reference the last element of
> the array returned by grep. How do I do this?
> I.E., if
> @matches=grep (/line\d_/, @myfile);
> and
> $nu_matches=grep (/line\d_/, @myfile);
> how do I reference the last element of @matches? ($matches[$nu_matches]
> doesn't work).
>
> Or am I going the wrong way about all this?
>
> Thanks.
First, let me state that I appreciate the varying discussion on this point.
Following that vein, let me throw my two cents in:
1. Spend the $40 and get your own copy of "Programming Perl". It's amazing
what this book covers if you'll only curl up with it at night for a few
weeks! (It's fun reading too due to Larry's great sense of humor!)
2. Use a negative index to count from the end of an array. It is much more
clear (obviously my opinion) than the $#arrayName construct, which can
easily be confused with scalar(@arrayName) even though they are one
different. The negative index is documented in Programming Perl, although
somewhat obscurely (check the footnote on the bottom of page 36).
In the tradition of Perl, all the foregoing is absolutely correct except
where it is incorrect!
See Ya,
Mark Reibert
-----------------------------
Mark S. Reibert, Ph.D.
Mystech Associates, Inc.
3233 East Brookwood Court
Phoenix, Arizona 85044
Tel: (602) 732-3752
Fax: (602) 706-5120
E-mail: reibert@mystech.com
-----------------------------
------------------------------
Date: Thu, 11 Dec 1997 16:52:40 -0600
From: Allie <allie@icct.net>
To: I R A Aggie <fl_aggie@thepentagon.com>
Subject: Re: Learning Perl - How to start
Message-Id: <34906EB6.4BE0AC44@icct.net>
I R A Aggie wrote:
> In article <34903891.90EF86E5@icct.net>, Allie <allie@icct.net>
> wrote:
>
> + I don't have programming experience, but I'm eager to start
> + learning Perl.
>
> OH DEER LARD! :) You'll have to be real careful. Perl isn't really
> suited
> to learn programming. I'm not saying that you can't do it, but it
> can
> be an adventure. I've been using perl for 3 years now, and fortran
> for
> 15 years before that, and I _still_ get bit by my own
> _carelessness_,
> from time-to-time.
>
> Perl will quite cheerfully allow you to hang yourself. Most
> teaching
> languages refuse to do so. And they usually don't have access to
> potentially dangerous calls.
>
> James
Okay, not that I am letting this negativity get under my skin or
anything, BUT, if I did get discouraged about Perl, but still wanted
to learn to program so that eventually I'd be competant to learn
Perl, what would be a reccommended language to begin with? And, of
course, a book to learn with. Not that I'm discourged or
anything.....
------------------------------
Date: Thu, 11 Dec 1997 13:02:43 -0800
From: Jim Bowlin <bowlin@sirius.com>
To: Brian Atkins <brian@posthuman.com>
Subject: Re: Memory leak (perl 5.004_04)
Message-Id: <349054F3.6DFBAD42@sirius.com>
Brian Atkins wrote:
>
> Hi, if anyone can help me find a memory leak in the code below
> ...
If your DB file is really large, you might be running out
of memory trying to read in all of the keys into a huge list.
try changing:
foreach $user (keys %h5) {
to
while ( ($user, $dum) = each %h5) {
HTH - Jim Bowlin
------------------------------
Date: Thu, 11 Dec 1997 16:42:20 -0500
From: Brian Atkins <brian@posthuman.com>
To: bowlin@sirius.com
Subject: Re: Memory leak (perl 5.004_04)
Message-Id: <34905E3C.B686F704@posthuman.com>
I don't believe that is the problem; I printed all the keys in
the database to a flatfile, and looped through that using a
while loop and I still get the same results. The memory growth
is coming from something within the loop, not the loop itself.
Jim Bowlin wrote:
>
> Brian Atkins wrote:
> >
> > Hi, if anyone can help me find a memory leak in the code below
> > ...
>
> If your DB file is really large, you might be running out
> of memory trying to read in all of the keys into a huge list.
>
> try changing:
>
> foreach $user (keys %h5) {
>
> to
>
> while ( ($user, $dum) = each %h5) {
>
> HTH - Jim Bowlin
--
The future has arrived; it's just not evenly distributed.
-William Gibson
______________________________________________________________________
Visit Hypermart at http://www.hypermart.net for free business hosting!
------------------------------
Date: Thu, 11 Dec 1997 21:51:03 GMT
From: jpquinn@cyberramp.net (Jay Quinn)
Subject: Most Common Web dev tools?
Message-Id: <3490603a.1706413@newshost.cyberramp.net>
What are the most common web development tools being used today?
Does anyone have a rough percentage of how much of each of the common
tools are being used for web development?
Thanks
Q
------------------------------
Date: Thu, 11 Dec 1997 21:56:32 GMT
From: jpquinn@cyberramp.net (Jay Quinn)
Subject: Most common Web Dev tools?
Message-Id: <34906183.2035206@newshost.cyberramp.net>
What are the most common web development tools being used today?
Does anyone have a rough percentage of how much of each of the common
tools are being used for web development?
Thanks
Q
------------------------------
Date: Thu, 11 Dec 1997 18:36:01 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Most Common Web dev tools?
Message-Id: <-1112971836020001@aggie.coaps.fsu.edu>
In article <3490603a.1706413@newshost.cyberramp.net>,
jpquinn@cyberramp.net wrote:
+ What are the most common web development tools being used today?
Define, please, what you mean by 'web development tools'?
Are you talking programming tools?
HTML tools?
Link verifiers?
Image editors?
Imagemap makers?
James - the lists stops 'cause I couldn't think of any more, but my brain
fried right now, so feel free to add more...
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: Thu, 11 Dec 1997 15:43:21 -0700
From: Ann <ngyat@isu.edu>
Subject: need help!
Message-Id: <34906C89.7BC8FDC9@isu.edu>
Hi ,
I tried to write a perl program to cut up each paragraph into lines
that has as many words as possible. I use a entire blank line to
determine a new paragraph. And the last line should be single spaced.
Maybe, it will be much clear, if I give an example.
Test file:
1111111111111111111111111
22222222222222222222222222222222222222
2222222222222
3333333333333333333333333
3333333333333333333333333
444444444
44
5555555555555555555555555
6666666666666666666666666
I want to have:
111111111111111111111111
222222222222222222222222222222222222222222222222222
33333333333333333333333333333333333333333333333333
44444444444
5555555555555555555555555
6666666666666666666666666
However, I got:
1111111111111111111111111 <-- right
22222222222222222222222222222222222222
2222222222222 <-- don't go up to make it one
line.
3333333333333333333333333
3333333333333333333333333 <-- same problem
444444444
44 <-- same problem!
5555555555555555555555555
6666666666666666666666666
Here is the code, but somehow it is not working!
#!/usr/local/bin/perl
$COLUMNS = 30;
$infile = "text.txt";
$outfile = "out.txt";
WrapIt($COLUMNS, $infile, $outfile); # once you
have the above three
values
# just put the WrapIt line in.
sub WrapIt {
($COLUMNS, $infile, $outfile) = @_;
open (IN, "$infile") or print "cannot open
filename\n";
@lines = <IN>;
close IN;
chomp @lines;
@newlines = ();
foreach $i (@lines) {
@words = split(/\s+/, $i);
if ($i eq "") {
push(@newlines, "");
next;
}
foreach $j (@words) {
if ($COLUMNS < (length($currentline) + 1 +
length($j))) {
push (@newlines, $currentline);
$currentline = "$j";
} else {
if ($currentline) {
$currentline .= " $j";
} else {
$currentline = "$j";
}
}
}
push(@newlines, $currentline);
$currentline = "";
}
open (OUT, ">$outfile") or print "cannot
write to output file\n";
foreach $i (@newlines) {
print OUT "$i\n";
print "$i\n"; # echoes to ST OUT
}
}
If you guys know how to do it, just let me know! Thanks!
------------------------------
Date: Wed, 10 Dec 1997 20:42:27 -0500
From: "David Harris" <dharris@drh.net>
Subject: Re: need to know what browser the client is using
Message-Id: <66nfvn$56b@ecuador.earthlink.net>
Hi,
Ah, the browser companies really did mess up the HTTP_USER_AGENT environment
variable by calling everything Mozilla. Your secret decoder ring is at:
http://www.gsb.georgetown.edu/dept/gsbtc/waehner/browser/
- David Harris
Principal Engineer, DRH Internet Services
dharris@drh.net
------------------------------
Date: 11 Dec 1997 21:46:06 GMT
From: kevin@kestrel.edu (Kevin Ow-Wing)
Subject: Perl 5 on Win95 and Serial Ports...
Message-Id: <66pmuu$1s7$1@tern.kestrel.edu>
Keywords: Perl 5, Windows, Serial Port
Hi,
I am trying to talk to the serial port(s) on a windows 95 (OSR2.1) machine.
I have tried to use:
open( PORT, "+>COM1" ) or die "open failed";
and it always fails. this is with perl5.00402 binary distribution.
Do I need to use some Win32 extension package to talk to com ports? Or
does anyone have any solutions or recommendations or scripts that they can
share that are known to work under windows 95 (or at least NT)?
Any suggestions/help will be greatly appreciated.
Email replies are preferred.
Thanks!
kevin@kestrel.edu
------------------------------
Date: Thu, 11 Dec 1997 13:38:22 -0800
From: HenryM <henrym@image.com>
Subject: Perl mail attachments
Message-Id: <34905D53.FD9ADD27@image.com>
Hello,
I was wondering if someone has a snippet of code using Perl that shows
how to
send mail with attachments using "windmail" running under windows NT.
Thanks in
advance.
Please send email.
------------------------------
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 1457
**************************************