[16853] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4265 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 8 18:10:46 2000

Date: Fri, 8 Sep 2000 15:10:29 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <968451028-v9-i4265@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 8 Sep 2000     Volume: 9 Number: 4265

Today's topics:
        How to save uploaded binaries to a named file? <kenn_mar@hotmail.com>
    Re: How to save uploaded binaries to a named file? <care227@attglobal.net>
    Re: INTERNATIONAL PERL TELECOMMUTING (Jynx)
    Re: Is HP finally recognizing Perl??? (Greg Andrews)
    Re: Is HP finally recognizing Perl??? <brian+usenet@smithrenaud.com>
    Re: Is HP finally recognizing Perl??? <lr@hpl.hp.com>
    Re: Last day of month <stephenk@cc.gatech.edu>
    Re: Last day of month (Craig Berry)
    Re: Last day of month (Logan Shaw)
    Re: Last day of month (Abigail)
    Re: Last day of month (Craig Berry)
    Re: Last day of month (Craig Berry)
    Re: Last day of month (Abigail)
        looking for PERL class in NYC <jeff@in2.com>
    Re: Multiple socket <tzz@iglou.com>
    Re: Multiple socket <bkennedy@hmsonline.com>
        Need Help! OK Who wants to laugh at my first perl attem <sysnovice@my-deja.com>
        Newbie needs help rtm7@my-deja.com
    Re: Newbie needs help (Mark-Jason Dominus)
    Re: Newbie needs help <lr@hpl.hp.com>
        Perl & https & proxy andras_kovacs2@non.agilent.com
        Perl fail test 19  (great_circle_distance in test trig. <fauvel@inrs-telecom.uquebec.ca>
        Perl script hogging memory on IRIX 6 <bw2@nospam.y12.doe.gov>
        Recognizing wrapped lines awr@cpu.com
        Regular Expressions armstrongc@my-deja.com
    Re: Scoping of symbolic references (variables) (Mark-Jason Dominus)
        Simple Question <akira.kiyomiya@autodesk.com>
    Re: Simple Question <jeffp@crusoe.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 09 Sep 2000 08:48:48 +1200
From: Ken <kenn_mar@hotmail.com>
Subject: How to save uploaded binaries to a named file?
Message-Id: <39B950B0.45421609@hotmail.com>

Hi all,

I used CGI.pm to upload files on web page. However, uploaded files are
always named CGItemp-*********. Why is that so? Maybe I should read in
the binary data into another named file but how? Any pointers/solutions
are most welcomed.

-Ken



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

Date: 08 Sep 2000 21:03:15 GMT
From: Drew Simonis <care227@attglobal.net>
Subject: Re: How to save uploaded binaries to a named file?
Message-Id: <39B951AA.C22428FF@attglobal.net>

Ken wrote:
> 
> Hi all,
> 
> I used CGI.pm to upload files on web page. However, uploaded files are
> always named CGItemp-*********. Why is that so? Maybe I should read in
> the binary data into another named file but how? Any pointers/solutions
> are most welcomed.

This is all covered in the CGI documentation...

$ perldoc CGI


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

Date: 08 Sep 2000 20:37:49 GMT
From: X@Y.Z.net (Jynx)
Subject: Re: INTERNATIONAL PERL TELECOMMUTING
Message-Id: <slrn8rijgs.bmb.X@animas.frontier.net>

On 6 Sep 2000 18:02:08 -0500, TelecommutePERL@GlobalWorkInt.com scribbled:

>             WEB PAGE PROGRAMMER
 -- snip  --
>$15.00 to $25.00 per hour commensurate with experience.

I'll pass this along to the fella that mows my lawn -- that's
what he makes now.  But, maybe he'd like to work indoors...

Jonesy
-- 
Marvin L Jones         |  jonz             |  W3DHJ     |  OS/2
 Gunnison, Colorado    |   @               |  Jonesy    |  linux    __
  7,703' -- 2,345m     |    frontier.net   |  DM68mn                SK


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

Date: Fri, 08 Sep 2000 18:15:01 GMT
From: gerg@ncal.verio.com (Greg Andrews)
Subject: Re: Is HP finally recognizing Perl???
Message-Id: <8pba7p$mj2$1@ncal.verio.com>

davidkrainess@yahoo.com (David Krainess) writes:
>I just got a course catalog and sure enough and under HP-UX operations 
>there is a course H4311S, Perl Programming, 4 days, $4,000.
>
>We have the lastest HP-UX OS 10.20 patch installed and look at this:
>
># /usr/contrib/bin/perl -v
> 
>This is perl, version 4.0
> 
>$RCSfile: perl.c,v $$Revision: 4.0.1.8 $$Date: 1993/02/05 19:39:30 $
>Patch level: 36
> 
>Copyright (c) 1989, 1990, 1991, Larry Wall
> 
>
>I guess I'm a little confused how they could teach a course if they still 
>use 4.0.1.8 and haven't incorporated the new version into their software.
>

It all becomes clear now.  Godzilla is a PHB at HP!!

  -Greg


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

Date: Fri, 08 Sep 2000 14:57:49 -0400
From: brian d foy <brian+usenet@smithrenaud.com>
Subject: Re: Is HP finally recognizing Perl???
Message-Id: <brian+usenet-151BD9.14574908092000@news.panix.com>

In article <8FA96864Adavidkrainessyahooco@38.8.213.2>, 
davidkrainess@yahoo.com (David Krainess) wrote:

> I just got a course catalog and sure enough and under HP-UX operations 
> there is a course H4311S, Perl Programming, 4 days, $4,000.
> 
> We have the lastest HP-UX OS 10.20 patch installed and look at this:
> 
> # /usr/contrib/bin/perl -v
>  
> This is perl, version 4.0

> I guess I'm a little confused how they could teach a course if they still 
> use 4.0.1.8 and haven't incorporated the new version into their software.

what the course teaches, what HP uses internally, and what they ship 
with the operating system are different things.  they do not depend
on each other.  HP is a big company, after all.

-- 
brian d foy


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

Date: Fri, 8 Sep 2000 12:00:18 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Is HP finally recognizing Perl???
Message-Id: <MPG.1422d7187abac65898ad45@nntp.hpl.hp.com>

In article <8FA96864Adavidkrainessyahooco@38.8.213.2> on Fri, 08 Sep 
2000 17:18:36 GMT, David Krainess <davidkrainess@yahoo.com> says...
> I just got a course catalog and sure enough and under HP-UX operations 
> there is a course H4311S, Perl Programming, 4 days, $4,000.
> 
> We have the lastest HP-UX OS 10.20 patch installed and look at this:
> 
> # /usr/contrib/bin/perl -v
>  
> This is perl, version 4.0
>  
> $RCSfile: perl.c,v $$Revision: 4.0.1.8 $$Date: 1993/02/05 19:39:30 $
> Patch level: 36
>  
> Copyright (c) 1989, 1990, 1991, Larry Wall
>  
> 
> 
> I guess I'm a little confused how they could teach a course if they still 
> use 4.0.1.8 and haven't incorporated the new version into their software.

You are confusing the perl bundled with the OS (evidently used by some 
build or initialization procedures) with the perl used to teach this 
class.  HP similarly bundles a dain-bramaged version of the C compiler, 
which is virtually useless for real work.

The course description mentions the CGI and Tk modules, and has a unit 
called 'Advanced Data Structures' that includes references in the list 
of topics.  Seems to require Perl 5, no?

A 1999 version of this course was described thus:

  Introduction to Perl Programming
  Instructor: Tom Christianson (sic!)
  3 days (with Lab) -- May 18 - 20
  ... 

I doubt that TomC would teach using Perl 4.036.

Time to put this particular slander to rest.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 08 Sep 2000 14:03:29 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: Last day of month
Message-Id: <39B929F1.92693FE7@cc.gatech.edu>

Craig Berry wrote:

> Stephen Kloder (stephenk@cc.gatech.edu) wrote:
> : If the day length changes, localtime() will become inaccurate and in need of an
> : upgrade.  Until then, localtime() has every day for the next 100 years as exactly
> : 24 hours long, with the exception of 2 days a year (which are not at the end of
> : the month).
>
> The point is that the government in any given country could move DST to
> the last day of the month at any moment, and that locale-respecting
> programs would then do the same.  Never make the correctness of your code
> dependent on legislators behaving rationally.

Good point.  I suppose you could use the $isdst fields to determine whether to add or
subtract an hour when calculating tomorrow's date/time.

P.S. Is this an appropriate time to bring up http://www.standardtime.com/ ?

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: Fri, 08 Sep 2000 18:28:07 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Last day of month
Message-Id: <sribtn4pljn61@corp.supernews.com>

Larry Rosler (lr@hpl.hp.com) wrote:
: Leap seconds are so rare that there aren't any at all, in any of the 
: standard computer epoch time scales.  Unix epoch time and astronomical 
: time are now about half a minute apart, and drifting further.

Those who care about such things distinguish between Ephemeris Time (ET),
which proceeds smoothly at 86,400 seconds per day without reference to any
external phenomena, and UTC, which is intended to match the Earth's
rotation and must therefore occasionally be corrected with leap seconds
due to small, aperiodic inconsistencies in that rotation.  The difference
between the two is called "Delta T", and is currently around half a
minute, as Larry mentions.

Given the way most computer systems are managed, the "Unix epoch time"  as
measured in time_t isn't really the Unix epoch time (count of seconds
since the epoch origin, Jan 0 1970*).  Instead, most sysadmins synchronize
the system clock to match current UTC, meaning that they are using an
effective epoch origin half a minute away from Jan 0 1970.  For most
purposes, this makes sense, but given that such synchronization will
likely be done over and over (once or more per day, quite commonly), you
can't reliably count seconds between two timestamps which cross a leap
second insertion point. This matters for some applications. 

* "Jan 0 1970" is chronological shorthand for the midnight at the
beginning of Jan 1 1970**.

** Unless you're an astronomer. :)

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Every force evolves a form."
   |              - Shriekback


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

Date: 8 Sep 2000 13:39:58 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Last day of month
Message-Id: <8pbbpu$gh4$1@provolone.cs.utexas.edu>

In article <39B929F1.92693FE7@cc.gatech.edu>,
Stephen Kloder  <stephenk@cc.gatech.edu> wrote:
>Good point.  I suppose you could use the $isdst fields to determine whether to add or
>subtract an hour when calculating tomorrow's date/time.

Except that it's not necessarily always going to be an hour.  Plus, if
you're going to calculate all that, you might as well just calculate
how many days there are in the current month, which is as easy as a
lookup for 11 of the months and which requires only three conditions
for February.  Or if you're really lazy, just parse the output of "cal"
and determine the last day of the month from there.

  - Logan


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

Date: 08 Sep 2000 18:40:07 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Last day of month
Message-Id: <slrn8ricid.vlt.abigail@alexandra.foad.org>

Craig Berry (cberry@cinenet.net) wrote on MMDLXV September MCMXCIII in
<URL:news:sri99g8qljn144@corp.supernews.com>:
__ 
__ The point is that the government in any given country could move DST to
__ the last day of the month at any moment, and that locale-respecting
__ programs would then do the same.  Never make the correctness of your code
__ dependent on legislators behaving rationally.


For that matter, they might decide all months will have 25 days, and
dates will be primes.



Abigail
-- 
map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;        
print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";


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

Date: Fri, 08 Sep 2000 18:40:41 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Last day of month
Message-Id: <sricl9a1ljn152@corp.supernews.com>

Stephen Kloder (stephenk@cc.gatech.edu) wrote:
: Good point.  I suppose you could use the $isdst fields to determine whether to add or
: subtract an hour when calculating tomorrow's date/time.

Yeah, but then you'd have to worry about when the transition occurs...no
physical law says that has to be 2am everywhere, either.  On the whole, I
prefer solutions that avoid the whole DST issue, like the various "add one
day to the day-of-month field, reencode, and see if it's the first"
solutions (including my own).

: P.S. Is this an appropriate time to bring up http://www.standardtime.com/ ?

Intriguing.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Every force evolves a form."
   |              - Shriekback


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

Date: Fri, 08 Sep 2000 18:50:34 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Last day of month
Message-Id: <srid7qm0ljn153@corp.supernews.com>

Abigail (abigail@foad.org) wrote:
: Craig Berry (cberry@cinenet.net) wrote on MMDLXV September MCMXCIII in
: <URL:news:sri99g8qljn144@corp.supernews.com>:
: __ 
: __ The point is that the government in any given country could move DST to
: __ the last day of the month at any moment, and that locale-respecting
: __ programs would then do the same.  Never make the correctness of your code
: __ dependent on legislators behaving rationally.
: 
: For that matter, they might decide all months will have 25 days, and
: dates will be primes.

Clearly you're familiar with the California state legislature. :)

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Every force evolves a form."
   |              - Shriekback


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

Date: 08 Sep 2000 20:26:36 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Last day of month
Message-Id: <slrn8riipu.vlt.abigail@alexandra.foad.org>

Craig Berry (cberry@cinenet.net) wrote on MMDLXV September MCMXCIII in
<URL:news:sribtn4pljn61@corp.supernews.com>:
,, Larry Rosler (lr@hpl.hp.com) wrote:
,, : Leap seconds are so rare that there aren't any at all, in any of the 
,, : standard computer epoch time scales.  Unix epoch time and astronomical 
,, : time are now about half a minute apart, and drifting further.
,, 
,, Those who care about such things distinguish between Ephemeris Time (ET),
,, which proceeds smoothly at 86,400 seconds per day without reference to any
,, external phenomena, and UTC, which is intended to match the Earth's
,, rotation and must therefore occasionally be corrected with leap seconds
,, due to small, aperiodic inconsistencies in that rotation.  The difference
,, between the two is called "Delta T", and is currently around half a
,, minute, as Larry mentions.
,, 
,, Given the way most computer systems are managed, the "Unix epoch time"  as
,, measured in time_t isn't really the Unix epoch time (count of seconds
,, since the epoch origin, Jan 0 1970*).  Instead, most sysadmins synchronize
,, the system clock to match current UTC, meaning that they are using an
,, effective epoch origin half a minute away from Jan 0 1970.  For most
,, purposes, this makes sense, but given that such synchronization will
,, likely be done over and over (once or more per day, quite commonly), you
,, can't reliably count seconds between two timestamps which cross a leap
,, second insertion point. This matters for some applications. 

If a synchronization is done one or more per day, it has *nothing* to do
with matching UTC, but all with inaccurate system clocks. There are only
two moments a year when UTC and the Unix epoch might drift futher apart
(or get closer to each other): Dec 31 23:59:60 and Jun 30 23:59:60.

Interestingly enough, while (in Unix/C) localtime() will pay attention to
leap seconds, the struct it returns allows for leap seconds....

Here's some more information.

  UT  Universal time. One of either UT0, UT1, or UT2, but usually UT2.

  UT0 is local solar time on the zero meridian (Greenwich, UK).

  UT1 is UT0 corrected for "Chandler wobble", which is caused by the 
      wandering of the Earth poles in small circles. UT1 is used in 
      space navigation.

  UT2 is a better corrected version of UT0 that takes seasonal variations
      in effect.

UT0, UT1 and UT2 are usually not further apart than 0.03 seconds.

  TAI (Temps Atomique International) is defined by worldwide network of
      atomic clocks. TAI is unrelated to any astronomical events. It
      has no lead seconds, and is the most uniform time scale we currently
      have available. This seems to be the time Craig was referring to
      (as opposed to ET defined below).

  UTC (Coordinated Universal Time) UTC will always differ an integral number
      of seconds from TAI, and at most 0.9 seconds from UT1. If UTC is about
      to drift further apart from UT1, a leap second is introduced (or removed,
      but that has never happened yet). In the late 1950s, shortly after
      introducing TAI, TAI and UTC were indentical (except that UTC was
      introduced in the early 1970s). To be fully pedantic, one can put
      the organization who defines the used UTC in parens behind UTC.
      The different UTCs vary in a few nanoseconds.

  ET  (Ephemeris Time). Introduced in 1960 for astronomical purposes.
      It compensates for variations in the Earths rotation. In the 19th
      century, ET closely matches UT, but currently, ET almost exactly
      one minute ahead of UT. In 1984, ET was replaced by Dynamical Time
      and TT.

  TT and Dynamical Time: Replaces ET as a uniform astronomical time scale,
      correcting for relativistic effects. There are two kinds of Dynamic
      Time: TDT (Terrestrial Dynamical Time) which is tied to Earth, and
      TDB (Barycentric Dynamical Time) which is tied to the barycenter
      of the Solar System. The difference of TDT and TDB is always smaller
      than a few milliseconds. If the difference is not important, TDT is
      referred to as TT. Most of the time, TDT can be considered to be
      TAI + 32.184.
  
The last leap second was in December 1998, the 22nd since 1972. There's
no leap second sceduled for December 2000.

Delta-T, which is the difference between TT and UT1 is currently about 64
seconds. UT1 - UTC is about 0.15 seconds, and UT1 - TAI about -32 seconds.
UT2-UT1 = 0.022 sin (2 * pi * T) - 0.012 cos (2 * pi * T) -
          0.006 sin (4 * pi * T) + 0.007 cos (4 * pi * T),
where T, the Besselian date, is given by
T = 2000.000 + (MJD - 51544.03) / 365.2422, with MJD being the Modern Julian
Day, or Julian Date - 2,400,000.5 days.



Abigail
-- 
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print 
               qq{Just Another Perl Hacker\n}}}}}}}}}'    |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w


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

Date: Fri, 08 Sep 2000 19:56:52 GMT
From: Jeff Kolber <jeff@in2.com>
Subject: looking for PERL class in NYC
Message-Id: <39B94302.AF962CB6@in2.com>

Hi

I am hoping someone can recommend a good place for some intro PERL classes in the NYC area. These would be for someone with just a little bit of programming background and a great willingness to
learn.

Please cc me (jeff@in2.com) as I am (shamed to admit) not a regular reader.

Thanks

-- 
Jeff Kolber   |  Director of Production
In2 | 205 Hudson Street 7th Floor 10013
jeff@in2.com


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

Date: 8 Sep 2000 14:47:38 -0500
From: Ted Zlatanov <tzz@iglou.com>
Subject: Re: Multiple socket
Message-Id: <968438290.5979@iglou.com>

In article <8paqbj$kuu$1@nnrp1.deja.com>, Ville Mattila wrote:
>I'm looking for a way how I could make a some kind of server software
>with Perl. I have found the system of sockets etc, but as I have tried,
>it can handle only one session by once. Is there any solution to handle
>multiple ones?
>
>Or, is it possible to make one always on -socket and then "temporarily"
>sockets as a server?

You can use the CPAN NetServer::Generic module with the "forking" model, or
you can write your own using IO::Socket::INET (standard with 5.6.0).  The
module documentation in either case has enough information to get you
started, but I would strongly recommend a book like "UNIX Network
Programming" by Stevens to learn more about sockets and writing network
applications in general.

Also, you could use inetd on a UNIX system, consult "man inetd."  But that's
overkill usually.

-- 
Teodor Zlatanov <tzz@iglou.com>
"Brevis oratio penetrat colos, longa potatio evacuat ciphos." -Rabelais


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

Date: Fri, 08 Sep 2000 19:53:09 GMT
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: Multiple socket
Message-Id: <Fsbu5.16072$AW2.206149@news1.rdc2.pa.home.com>


"Ville Mattila" <ville.mattila@nettipaa.fi> wrote in message
news:8paqbj$kuu$1@nnrp1.deja.com...
> I'm looking for a way how I could make a some kind of server software
> with Perl. I have found the system of sockets etc, but as I have tried,
> it can handle only one session by once. Is there any solution to handle
> multiple ones?
>
> Or, is it possible to make one always on -socket and then "temporarily"
> sockets as a server?

I've found that the Perl Cookbook published by O'Reilly (Ram on cover) has
good networking examples.  You should investigate the IO::Select and
IO::Socket modules, which in included in standard Perl distribution.

--Ben Kennedy




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

Date: Fri, 08 Sep 2000 21:47:41 GMT
From: Greg Donovan <sysnovice@my-deja.com>
Subject: Need Help! OK Who wants to laugh at my first perl attempt?
Message-Id: <8pbmpm$oge$1@nnrp1.deja.com>

Ok here it goes! Let me have it! What am I doing wrong? Boy is that a
loaded question. Please be kind and just give me a few pointers. Keep in
mind this is my first attempt at any kind of code at all. I sincerly
would appreciate your guru critiques.

Well it almost works. It sends the file name of the mail message to the
forwarding address not the contents. When I use /usr/lib/sendmail -odg
gdonovan@gregsmail.com < 20000907161927.AAA.7aa556d9 on the command line
it works but not in the program.

Thanks for your help
G.Donovan

************************************************************************
#!/usr/bin/perl -w
#forward.pl
use strict;


# forward.pl: a very simple mail forwarding application.
#    This program asks for a mailbox and forwarding address
#    and sends any remaining mail in the mailbox to the
#    forwarding address specified.


while(1) { # Loop forever
my $messages = 0;
my $MAILBOX;
my $letters;
print "\nPlease enter the userID of the mailbox you want to forward, " .
    " or quit (q):\n ";

$MAILBOX= <STDIN>;

    chomp($MAILBOX);
    $MAILBOX =~ tr/A-Z/a-z/;
    # Check if they want to quit
    if($MAILBOX eq 'q') { last }
    opendir(BIN, "/var/spool/mailbox/$MAILBOX/inbox") || die "Can not
find mailbox for " .
"$MAILBOX.: $! \n";
    while(defined ($letters = readdir BIN)) {
    next if $letters =~ /^\.\.?$/;
    next if $letters =~ /[__]/;
    $messages = $messages + 1;
    }
    if ($messages == 0) {print "No messages found in mailbox.\n"; }
    else { print "$messages messages found in $MAILBOX\'s mailbox.\n"}

    closedir(BIN);
#ask for mail address to forward mail to.

print "\nWhat address would you like to forward $MAILBOX\'s messages to?
\n" ;

    my $DESTADD = <STDIN>;
    chomp($DESTADD);
    opendir(BIN, "/var/spool/mailbox/$MAILBOX/inbox") || die "Can not
find mailbox for " .
"$MAILBOX.: $! \n";
my $MessagesSent;
    while(defined ($letters = readdir BIN)) {
    next if $letters =~ /^\.\.?$/;
    next if $letters =~ /[__]/;
    open(SENDMAIL, "|/usr/lib/sendmail -odg $DESTADD") || die "Can't
fork for sendmail: $!\n";
    print SENDMAIL ($letters);
    close(SENDMAIL);
}
}
    closedir(BIN);
print "program completed.\n";


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 08 Sep 2000 21:32:56 GMT
From: rtm7@my-deja.com
Subject: Newbie needs help
Message-Id: <8pblu7$nl7$1@nnrp1.deja.com>

Hi all :

I have never used Perl before and at work, I need to write a simple
script that will take a file as input, look for a specific string
within that like and replace that with another string input at the
command line and write the output to another file. Can anyone help?

Inputs are "String2" (string to replace with) and FILE1 (file to be
read).

Look for "String1" (string to be replaced in FILE1) and replace
with "String2". Write output to FILE2.

Thanks in advance


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 8 Sep 2000 21:50:18 GMT
From: mjd@red.seas.upenn.edu (Mark-Jason Dominus)
Subject: Re: Newbie needs help
Message-Id: <8pbmuq$su3$1@netnews.upenn.edu>

In article <8pblu7$nl7$1@nnrp1.deja.com>,  <rtm7@my-deja.com> wrote:
>I need to write a simple script that will take a file as input, look
>for a specific string within that like and replace that with another
>string input at the command line and write the output to another
>file. Can anyone help?

Try

	perl -pe 's/STRING1/STRING2/g' FILE1 > FILE2

And try getting a book about Perl and reading it.


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

Date: Fri, 8 Sep 2000 14:57:21 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Newbie needs help
Message-Id: <MPG.1423009c5cafb2a398ad4a@nntp.hpl.hp.com>

In article <8pblu7$nl7$1@nnrp1.deja.com> on Fri, 08 Sep 2000 21:32:56 
GMT, rtm7@my-deja.com <rtm7@my-deja.com> says...
> Hi all :

Hi.
 
> I have never used Perl before and at work, I need to write a simple
> script that will take a file as input, look for a specific string
> within that like and replace that with another string input at the
              ????

> command line and write the output to another file. Can anyone help?
> 
> Inputs are "String2" (string to replace with) and FILE1 (file to be
> read).
> 
> Look for "String1" (string to be replaced in FILE1) and replace
> with "String2". Write output to FILE2.

Assuming the string to be replaced does not span more than one line of 
the input file, it is as simple as this, entered at a command prompt:

    perl -pe 's/\QString1/String2/g' file1 >file2

On a Windows/DOS system, replace the single-quotes by double-quotes.

Do try to learn some Perl before posting again.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 08 Sep 2000 17:59:34 GMT
From: andras_kovacs2@non.agilent.com
Subject: Perl & https & proxy
Message-Id: <8pb9dp$7pm$1@nnrp1.deja.com>

Hi,

I have to use a proxy server to access the outside world.
My proxy has an address like : http://proxy.koko.com:6000

The web site that I want to access is an https:
https://www.koko.com

When I try to connect from perl to this "https" site perl uses
the "http" scheme instead of the "https" because of the proxy server.


This setting is defined in LWP::UserAgent->simple_request()

    # Locate protocol to use
    my $scheme = '';
    my $proxy = $self->_need_proxy($url);
    if (defined $proxy) {
	$scheme = $proxy->scheme;
    } else {
	$scheme = $url->scheme;
    }


Is there a workaround to open a socket on my http proxy then
keep this socket open and send through https request encoded ?


Thanks


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 8 Sep 2000 18:26:46 GMT
From: Sylvain Fauvel <fauvel@inrs-telecom.uquebec.ca>
Subject: Perl fail test 19  (great_circle_distance in test trig.t)
Message-Id: <8pbb16$7p8$1@Tropolix.UQSS.UQuebec.CA>


	My compiled version of perl pass all tests except the following :

	    > print 'not '
	    >    unless (near(great_circle_distance(0, 0, pi, pi), pi));
	    > print "ok 19\n";

	We checked and the result of great_circle_distance(0, 0, pi, pi)
	differ from "pi" by several digits.  Anyone know what could
	cause this.  I am assuming it is a configuration problem since
	the same version compiled by someone else i know pass the test
	on similar computer/OS config.

	Sylvain


Sylvain Fauvel
Analyste en informatique

INRS-Télécommunications
Place Bonaventure,
900 de la Gauchetière ouest, Niveau C
Case Postale 644
Montreal(Québec),
H5A-1C6

Tél.: (514)875-1266 
Fax : (514)875-0344 
E-Mail: fauvel@inrs-telecom.uquebec.ca





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

Date: Fri, 08 Sep 2000 16:38:10 -0500
From: "Barry Westaway" <bw2@nospam.y12.doe.gov>
Subject: Perl script hogging memory on IRIX 6
Message-Id: <8pbihu$kbn$1@sws1.ctd.ornl.gov>


I have written a Perl script that normally operates in 12 - 30 MB of
memory on an SGI Irix 6.X system.  It run like this for weeks at a time. 
On rare occasions it will go berzerk and start gobbling up memory. 
Eventually, IRIX provides all memory and swap  to the script and then the
system crashes.  I get a nasty phone call.

I could probably add a few undefs to give back some relatively large
chunks of memory (100 - 600K), but othet that that I don't know what to do
to restrict memory usage.

Any suggestions or hypothesis would be apreciated.

Thanks.



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

Date: Fri, 08 Sep 2000 18:13:45 GMT
From: awr@cpu.com
Subject: Recognizing wrapped lines
Message-Id: <8pba86$8tk$1@nnrp1.deja.com>

In files I'm processing, some lines are data of interest, some are not.
To complicate matters, the data lines may be wrapped. It is pretty
straightforward to build a regular expression to recognize the whole
data lines. Is there a straightforward way to recognize the data when it
is spread across multilple lines, especially since I don't know where in
the record it may get wrapped?

Thanks!

Andrew Robinson


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 08 Sep 2000 21:52:09 GMT
From: armstrongc@my-deja.com
Subject: Regular Expressions
Message-Id: <8pbn20$oqv$1@nnrp1.deja.com>

I hope someone can give me some help with a reqular expression problem.

Here is my Text:

Testing stuff <BDI.delimited.catalog.ETOWN@redknife.net>
or
Testing stuff "BDI.delimited.catalog.ETOWN@redknife.net"
or
Testing stuff 'BDI.delimited.catalog.ETOWN@redknife.net'

I want to just be able to pull out
BDI.delimited.catalog.ETOWN@redknife.net

The address can change so I cannot depend on counting chars at the
begining.

Thanks for the Help.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 8 Sep 2000 21:31:58 GMT
From: mjd@red.seas.upenn.edu (Mark-Jason Dominus)
Subject: Re: Scoping of symbolic references (variables)
Message-Id: <8pblse$2jo$1@netnews.upenn.edu>

In article <39B91250.CAA6E522@texas.net>, Tom Briles  <sariq@texas.net> wrote:
>> Again, any insight woould be greatly appreciated.
>
>Read:
>
>http://www.plover.com/~mjd/perl/varvarname.html

I think it might be more instructive to read

  http://www.plover.com/~mjd/perl/FAQs/namespaces.html

in this case.



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

Date: Fri, 8 Sep 2000 11:20:34 -0700
From: "Akira Kiyomiya" <akira.kiyomiya@autodesk.com>
Subject: Simple Question
Message-Id: <8pbaqm$kho@autodesk.autodesk.com>

Could someone explain why this results in  3: 0 8 22 in dummy's language?
I am a little bit confused ...

Thanks

AK

$string = 'foo bar foo blah quux foo';
    my @pos   = find_strings($string, 'foo');
    my $count = find_strings($string, 'foo');
    print "$count: @pos\n";                   # prints: 3: 0 8 22

    sub find_strings {
        my($string, $substr, $offset) = @_;
        $offset ||= 0;  # what is ||??
        my @positions;
        my $ind;
        while(($ind = index($string, $substr, $offset)) >= 0){
            push @positions, $ind;
            $offset = $ind + 1;
        }
        if ( wantarray() ) {
            return @positions;
        } elsif ( defined(wantarray()) ) {
            return scalar @positions;
        } else {
            return;
        }
    }




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

Date: Fri, 8 Sep 2000 16:27:17 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Simple Question
Message-Id: <Pine.GSO.4.21.0009081623000.23350-100000@crusoe.crusoe.net>

[posted & mailed]

On Sep 8, Akira Kiyomiya said:

>Could someone explain why this results in  3: 0 8 22 in dummy's language?

The function find_strings() returns the offsets in a target string of a
substring.  In the string

            1         2
  0123456789012345678901234
  foo bar foo blah quux foo

the substring 'foo' is located at position 0, 8, and 22.  That's what this
function returns.

>    sub find_strings {
>        my($string, $substr, $offset) = @_;
>        $offset ||= 0;  # what is ||??
>        my @positions;
>        my $ind;
>        while(($ind = index($string, $substr, $offset)) >= 0){
>            push @positions, $ind;
>            $offset = $ind + 1;
>        }
>        if ( wantarray() ) {
>            return @positions;
>        } elsif ( defined(wantarray()) ) {
>            return scalar @positions;
>        } else {
>            return;
>        }
>    }

I have a similar function, aindex(), which is far more compact. ;)

  # return all indices in $str where $sub is found
  sub aindex ($$;$) {
    my ($str,$sub,$pos) = @_;
    $pos ||= 0;
    my @pos;
    push @pos, $pos++ while ($pos = index($str,$sub,$pos)) != -1;
    return @pos;
  }

It does the same thing, but in fewer lines of code. :)

-- 
Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/



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

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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 4265
**************************************


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