[10952] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4552 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 5 12:27:29 1999

Date: Tue, 5 Jan 99 09: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           Tue, 5 Jan 1999     Volume: 8 Number: 4552

Today's topics:
    Re: $0 as .//programName  ? (John Klassa)
    Re: $0 as .//programName  ? (David Cantrell)
        [OT] email address == passwd (Was: Re: OK I give up (Af <ludlow@us.ibm.com>
        A perl embedded C in netscape <leech6@ie.cuhk.edu.hk>
    Re: a problem! (Abigail)
    Re: BEGIN { local $/="\n" } clobbers global $/ (Abigail)
    Re: Downloading files : help !! (Bart Lateur)
        Embedding PERL in C & also C in PERL <partha@mihy.mot.com>
    Re: File Operations problem (Abigail)
    Re: fork under Win32 -- Activestate!? (Jeffrey R. Drumm)
    Re: fork under Win32 -- Activestate!? <njones@firstquadrant.com>
    Re: Getting at stderr (Andrew M. Langmead)
    Re: Getting at stderr (Tad McClellan)
        getting the dimensions of an Image <r2-d2@REMOVEbigfoot.com>
    Re: hash of hashes (Abigail)
        How do I delete tmp files based on age? diane6683@my-dejanews.com
    Re: How do I delete tmp files based on age? <jwarner@tivoli.com>
    Re: How do I delete tmp files based on age? (Randal L. Schwartz)
        I wanna learn Perl real good..but first <ilowe@interlog.com>
    Re: Installtion Problem: Compiler - 'B' for PERL <marius@funcom.com>
        Looking for Example PERL plotting/GUI package (Brian D. Schieber)
    Re: Make Gif/jpeg file <andrey@aer.ntu-kpi.kiev.ua>
    Re: New posters to comp.lang.perl.misc <newsposter@cthulhu.demon.nl>
    Re: newline <ljz@asfast.com>
    Re: newline dave@mag-sol.com
    Re: newline dave@mag-sol.com
    Re: OK I give up (After a WEEK!) dave@mag-sol.com
    Re: Path under windows (Clinton Pierce)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 5 Jan 1999 13:02:46 GMT
From: klassa@aur.alcatel.com (John Klassa)
Subject: Re: $0 as .//programName  ?
Message-Id: <76t2hm$hjf$1@aurwww.aur.alcatel.com>

On Mon, 04 Jan 1999 10:53:07 -0800, Xah Lee <xah@web-central.net> wrote:
  > Can someone explain that why $0 returns the program name with ".//"
  > prefixed?

It depends on how you call it...  For example:

	% ./foo
	--./foo--

	% foo
	--/homes/klassa/bin/foo--

You didn't say how you were executing yours.

  > GNU: helping the moronic unix community move forward.

For somebody who continues to come to a fairly Unix-oriented newsgroup for
help, your continued Unix-bashing is rather quizzical.

-- 
John Klassa / Alcatel / Raleigh, NC, USA / $perl_monger{Raleigh}[0] / <><


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

Date: Tue, 05 Jan 1999 16:00:28 GMT
From: NukeEmUp@ThePentagon.com (David Cantrell)
Subject: Re: $0 as .//programName  ?
Message-Id: <369236e7.1121584152@thunder>

On 5 Jan 1999 13:02:46 GMT, klassa@aur.alcatel.com (John Klassa)
enlightened us thusly:

>On Mon, 04 Jan 1999 10:53:07 -0800, Xah Lee <xah@web-central.net> wrote:
>
> > GNU: helping the moronic unix community move forward.
>
>For somebody who continues to come to a fairly Unix-oriented newsgroup for
>help, your continued Unix-bashing is rather quizzical.

Odd, I thought this was a perl-oriented newsgroup.  Perl is
cross-platform.

[Copying newsgroup posts to me by mail is considered rude]

-- 
David Cantrell, part-time Unix/perl/SQL/java techie
                full-time chef/musician/homebrewer
                http://www.ThePentagon.com/NukeEmUp


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

Date: Tue, 05 Jan 1999 09:14:44 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: [OT] email address == passwd (Was: Re: OK I give up (After a WEEK!))
Message-Id: <36922C64.F1AF729B@us.ibm.com>

Marc Austin wrote:
> if Joe loses his password, I want him to be able to request it again
> using a simple online form...
 
> Joe will submit his email address (requesting his lost password)
> the script will look to see if it's in  the temp.txt file.  if Joe
> Blows email address is in the text file then email joe his password...

Of course, this means that the passwords are now actually the email
addresses themselves.  Basically, if someone knows an email address,
they can get the password for free.  In other words, I wouldn't
recommend this system for anything that really needed to be password
protected in the first place.

-- 
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)


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

Date: Tue, 5 Jan 1999 22:24:16 +0800
From: HING <leech6@ie.cuhk.edu.hk>
Subject: A perl embedded C in netscape
Message-Id: <Pine.SOL.3.95.990105221828.7939G-100000@iesun60>

Hi all,
   
   i need to using perl on the netscape, and the perl call a C
program. The run-time of the C program is about 10 minute and it write
some data set for several file.
   my problem is when the perl is running, the c program can only write a
portion (less than 10%) then the the perl quite the c program and do the
remain part. can anyone tell me what the problem occurs, i can successful
run the perl in unix machine but why netscape cant??? does the running
time of C affect the result or the writing actions of C affect it??

regards,
Vincent Lee




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

Date: 5 Jan 1999 15:52:40 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: a problem!
Message-Id: <76tcg8$b9r$2@client3.news.psi.net>

_cim_ (cim@online.ee) wrote on MCMLII September MCMXCIII in
<URL:news:3691453b.4591145@news.online.ee>:
;; 
;; 1. What I need is to get a string up to the point where the first
;; space (empty line) occurs.
;; 2. I need to write this all to a html file, but these empty lines
;; should be replaced with <p>, or <p> should be inserted just
;; before/after/ the line.
;; 3. Now string from point 1. is written to another file.
;; 
;; PS. When this info is copied (from another application when filling
;; the form) it may be possible that these empty lines contain spaces or
;; tabs etc.


perl -pwe '/^\s*$/ and $_ = "<p>\n"' < file1 > file2



Abigail


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

Date: 5 Jan 1999 15:45:27 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: BEGIN { local $/="\n" } clobbers global $/
Message-Id: <76tc2n$b9r$1@client3.news.psi.net>

Alan Curry (pacman@defiant.cqc.com) wrote on MCMLIII September MCMXCIII
in <URL:news:yakk2.7$pS.39@news6.ispnews.com>:
++ In article <76saik$7sb$1@csnews.cs.colorado.edu>,
++ Tom Christiansen  <tchrist@mox.perl.com> wrote:
++ >
++ >    % perl5.00502 -le 'BEGIN {  print defined $/ }'
++ >    1
++ >
++ >What am I missing?  
++ 
++ Apparently it's thread-related. Some threading fanatic put a thread-enabled
++ perl binary package on contrib.redhat.com, and like an idiot I used it.


There's a reason why Perl is distributed in source form.



Abigail


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

Date: Tue, 05 Jan 1999 14:15:29 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Downloading files : help !!
Message-Id: <36a01a1a.8440050@news.skynet.be>

Sven Delmeiren wrote:

>print "Content-type: application/zip\n\n";
>open (DL, "<test.zip");
>   while (<DL>) {
>             print ();
>   }
>close (DL);

Ouch. You're reading/writing a binary file as text. Where is "binmode"
(both on DL and STDOUT)?

You'd be better of reading chunks of a few k at a time, using read (or
sysread).

>but, when the user gets the "Save as" window as to where he can save
>the file, it doesn't show test.zip as the filename for the file to be
>saved, but login2.cgi, the name of the cgi script. Can anyone tell me
>how I can let it show up the correct filename ??

Append the filename to your URL of the script, like

	http://server/.../login2.cgi/test.zip

This should work on most servers.

   HTH,
   Bart.


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

Date: Wed, 06 Jan 1999 17:42:20 +0530
From: Ramanujam Parthasarathi <partha@mihy.mot.com>
Subject: Embedding PERL in C & also C in PERL
Message-Id: <36935324.409BFC21@mihy.mot.com>

Hi,

Embedding PERL in C and vice-versa seem interesting. Can anyone suggest
where I can find some introduction to it - some sort of a book......

Thanks



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

Date: 5 Jan 1999 15:55:31 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: File Operations problem
Message-Id: <76tclj$b9r$3@client3.news.psi.net>

ed_c@my-dejanews.com (ed_c@my-dejanews.com) wrote on MCMLII September
MCMXCIII in <URL:news:76r1e9$9o6$1@nnrp1.dejanews.com>:
** 
** I'm writing a simple script that needs to delete and rename a file.  However,
** I keep getting a failure for both unlink and rename.  Neither seems to work. 

So? What does Perl say why it fails?



Abigail


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

Date: Tue, 05 Jan 1999 12:33:09 GMT
From: drummj@mail.mmc.org (Jeffrey R. Drumm)
Subject: Re: fork under Win32 -- Activestate!?
Message-Id: <369200bb.1700235369@news.mmc.org>

[ posted to comp.lang.perl.misc and a courtesy copy was mailed to the cited
author ]

On Mon, 04 Jan 1999 22:05:15 -0700, Richard Bateman <richardb@byu.edu> wrote:

>Hi... I'm fairly new to perl, and I've been working with CGIs a lot... I
>recently created a Web based email client, but now I'm trying to figure
>out how to do the server.  I seem to have run into a brick wall as far
>as spawning child processes to process the requests.  I figured out how
>to have a program wait on a port, in this case port 110, but only one
>person can connect to it at a time.  Does anybody know a way to work
>around the missing "fork" function in WindowsNT?  I don't know if I'll
>be able to check this, so if you could email me any input at
>"richardb@byu.edu" I'd really appreciate it.  If you can't, I will try
>to check for a reply later.

There's an example of a non-forking server in "The Perl Cookbook" by Tom
Christiansen and Nathan Torkington; it's in chapter 17, recipe 13. The
publisher is O'Reilly and Associates, ISBN 1-56592-243-3.

This book is outstanding . . . it belongs in every Perl programmer's library.

-- 
                               Jeffrey R. Drumm, Systems Integration Specialist
                       Maine Medical Center - Medical Information Systems Group
                                                            drummj@mail.mmc.org
"Broken? Hell no! Uniquely implemented!" - me


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

Date: Tue, 05 Jan 1999 06:10:26 -0800
From: Neil Jones <njones@firstquadrant.com>
To: Richard Bateman <richardb@byu.edu>
Subject: Re: fork under Win32 -- Activestate!?
Message-Id: <36921D52.1B1198A8@firstquadrant.com>

Oddly, I have the same problem but my goal is slightly different.

Anyway, Win32 doesn't really have a fork, though you can try using
Cygwin (from www.cygnus.com) which inserts a layer between the windows
kernel and your program that emulates POSIX, hence fork is available
on _some_ win32 platforms in perl.  In order to really use it, you'll have
to recompile perl (don't worry --- no Visual C++ required --- it uses
gcc for win32).  I was never able to get the cygnus makefile to work for
perl, however, so I didn't bother.

You can also create a multithreaded server.  For this, you'll need a
multithreaded
perl, compilable using gcc (mingw32).  The straight gcc compile went without

problems on winNT and win95.

Or, as is probably the case with the perl cookbook, there may be a
multiplexed
server (one that uses IO::Select).  Be aware, however, that this is not a
terribly
robust way of writing something like a mail server -- each cycle of the
multiplexing
loop needs to be very fast (hence, little processing can be done per
iteration)
in order for it to appear to respond quickly.

But...why not just use a freely available mail server?  I can understand
wanting
to write your own, but if you're trying to learn, Unix would be the better
platform
in my opinion.

 ..Neil

Richard Bateman wrote:

> Hi... I'm fairly new to perl, and I've been working with CGIs a lot... I
> recently created a Web based email client, but now I'm trying to figure
> out how to do the server.  I seem to have run into a brick wall as far
> as spawning child processes to process the requests.  I figured out how
> to have a program wait on a port, in this case port 110, but only one
> person can connect to it at a time.  Does anybody know a way to work
> around the missing "fork" function in WindowsNT?  I don't know if I'll
> be able to check this, so if you could email me any input at
> "richardb@byu.edu" I'd really appreciate it.  If you can't, I will try
> to check for a reply later.
>
> Thanx in advance,
>
> Richard Bateman
> Perl Beginner
> richardb@byu.edu




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

Date: Tue, 5 Jan 1999 12:33:32 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Getting at stderr
Message-Id: <F536vw.LuC@world.std.com>

"David Evans" <evs@sds.lcs.mit.edu> writes:

>I am trying to find a way to use the stderr output in a perl script.  For
>example, I want to do:

You might want to look at the FAQ entry "How can I capture STDERR from
an external command?" <URL:http://www.perl.com/CPAN/doc/manual/html
/pod/perlfaq8/How_can_I_capture_STDER_from_an.html>

-- 
Andrew Langmead


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

Date: Tue, 5 Jan 1999 07:55:40 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Getting at stderr
Message-Id: <sk5t67.a45.ln@magna.metronet.com>

David Evans (evs@sds.lcs.mit.edu) wrote:

: But get the command's <stderr> output instead of its stdout.

: Any suggestions?


   I would suggest checking the FAQ before posting.


   Perl FAQ, part 8:

      "How can I capture STDERR from an external command?"


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 5 Jan 1999 13:08:39 -0000
From: "Artoo" <r2-d2@REMOVEbigfoot.com>
Subject: getting the dimensions of an Image
Message-Id: <76t2ve$m2i$1@plug.news.pipex.net>

Hi All

Does anyone know how you can get perl to tell you the pixel dimensions of a
Jpeg image on the server?

Thanks for any help
Artoo




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

Date: 5 Jan 1999 16:00:56 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: hash of hashes
Message-Id: <76tcvo$b9r$4@client3.news.psi.net>

Ernesto Gianola (netog@ziplink.net) wrote on MCMLII September MCMXCIII in
<URL:news:369153FA.E1F6919E@ziplink.net>:
## Hello. I have a simple question.
## 
## In Perl you can assign a values to a hash of hashes as so.
## $hash{$key1}{$key2} = $value;
## 
## But is it possible to assign it mulitple values?

No. Everything in Perl has one value. And if you mean "can I assign
an array", the answer is no as well. `$hash {$key1} {$key2}' starts
with a `$', hence, it's a scalar.

## Why doesn't this work.
## 
## $hash{$key1}{$key2} = [@values]

What do you mean "it doesn't work"? It works for me. [@values] is a
scalar.



Abigail


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

Date: Tue, 05 Jan 1999 14:44:51 GMT
From: diane6683@my-dejanews.com
Subject: How do I delete tmp files based on age?
Message-Id: <76t8h2$57n$1@nnrp1.dejanews.com>

I've written a perl cgi that requires the use of temp files - a search is
performed, the results are put in a temp file, then the user accesses the
temp file to view selected groups of the results. The user might never look
at this file, or he might access it a dozen times. So, I thought I should
write something in the cgi to check the time of all the files in the temp
directory, and delete all that have been in there for more than a set amount
of time, say, 5 minutes. The temp files are named $ENV{'REMOTE_ADDR'} . time
 . '.tmp' (ie 184.412.99.25915546646.tmp) , so I was thinking that I can
somehow use the "time" part of the name, but I'm not sure how to use unix
commands in my perl script, and I'm not too familiar with unix commands.

Thanks much for any help!

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 05 Jan 1999 09:20:50 -0600
From: John Warner <jwarner@tivoli.com>
Subject: Re: How do I delete tmp files based on age?
Message-Id: <36922DD2.646F0952@tivoli.com>

You will want to do something like the following (adapted from the Perl Cookbook
p.319):

$dirname = 'some_directory';
$hold_time = 600; #Amount of time to hold ont .tmp file in seconds.
opendir(DIR, $dirname) or die "Oops.  Can't open dir $dirname. $!\n";
while (defined($file = readdir(DIR))){
    #9th item in list returned by stat is the last access time since epoch
    $last_access = stat($file)[8] + hold_time;
    if ($last_access > time) {unlink $file;}
}

 ...or something to that effect.  I assumed that all the files in the specified
directory are .tmp files you wish to get rid of at some point.  If that is not
correct, you will need to check the filename first.

HTH,

John Warner

diane6683@my-dejanews.com wrote:

> I've written a perl cgi that requires the use of temp files - a search is
> performed, the results are put in a temp file, then the user accesses the
> temp file to view selected groups of the results. The user might never look
> at this file, or he might access it a dozen times. So, I thought I should
> write something in the cgi to check the time of all the files in the temp
> directory, and delete all that have been in there for more than a set amount
> of time, say, 5 minutes. The temp files are named $ENV{'REMOTE_ADDR'} . time
> . '.tmp' (ie 184.412.99.25915546646.tmp) , so I was thinking that I can
> somehow use the "time" part of the name, but I'm not sure how to use unix
> commands in my perl script, and I'm not too familiar with unix commands.
>
> Thanks much for any help!
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own



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

Date: 05 Jan 1999 08:03:08 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: How do I delete tmp files based on age?
Message-Id: <m1zp7x4shv.fsf@halfdome.holdit.com>

>>>>> "John" == John Warner <jwarner@tivoli.com> writes:

John> You will want to do something like the following (adapted from the Perl Cookbook
John> p.319):

John> $dirname = 'some_directory';
John> $hold_time = 600; #Amount of time to hold ont .tmp file in seconds.
John> opendir(DIR, $dirname) or die "Oops.  Can't open dir $dirname. $!\n";
John> while (defined($file = readdir(DIR))){
John>     #9th item in list returned by stat is the last access time since epoch

The name $file here is relative to some_directory, so the following
stuff fails unless you add:

	$file = "some_directory/$file";

first.

John>     $last_access = stat($file)[8] + hold_time;

missing $ there

John>     if ($last_access > time) {unlink $file;}
John> }

But I think this would be simpler written as:

    $dirname = 'some_directory';
    opendir DIR, $dirname or die "...";
    unlink grep -A > $hold_time, map "some_directory/$_", readdir DIR;
    closedir DIR;

Then again, that could just be me. :)

print "Just another Perl hacker,"

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Tue, 05 Jan 1999 10:49:38 -0500
From: Iain Lowe <ilowe@interlog.com>
Subject: I wanna learn Perl real good..but first
Message-Id: <36923492.FBC1CF0F@interlog.com>

Hello Perl folks.

I've been dabbling in your dominion for awhile now, wanting to learn how
to do things -- mostly CGI / Web form processing. I've looked at lots of
tools and books, but I haven't found anything that really strikes my
fancy.

Currently, I use PerlBuilder on Win95 to develop pretty basic Perl form
processors, and then tweak them where I can. Most of the books I've
looked at only cover very simple forms, and spend most of their time
explaining how to break up the query string into key/value pairs--the
brain-dead stuff.

SO, does anybody know of good resources where I can learn to do things
like split a feedback form across a couple of pages without going all
the way through the Camel book (that'll come).

Thanks


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

Date: Tue, 05 Jan 1999 14:09:38 +0100
From: Marius Kjeldahl <marius@funcom.com>
Subject: Re: Installtion Problem: Compiler - 'B' for PERL
Message-Id: <36920F12.DC76B73F@funcom.com>

Ramanujam Parthasarathi wrote:
> 
> Hi,
> 
> I was trying to install the 'C' compiler for PERL - 'B'. The PERL
> version is:5.005_02. The Compiler version is :a3. I got the following
> errors when I was trying to 'make':

I'm no expert, but I believe that the compiler comes with perl 5.005 by
default. However, other posting have said that this compiler is broken
(does not work with modules), so if you want to compile anything you
should downgrade to 5.004 and use the latest version of the compiler for
that perl version (which I think was a3).

In the meanwhile I'm waiting for a new 5.005 release..

Marius


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

Date: 5 Jan 1999 15:05:22 GMT
From: schieb@seabass.gsfc.nasa.gov (Brian D. Schieber)
Subject: Looking for Example PERL plotting/GUI package
Message-Id: <76t9ni$apu@post.gsfc.nasa.gov>


Hi,
 I'd like to see what it would take to put together a 
simple plotting package in PERL. Are there any example
PERL packages out there that have:

* A GUI interface
* Can plot simple XY plots and/or log-linear line plots

Thanks in advance,

--Brian, wannabee PERL weenie

| Brian D. Schieber / SAIC General Sciences Corp.
| SeaWiFS Project / NASA Goddard Space Flight Center 
| Code 970.2, Greenbelt, MD 20771
| schieb@seabass.gsfc.nasa.gov / (301) 286-1440
| http://seabass.gsfc.nasa.gov/~schieb/home_page.html



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

Date: 5 Jan 1999 15:04:38 GMT
From: "Andrey W. Ohrimenko" <andrey@aer.ntu-kpi.kiev.ua>
Subject: Re: Make Gif/jpeg file
Message-Id: <76t9m6$et1$1@oberon.ntu-kpi.kiev.ua>

Frank de Bot <debot@xs4all.nl> wrote:
> How can I make with a perlscript from 2 files (1.gif and 2.gif) one
> image with Perl? I've downloaded some counters that do that, but I still
> don't know how it works. Please give a simple example
You can use Fly Program... It's can return to browser GIF image..
I'd like it :)

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

		+----------------------------------+
		|   Andrey Ohrimenko AKA Arhip     |
		| mail: andrey@aer.ntu-kpi.kiev.ua |
		|         UIN :#6489392		   |
		+----------------------------------+


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

Date: Tue, 05 Jan 1999 10:56:15 -0500
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: New posters to comp.lang.perl.misc
Message-Id: <3692361E.946AD464@cthulhu.demon.nl>

ruben@wynn.com wrote:
> 
> What is OCR and why am I being picked on here?

In the first paragraph of the article you posted you could have
read what OCR means.

>     - Original Content Rating (OCR) is the ratio of the original content
>       volume to the total body volume.

I bet your OCR will be low in the next monthly post, since you quoted
a lot, with only a few lines original content ...

Erik
-- 
Sure, doesn't everyone sign up for internet service so as to have
their mailbox stuffed with megabytes of postage-due rubbish every day?
Absolutely.  And everyone who owns a car intends that it be used as a
portable dumpster.  Any unwanted garbage in their vehicle they can
simply throw away, after all.


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

Date: 05 Jan 1999 09:26:47 -0500
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: newline
Message-Id: <ltsodp7q3c.fsf@asfast.com>

"Geir Magnusson Jr." <gmj@netaxis.com> writes:

> Herger Peter wrote:
> > 
> > [ ... ]
> > 
> > But in the second last line, there is a problem. The variable $storedir
> > always includes a \n at the end. How can I suppress this \n ?
> 
> you are getting the extra newline from the date command.
> 
> chop $storedir;
>
> You might want to do the same for $date for completeness.

Yes, but also ...

In Perl5, it's better to use `chomp' instead of `chop'.  The `chop'
function strips off the rightmost character of a string no matter
what, while `chomp' strips it only if it's an end-of-line character.

It's best to use `chop' only in special cases where the final character
of a string needs to be removed irrespective of its value.  In the
"get rid of the trailing newline" case, `chomp' is usually preferred.

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -le '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x"'


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

Date: Tue, 05 Jan 1999 16:16:11 GMT
From: dave@mag-sol.com
Subject: Re: newline
Message-Id: <76tds8$ad4$1@nnrp1.dejanews.com>

In article <3691D936.1253AC2F@swisslife.ch>,
  Herger Peter <peter.herger@swisslife.ch> wrote:
> Hi all
>
> I've wrote a script like the following.
>
> #!/usr/bin/perl -w
> ######################################################################
> # (c) Herger Peter 29.12.98  peter.herger@swisslife.ch
> #This script gets the configfiles ones per week from the first
> #device on each router and stores it on
> su8000/usr/net/routers/rtconfigs/
> #
> ######################################################################
>
> use Net::FTP;
> $date     = `date '+%m%d'`;
> $storedir = `date '+log%m%d'`;
>
> `mkdir /usr/net/routers/rtconfigs/$storedir`;
>
> #**************************** wfhgtv1 ********************************
> $dir      = "1:";
> $host     = "wfhgtv1";
>
> $ftp = Net::FTP->new($host, Timeout => 60) ||
>     die "Cannot connect: $host";
>
> $ftp->login("Manager", "mars97ib") || die "Login failed";
>
> $ftp->cwd($dir) || die "Directory $dir doesn't exist";
> $ftp->binary();
> $ftp->get("config" ,
> "/usr/net/routers/rtconfigs/$storedir/confhgtv1.$date");
>
> $ftp->quit();
> #********************************************************************
>
> But in the second last line, there is a problem. The variable $storedir
> always includes a \n at the end. How can I suppress this \n ?

$date will also have a newline on the end. This is because the outout from the
Unix date command always has a newline at the end.

perldoc -f chomp

may point you in the right direction.

hth,

Dave...

--
Dave Cross
Magnum Solutions Ltd: <http://www.mag-sol.com/>
London Perl M[ou]ngers: <http://london.pm.org/>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 05 Jan 1999 16:18:45 GMT
From: dave@mag-sol.com
Subject: Re: newline
Message-Id: <76te13$aeh$1@nnrp1.dejanews.com>

In article <3691F2B4.B3B76359@netaxis.com>,
  "Geir Magnusson Jr." <gmj@netaxis.com> wrote:
> Herger Peter wrote:
> >
> > Hi all
> >
> > I've wrote a script like the following.
> >
> > #!/usr/bin/perl -w
> > ######################################################################
> > # (c) Herger Peter 29.12.98  peter.herger@swisslife.ch
> > #This script gets the configfiles ones per week from the first
> > #device on each router and stores it on
> > su8000/usr/net/routers/rtconfigs/
> > #
> > ######################################################################
> >
> > use Net::FTP;
> > $date     = `date '+%m%d'`;
> <snip>
> > "/usr/net/routers/rtconfigs/$storedir/confhgtv1.$date");
> >
> > $ftp->quit();
> > #********************************************************************
> >
> > But in the second last line, there is a problem. The variable $storedir
> > always includes a \n at the end. How can I suppress this \n ?
>
> you are getting the extra newline from the date command.
>
> chop $storedir;
>
> You might want to do the same for $date for completeness.

chomp is generally safer than chop.

Dave...

--
Dave Cross
Magnum Solutions Ltd: <http://www.mag-sol.com/>
London Perl M[ou]ngers: <http://london.pm.org/>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 05 Jan 1999 16:05:43 GMT
From: dave@mag-sol.com
Subject: Re: OK I give up (After a WEEK!)
Message-Id: <76td8l$9qa$1@nnrp1.dejanews.com>

In article <76snub$9u$1@penthesilea.Materna.DE>,
  Juergen.Puenter@materna.de (J|rgen P|nter) wrote:
> In article <placeit-0401992224420001@blv-lx100-ip18.nwnexus.net>,
> placeit@easyad.com says...
> >
> >
> >#!/usr/bin/perl
>
> Using perl -w is always a good idea.
>
> >foreach (@keyemail)  {
> >
> >($field1,$field2) = split(/\\t/);
> >
> >   if ($field2 = $email) {   #changed this
> >     $email_found = 1;
> >   }
> >}
>
> Here's the problem. The foreach doesn't stop checking each
> line of @keyemail once it has found a match. It just sets
> $email_found to 1 and continues with the next line. When
> it is done with @keyemail, you have the contents of the last
> line in $field1 and $field2 - regardless of where the match
> occured.
>
> You could just add something like
> 	$matched_password = $field1;
> after
> 	$email_found = 1;
> and 'remember' the correct password that way. Modify the
> rest of your script accordingly and it should work (didn't
> test it).
>
> Oh, BTW, shouldn't that be
> 	if ($field1 = $email) {
>                   ^
> instead of
> 	if ($field2 = $email) { ?

 ...and in all cases it should be 'eq' (or possibly '==') in place of '=' in
the if conditions.

Dave...

--
Dave Cross
Magnum Solutions Ltd: <http://www.mag-sol.com/>
London Perl M[ou]ngers: <http://london.pm.org/>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 05 Jan 1999 14:44:39 GMT
From: cpierce1@mail.ford.com (Clinton Pierce)
Subject: Re: Path under windows
Message-Id: <36972240.2497226447@news.ford.com>

On Mon, 04 Jan 1999 15:50:51 -0600, John Warner <jwarner@tivoli.com>
wrote:
>An interesting problem.  Are you sure they can install the ActiveState build?  It
>certainly would make life easier.  If you absolutely have to do this the hard way
>there are a couple of approaches.

No.  These are Microsofties.  Remember that at least 50% of ISP's are
run by scared-shitless, clueless idiots, who couldn't admin their way
out of a paper bag.  They saw the "Make Big Money as an Internet Service
Provider" in the back of a magazine, and sent away for equipment.

use Sarcasm qw(:dripping);
Installing ActiveState would violate their Microsoft license.  
Or something.

>First, if they have a C compiler on the machine,
>have them download and install the CGI module off CPAN.  The installation procedure
>should be substantially similar to that used on Unix.

I've bought my clues, and this isn't as easy as it sounds.  Not at all.
I'd volunteer to give them a Perl build with all the good modules, but I
don't pay for software and I don't have a copy of NT or a C compiler for
Windows 9x laying around.  (And frankly, under Win9x CygWin is useless.)

>If all else fails, you can
>copy the .pm files from the distribution to replace the existing .pm files of the
>same names.  (Make a backup of your originals first!)  I've installed modules both
>ways.  The second method is certainly harder because of the verification testing
>needed to ensure the new .pm files are functioning properly.

This would require them to put files into the directories where Perl is
installed on the NT server.  Again, for distribution/portability this is
wholly inadaquate.  It would be easier to build a custom Perl, and give
them an Install-Sheilded EXE to re-install Perl with.  (Except that
building Perl with freeware tools is an exercise in insanity.)

>One alternative I can think of right off is to install Timbuktu on both your Unix

I'll look at Timbuktu.

>However, the best advice is to have them upgrade to the ActiveState build.  From
>what you describe, your client also needs some educating about basic NT
>operation/administration.

My analysis of what these ISP's are thinking: 

They're running their site By The Book.  Perl came with Windows
NT--that's the Perl we use.  A CGI program is just that--a program.  Not
a whole suite of modules.  ASP doesn't require modules to be wholly
functional, why should Perl?



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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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