[18928] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1123 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 13 03:05:49 2001

Date: Wed, 13 Jun 2001 00:05:13 -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: <992415912-v10-i1123@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 13 Jun 2001     Volume: 10 Number: 1123

Today's topics:
    Re: 2 questions about flock <no@spam.org>
    Re: 2 questions about flock <sljhglj@lksdlg.fd>
    Re: 2 questions about flock ctcgag@hotmail.com
    Re: 2 questions about flock <sljhglj@lksdlg.fd>
    Re: 2Gb+ files (was: can you do while (<HANDLE>) inside <ahamm.NO$PAM@sanderson.NO$PAM.net.au>
    Re: a question to programmers. <joe+usenet@sunstarsys.com>
    Re: Can an lvalue sub also be an rvalue? <johnlin@chttl.com.tw>
    Re: Can an lvalue sub also be an rvalue? <nospam-abuse@ilyaz.org>
    Re: Can't rename a file <no@matter.com>
    Re: CPAN hacked? <sdljfhk@lsgl.fj>
    Re: DBD::ODBC or Win32::ODBC? <no@spam.org>
    Re: ENV{HTTP_REFERER} in Netscape <spam_me@spam.com>
    Re: Foreach Not Behaving Properly <c_clarkson@hotmail.com>
    Re: Help with split?vvp <no@spam.please.org>
        how do I sort the output of this? <Patrick_member@newsguy.com>
    Re: log file parsing (Sweth Chandramouli)
        LOOKING FOR PERL JOBS <cometlinear@yahoo.com>
    Re: New word <pne-news-20010613@newton.digitalspace.net>
    Re: New word <pne-news-20010613@newton.digitalspace.net>
    Re: Perl  HTTP & SSL <killer@spam.org>
    Re: Perl is dead! Long live Perl! <no@spam.org>
    Re: PERL on PC <sagsg@dhdh.gf>
    Re: PERL on PC <lfhslhf@lkhsl.bk>
        Scoping problem ctcgag@hotmail.com
        Sending Attachments Via Sendmail <AHALL5@nc.rr.com>
    Re: Sending Attachments Via Sendmail <keng@spinalfluid.com>
    Re: Sending Attachments Via Sendmail (David Efflandt)
    Re: Sending Attachments Via Sendmail (Rafael Garcia-Suarez)
    Re: Simplest code to test if web site is up? <pne-news-20010613@newton.digitalspace.net>
    Re: Sorting versions of a file, Help needed <eyheyh@dhd.dg>
    Re: Table/Cell formatting with CGI.pm <joe@bloggs.com>
    Re: Table/Cell formatting with CGI.pm (Craig Berry)
        Win32 - Return DOS Errorlevel <alex_tatistcheff@NOSPAM.non.hp.com>
    Re: Win32 - Return DOS Errorlevel (Jay Tilton)
    Re: Win32::OLE Question (Homer Simpson)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 13 Jun 2001 06:04:37 GMT
From: "sgdhfd" <no@spam.org>
Subject: Re: 2 questions about flock
Message-Id: <3b26f465@news2.mibx.net>


abigail@foad.org (Abigail) wrote:
>
>I don't want to speak on behalf of Windows, but that claim is certainly
>not true on Unix. Otherwise, it would never have taken off as a popular
>multi-user environment. One programming mistake (or evil intention) and
>you have a denial-of-service attack.

So true. Windows 16 exhibits the waiting behaviour as does MacOS, any apps
that use the 16-bit (read: win3.1 code) side of Win 95/98 and any apps 
sharing a WOW instance inside a NTVDM on Windows NT.  This is due to 
co-operative multitasking.  Th advantages of win95 and NT is a 
pre-emptive kernel (bit of a stretch for win95) that allows other programs

to run (win95: except when a non-reentrant system call has hung).

>
>A program in a busy-loop will not prematurely give up its time slice, and
>get right back in the queue. However, it won't occupy the CPU for 20 seconds
>at a time. At worst, it will cause some slow down.

I don't know if you'd call it a slow down as such, it would be just as fast
as
if the program was actually doing something, however you would get the extra

performance that you would've got if the program voluntarily yielded.


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

Date: 13 Jun 2001 06:19:20 GMT
From: "fwaryhrjnm" <sljhglj@lksdlg.fd>
Subject: Re: 2 questions about flock
Message-Id: <3b26f7d8@news2.mibx.net>


abigail@foad.org (Abigail) wrote:

>
>    7358: Fri Jun  8 22:51:04 2001: Start
>    7359: Fri Jun  8 22:51:04 2001: Start
>    7359: Fri Jun  8 22:51:05 2001: Asking for shared lock. 
>    7359: Fri Jun  8 22:51:05 2001: Got the shared lock. 
                                 59-LOCK_SH / 58-No Lock
>    7358: Fri Jun  8 22:51:05 2001: Asking for shared lock. 
>    7358: Fri Jun  8 22:51:05 2001: Got the shared lock. 
                                 59-LOCK_SH / 58-LOCK_SH
>    7359: Fri Jun  8 22:51:10 2001: Upgrading lock to exclusive lock.
>    7358: Fri Jun  8 22:51:10 2001: Upgrading lock to exclusive lock.
>    7359: Fri Jun  8 22:51:10 2001: Got the exclusive lock. 
                          >>     59-LOCK_EX / 58-LOCK_SH  <<
>    7359: Fri Jun  8 22:51:15 2001: Exiting, releasing locks. 
                                 59-LOCK_UN / 58-LOCK_SH
>    7358: Fri Jun  8 22:51:15 2001: Got the exclusive lock.
                                 59-No Lock / 58-LOCK_EX
>    7358: Fri Jun  8 22:51:20 2001: Exiting, releasing locks.
                                 59-No Lock / 58-LOCK_UN
>
>No deadlock.

(see notes above, please correct if incorrect)

Interesting, I though an exclusive lock blocked until there were no
locks on the file (no LOCK_SH or LOCK_EX).  However the above suggests
that the exclusive lock was granted while there was an existing shared 
lock.  This has the same effect as being granted a shared lock on a file
that has an exclusive lock.  Wouldn't this be an error condition.
What code was used to produce the above, I don't have any posts before
this one yet.


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

Date: 13 Jun 2001 05:39:48 GMT
From: ctcgag@hotmail.com
Subject: Re: 2 questions about flock
Message-Id: <20010613013948.249$44@newsreader.com>

"fwaryhrjnm" <sljhglj@lksdlg.fd> wrote:
> abigail@foad.org (Abigail) wrote:
>
> >
> >    7358: Fri Jun  8 22:51:04 2001: Start
> >    7359: Fri Jun  8 22:51:04 2001: Start
> >    7359: Fri Jun  8 22:51:05 2001: Asking for shared lock.
> >    7359: Fri Jun  8 22:51:05 2001: Got the shared lock.
>                                  59-LOCK_SH / 58-No Lock
> >    7358: Fri Jun  8 22:51:05 2001: Asking for shared lock.
> >    7358: Fri Jun  8 22:51:05 2001: Got the shared lock.
>                                  59-LOCK_SH / 58-LOCK_SH
> >    7359: Fri Jun  8 22:51:10 2001: Upgrading lock to exclusive lock.
              ***                  59-No lock / 58-LOCK_SH
> >    7358: Fri Jun  8 22:51:10 2001: Upgrading lock to exclusive lock.
              ***                  59-No lock / 58-No lock
> >    7359: Fri Jun  8 22:51:10 2001: Got the exclusive lock.
>             888           >>     59-LOCK_EX / 58-No lock  <<


>
> (see notes above, please correct if incorrect)

Corrected with ***


> Interesting, I though an exclusive lock blocked until there were no
> locks on the file (no LOCK_SH or LOCK_EX).

Yes, but the process of asking for EX automatically drops the SH that
the requesting process holds.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
                       Usenet for the Web


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

Date: 13 Jun 2001 07:24:34 GMT
From: "fwaryhrjnm" <sljhglj@lksdlg.fd>
Subject: Re: 2 questions about flock
Message-Id: <3b270722@news2.mibx.net>


ctcgag@hotmail.com wrote:

>
>Yes, but the process of asking for EX automatically drops the SH that
>the requesting process holds.

Thank you. Makes sense now.


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

Date: Wed, 13 Jun 2001 13:07:53 +1000
From: "Andrew Hamm" <ahamm.NO$PAM@sanderson.NO$PAM.net.au>
Subject: Re: 2Gb+ files (was: can you do while (<HANDLE>) inside opening a file twice?)
Message-Id: <3b26d927$1@news.iprimus.com.au>

Gala wrote in message ...
>
>Ok.. a long is a 32 bit number, therefor goes up to of 4,294,967,295 -
>about 4 gigs (unsigned), or, 2,147,483,647 - about 2 gigs (singed). Now
>lets be realistic here. Is there a computer out there that has a file
>thats 4 or 2 gigs big?
>
Oh, I could think of several dozen under my administration. A multi-gig
space is routine these days in a large database system. Terabyte
databases are now in existence and becoming more common. Places like KFC
and Pizza Hut collect daily records from all the stores in a district.
These records include cash register activity to the minute and include
details such as what was purchased, how much was spent, the time of the
day, whether any special deal vouchers were used to make the purchases,
whether any specific "deal" was asked for and so on.

I was told several years ago thru a loose connection to the place, that
KFC even analyses details such as whether having a slide in the child-
ren's playground has an effect on the profitability of the store.

>(Damn that'd be a huge file!!! Bleh, just thinking about itterating
>through a file that big just makes my stomach turn ;p)
>
This information is collected into huge "database warehouses" and
analysed in an attempt to see which deals and vouchers work the best on
which days and where. These databases are huge and a typical query
against a warehouse will completely scan multiple tables and bang them
together to get the results they are looking for.

Apart from the fast food vendors, you can be sure that banks, insurance
companies, financial institutions, etc etc etc etc etc are using huge
databases of multi-gigabyte and even multi-terabyte sizes. Needless to
say the data is grouped into files or spaces exceeding 2Gb.

Tax departments and insurance companies are using terabyte database
warehouses to detect patterns which suggest fraudulent activities are
taking place. Medical research centres are using terabyte warehouses to
detect adverse drug interactions. Health authorities are using terabyte
warehouses to detect over-prescription and other medical crimes.

Even disregarding the common-place activity of sequentially scanning
large databse tables, intelligent database engine software is extremely
powerful and capable of selecting individual records out of millions.
And, certain other processes do run through large amounts of space
sequentially. When you can achieve transfer rates of at least several
Mb/sec INCLUDING the processing work going on, it doesn't take too much
time. Archiving the database to tape is one example of this happening.
If you setup a machine with striped sets of disks, you can multiply this
transfer rate to whatever degree you need for your system.

>No, really, I really doubt are files of that size.
>
On a home pc, sure, I'd agree with that.

>My god, do you have any idea how slow a server would be if were to
>process that file over and over (in for example a site where many users
>visit, each calling the cgi that processes that file). I think a word
>for that would be INSANE.
>
So you think the whole world is limited to web sites? Think again! Even
with web sites, as those sites become larger and more mission critical
to a business, the database engines I've mentioned are becoming more and
more essential to maintain performance on the sites as more and more
information and transactions are performed.

>In over words I very much doublt anyone would have any trobble with
>a file size bigger then a long can hold. Not to mention, most server
>providers usally dont give more then 100 megs, or sometimes less,
>depending on the provider and service, but theres no way in the 7th
>circle of hell you are going to get anything even remotely close to
>2 gigs. Unless you happen to own/host your own server with a big
>hard drive.
>
Well, like I've already proven, files greater than 2G are trivial to
create. I haven't got immediate access to a Linux system right now (I'm
rebuilding my personal machine) but if you do, have a look at the
definitions of the fpos_t datatypes. If you have sufficiently modern
Linux, you'll find that it's now a structure that's bigger than a long.
Hence, even a Perl long will soon be unsuitable to hold the return value
from ftell. Very soon the Perl Porters will deal with this and we'll all
have to adapt if the language is shifted that way.

This change in the structure of fpos_t is because Linux is being
prepared for 64 bit addressing. I hear that Linux is considered
ready for the Intel 64 bit processor. HP-UX, DG/UX, AIX and many
other professional UNIX have been made 64 bit ready and functional
for a few years now. You can only buy a 64 bit processor from many
of these vendors.

>Even so, god forbid trying to display the entire file!!!!!!!
>
Yes, that would be a silly, breathless thing to do...

--
"Dis act ain't about lafter - it's about comedy" - Andrew Dice Clay







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

Date: 13 Jun 2001 02:13:35 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: a question to programmers.
Message-Id: <m3bsnsdi0g.fsf@mumonkan.sunstarsys.com>


thinkit <thinkit8@lycos.com> trolls clp.misc this time and writes:

> In article <tid2dtk5i80ja6@corp.supernews.com>, cberry@cinenet.net says...
> >
> >thinkit (thinkit8@lycos.com) wrote:
> >: if a language only offered hexadecimal and binary input literals, 
> >: would you be more or less likely to utilize it?  in a similar line,
> >: how much hexadecimal do you use in the languages you use now?  do
> >: you count to 16, or to 0x10?
> >
> >I wouldn't use it.  After all, even (most) assemblers offer string
> >literals and the like.  Having
> >
> >  print 0x48656c6c6f2c20776f726c64210a;
> >
> >as your first program seems a bit...retro. :)
> >

[... sig snipped ...]

> oops, i meant only hexadecimal and binary integer literals--and no
> decimal. thus a-f would have same status as 0-9 w/regards to naming,
> and you would need no "0x".
> 

What next, mandatory conversion to the new metric system? 
BTDT, Jimmy Carter- and it's still 2880249322, IOW

  A_BAD_1DEA.


all.SCORE application accepted.

[F'ups set.]

-- 
Joe Schaefer      "The past may not repeat itself, but it sure does rhyme."
                                               --Mark Twain



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

Date: Wed, 13 Jun 2001 09:43:53 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: Can an lvalue sub also be an rvalue?
Message-Id: <9g6gcb$hoo@netnews.hinet.net>

"pt" wrote
> "John Lin" wrote
> > "pt" wrote
> > > Can a sub declared with the "lvalue" attribute also be used as a
> > > regular (rvalue) sub?
> > >    $thing_status = status($thing) ; # get thing's status
> > >    status($thing) = 0 ;             # reset thing's status
> >
> > Your code tells your the answer.  Does it compile?  Does it work?

<nobull@mail.com> wrote:
> John, that is the Godzilla answer.
Oh, sorry.  In our Perl discussion group, sometimes people ask questions
like: "What would 'print sqrt(-1)' prints?"  I would answer in this manner.
You know, I thought that was the Abigail answer...

>    No and No, but that's only because I haven't figured out the
> correct syntax, usage, or incantation yet.  One or two short examples
> would be appreciated.  Thanks in advance.

Oh, OK.  Let's take your code for example.  We can write a lvalue sub

    sub status: lvalue { shift }

(the simplest one, I think) which returns the first argument.  That is

    status($x,$y,$z)  means  $x

no matter in lvalue or rvalue context.  So

    status($x,$y,$z) = 3;  means  $x = 3;
    print status($x,$y,$z);  means  print $x;

Let's test your code:

sub status: lvalue { shift }
my $thing = 1;
my $thing_status = status($thing);    # should get 1
print $thing_status;
status($thing) = 0;
print $thing;    # should get 0
__END__
10        <---- Yes, that's right.

HTH

John Lin





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

Date: Wed, 13 Jun 2001 03:47:37 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Can an lvalue sub also be an rvalue?
Message-Id: <9g6nop$c3k$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
John Lin
<johnlin@chttl.com.tw>], who wrote in article <9g6gcb$hoo@netnews.hinet.net>:
> > > > Can a sub declared with the "lvalue" attribute also be used as a
> > > > regular (rvalue) sub?
> > > >    $thing_status = status($thing) ; # get thing's status
> > > >    status($thing) = 0 ;             # reset thing's status
> > >
> > > Your code tells your the answer.  Does it compile?  Does it work?

> Oh, sorry.  In our Perl discussion group, sometimes people ask questions
> like: "What would 'print sqrt(-1)' prints?"  I would answer in this manner.

Do not.  Because it is a wrong answer.  The answers to both these
questions cannot be detected by experiments, because they are not
completely documented.

  perl -MMath::Pari=:int -wle 'print sqrt -1'
  1.000000000000000000000000000*I

*No* question about programming may be answered by experiments (unless
answered negatively ;-).  This is the difference between programming
and scripting.

Hope this helps,
Ilya


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

Date: 13 Jun 2001 06:41:24 GMT
From: "dqlkhdkqu" <no@matter.com>
Subject: Re: Can't rename a file
Message-Id: <3b26fd04$1@news2.mibx.net>


"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:

>Amazing! An article referencing this same problem was
>posted just hours back! What a coincidence! Even more
>amazing, I posted code which works for Win 32 file
>renames just an hour or so back! How about that!
>
>* simply stupefied *

Yes you see everyone uses exactly the same server as Godzilla and
receives all messages instantly the moment they are sent.  Perhaps 
you should replace "efied" with "id"?

>
>
>> Any ideas?
>
>Yes, post that portion of your code in question. For
>all I know, your code might be,
>
>print "Hello World!";
>

A simple "Please post code" would suffice.  Just because they are new,
aren't familiar with posting technical questions or have english as 
a second language doesn't give you the right to be rude.

>rename ("oldfilename", "newfilename");

possible reasons for a rename to fail, assuming your code is correct:
1. You don't have permission to do this.
2. A file already exists with the filename you are attempting to
   change to.


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

Date: 13 Jun 2001 04:19:37 GMT
From: "ewww" <sdljfhk@lsgl.fj>
Subject: Re: CPAN hacked?
Message-Id: <3b26dbc9@news2.mibx.net>


Elaine Ashton <elaine@chaos.wustl.edu> wrote:
>"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
>> I will strongly urge you to pursue criminal prosecution.
>> This is easy to do and almost always successful. A crime
>> has been committed. Don't turn a blind eye. I never do.
>
>Why? It would simply waste more time and, since the site
>neither generates nor is supported by any commercial enterprise,
>money we don't have.
>
>e.
>
Godzilla said criminal not civil.  Just hand over any logs, etc to
the FBI (or equivalent) and let them do the work.  
Didn't cost you a cent.



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

Date: 13 Jun 2001 03:51:58 GMT
From: "Mr. Nobody" <no@spam.org>
Subject: Re: DBD::ODBC or Win32::ODBC?
Message-Id: <3b26d54e@news2.mibx.net>


DBD is useful when you may need to change to a different DBMS 
in the future.  If you stick to fairly standard SQL then it 
becomes a fairly trivial task to change to a different DBMS. 
However DBD is a lowest common denominator style of interface.  
(DBMS extensions are availible, but are more of a hack then a 
integrated part of the API).

If you think that you will always have the db on win32 then use
win32::ODBC as it has a neater interface for this circumstance.
I prefer DBD, but it's a matter of preference.  Have a look at the
PODs for win32::ODBC, DBD/DBI::ODBC and decide which one best suits
your requirements, and which one you are most comfortable using.

"Richard Biffl" <REMOVETHISPHRASEusenet@blacklettersoftware.com> wrote:
>What are the pros and cons of these modules? I'm using ActivePerl on Windows
>2000, and Win98 may use the program too. I'll initially use the interface
to
>migrate data from a text file to a Paradox table, using nothing but INSERT
>statements, but maybe I'll do more with it later. I've seen a post here
>saying that DBD::ODBC is preferred, but ActiveState's website mentions that
>Win32::ODBC is popular.
>
>  Richard
>
>
>



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

Date: Tue, 12 Jun 2001 21:58:25 -0400
From: "MindReaper" <spam_me@spam.com>
Subject: Re: ENV{HTTP_REFERER} in Netscape
Message-Id: <6NzV6.14500$Cl1.1350969@wagner.videotron.net>

Or maybe there is simply no referer :)



Dianne van Dulken a écrit dans le message ...
:Hi,
:
:I have already posted this to the perl and perl-cgi mailing lists, but
:haven't been able to find a solution
:
:I am calling a perl script from a HTML page in the following form:
:
:<script language="javascript"
:src="https://testserver.com.au/server/cgi-bin/script1.pl">
:
:This checks the HTTP_REFERER of the calling page, and if it is one we like,
:gives one set of javascript back, or else a different set.
:
:The problem is that Netscape isn't giving me a HTTP_REFERER code at all..
:Everyone I have talked to agrees that it SHOULD be giving it to me, but in
:none of our tests it has done so.
:
:Has anyone got a suggestion of what else I could use?  The javascript
:http_referrer still works in Netscape, but not the perl version.  We need
to
:find the IP of the page calling the code, not the users IP or anything like
:that.
:
:Thanks a lot
:
:Dianne
:
:--
:Dianne van Dulken
:You have the right to remain silent.
:Anything you say will be misquoted, then used against you.
:
:
:




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

Date: Wed, 13 Jun 2001 01:44:30 -0500
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: Foreach Not Behaving Properly
Message-Id: <7D52933F9A4D6B1E.FB3551F4C8A9B014.C7DEC291A0CB7CE1@lp.airnews.net>

Barry Allwood <barryallwood@aol.com> wrote

: Hey,
:
: I am making a news script not to similar to newspro
: and I was wondering why when I use 2 foreach loops
: to display news I get an extra box
: (http://www.sky-scraper.net/phoenix/bpnews2.cgi) at
: the bottom, here is the code if you need it
:
: #!/usr/bin/perl
:
: require "bpcs.pl";

    Sure would be helpful if we could see what is
in 'bpcs.pl'.

: print "Content-type: text/html\n\n";
:
: &Parse(\%in);
:
: $AID = $in{'AID'};

    Might be neat if you could tell us what is
assigned to $AID.

: open (NEWS, "< news.txt") or &die("crappy shit");
: @article = <NEWS>;
: close (NEWS);

    Okay, I got the contents of news.txt off the
site:

1:x:Wooohooo!:x:Yes This Fantastic Thing Actually
Works!:x:ElBazo:x:25/05/01:x:0:x:0
2:x:Wrong Statement:x:Yes This Fantastic Thing Actually
Works!:x:ElBazo:x:25/05/01:x:1:x:1
3:x:Number3:x:Yes This Fantastic Thing Actually
Works!:x:ElBazo:x:25/05/01:x:0:x:0
4:x:Number4:x:Yes This Fantastic Thing Actually
Works!:x:ElBazo:x:25/05/01:x:0:x:1

:
: foreach (@article) {
: my ($NewsAID, $NewsTitle, $NewsText, $NewsPerson,
:     $NewsDate, $Display, $Bump) = split /:x:/;
:
: &NewsTemplate(@article) if (($AID == '') &&
:     ($Display == 0)) && ($Bump == 1);

<sarcasm>
    Ahh, yes NewsTemplate, that's the subroutine
you explained in your message, right?
</sarcasm>

    Come on, Barry, show us the subroutines, too.
We want to help, but we are not mind readers.






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

Date: 13 Jun 2001 03:12:18 GMT
From: "No Matter" <no@spam.please.org>
Subject: Re: Help with split?vvp
Message-Id: <3b26cc02@news2.mibx.net>


$line = "a|b|c|d|e|f|g";
($a,@items)=split /\|/,$line;
print "0|".join("|",@items)."\n";

could be simplified to:

my($a, $other);
$line = "a|b|c|d|e|f|g";
($a,$other)=split(/\|/,$line,2);
print "0|".$other;  # no \n as original ($line) doesn't

Some might say its a little easier to read, and it 
has the advantage of handling any number of columns.
when reading from a file you wouldn't need to chop 
the \n either.

steve.busiello@gs.com (Steven) wrote:
>I would do it like this:
>
>$line = "a|b|c|d|e|f|g";
>substr($line,0,1) = "0";
>print "$line \n";
>
>A little reverse substr jammy ...
>
>
>Otherwise
>Try this: ( definately not the best way, but following your thinking )
>$line = "a|b|c|d|e|f|g";
>($a,@items)=split /\|/,$line;
>print "0|".join("|",@items)."\n";
>
>
>-Steven
>
>
>"Prasad, Victor [FITZ:K500:EXCH]" <vprasad@americasm01.nt.com> wrote in
message news:<3B26297F.9BB8F76A@americasm01.nt.com>...
>> Hello,
>> 
>> I have a small script that takes a PIPE ( | ) delimited file that is
>> suppose to strip the first field away, replace it with a 0 then keep the
>> rest of the | delimited fields.
>> 
>> ie.
>> 
>> file (many lines)
>> 
>> a|b|c|d|e|f|g
>> 
>> output to new file should be
>> 
>> 0|b|c|d|e|f|g
>> 
>> what happens...the file contains this
>> 
>> 0|2
>> 
>> I have to use a PIPE (|) - because that is the standard for all our
>> files.
>> 
>> Script:
>> 
>> open (rf,"$filename");
>> 
>> open (faxtemp,">$filename.txt");
>> while($line=<rf>) {
>>         ($a,$items)=split /|/,$line;
>>                print faxtemp "0|$items \n";
>>                              
>> }
>> close (rf);       
>> 
>> help?
>> 
>> Thanks,
>> 
>> V



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

Date: 12 Jun 2001 22:05:41 -0700
From: Patrick Flaherty <Patrick_member@newsguy.com>
Subject: how do I sort the output of this?
Message-Id: <9g6sb502ocm@drn.newsguy.com>

Hello,

  Have the following procedure that I just wrote:

#
# Usage: perl dtrees.pl PATH
# if PATH not defined then PATH=.
#
use File::Find;
my $this_subtree;


@ARGV = ('.') unless @ARGV;
my $dir = $ARGV[0];

# if there isn't a backslash at the end of ARGV[0] add one
if ( substr($dir,-1) ne "\" ) { $dir = $dir . "\";}

opendir DIR, $dir or die "can't opendir $dirname: $!";
while (defined($file = readdir(DIR))) {
    if (-d ($dir . $file) && $file ne "." && $file ne "..") {
	find sub { $this_subtree += -s }, ($dir . $file);
	write();
	$this_subtree = 0;
    }
}
closedir(DIR);

format STDOUT =
@<<<<<<<<<<<<<<<<<<<<<          @###########
$file                           $this_subtree
 .

This works well enough.  It takes all the directories within pwd and finds the
subtree of each.

Next iteration.  I'd like to sort the output by the size field ($this_subtree).

I've tried saving each line produced by the write() statement via a push to an
array.  But it's not clear to me how to use sort to sort on a certain column
range within each string?  Or do I need to set up my elements as data structures
(with, presumably, a name and a size)?

  thanx.

  pat



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

Date: Wed, 13 Jun 2001 03:21:34 GMT
From: sweth+perl@gwu.edu (Sweth Chandramouli)
Subject: Re: log file parsing
Message-Id: <2%AV6.76077$G5.16376796@news1.rdc1.md.home.com>

In article <tid3rk116i2i5b@corp.supernews.com>,
kevin <emailkevin@charter.net> wrote:
>can someone show me how to read each new line of a log file and then take
>some action, and then read the next?  Thanks
$ perl -ne 'some_action ($_);' logfile

	-- Sweth.

-- 
Sweth Chandramouli ; <sweth+perl@gwu.edu>


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

Date: Tue, 12 Jun 2001 23:10:09 -0700
From: dot-comet <cometlinear@yahoo.com>
Subject: LOOKING FOR PERL JOBS
Message-Id: <120620012310093500%cometlinear@yahoo.com>

Hello,

I am interested in doing small/medium-scale perl programming jobs. I
will not charge very much at all, as I want to do it to keep my skills
sharp.

If you are interested, I can be contacted at: 
staff>>"at"<<dot-comet.com

Or, go to:

http://dot-comet.com

And contact me there.


Thank you,
-joshua


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

Date: Wed, 13 Jun 2001 06:35:33 +0200
From: Philip Newton <pne-news-20010613@newton.digitalspace.net>
Subject: Re: New word
Message-Id: <88rditsl3hd8p6vhqgqig0oda2jge31d80@4ax.com>

On Tue, 12 Jun 2001 19:53:45 GMT, Gary <gamtci@mpinet.net> wrote:

> I don't think my C preprocessor is going to like what it sees 
> in here.  Aren't statements like $_[0], \$myvar or <=> going to 
> lead the preprocessor to error out?

I think the preprocessor looks very little at syntax, mostly looking out
for lines starting with '#' and substituting macros it knows about.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Wed, 13 Jun 2001 06:35:33 +0200
From: Philip Newton <pne-news-20010613@newton.digitalspace.net>
Subject: Re: New word
Message-Id: <g9rdito9asbqk63lrpuv97mt2he4o532po@4ax.com>

On Tue, 12 Jun 2001 21:07:31 GMT, Gary <gamtci@mpinet.net> wrote:

> the comment issue (namely #) is sure to cause some problems.

Not really. I think most cpp's ignore unknown processing directives, so
something like this

    # what should I do know?

shouldn't be a problem, but

    # error handling code follows

might if the cpp has a directive '#error'.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: 13 Jun 2001 06:53:45 GMT
From: "Spam Killer" <killer@spam.org>
Subject: Re: Perl  HTTP & SSL
Message-Id: <3b26ffe9$1@news2.mibx.net>


brian d foy <comdog@panix.com> wrote:
>In article <3b1f896e$1@rpc1284.daytonoh.ncr.com>, "Dennis Kowalski" 
><dennis.kowalsk@daytonoh.ncr.com> wrote:
>
>> I need HTTPS capability.
>
>http://search.cpan.org
>

While nothing more then a nudge (well swift kick ;-) ) to more information
I wish more posters did this (or didn't post) rather then engage in long

winded tirades.  

Not mentioning any names <cough>Godzilla<cough>, though 
to her defense (and this is as close as I'll get to defending her), she
usually does answer her question with an example, and she seems to be 
putting more effort into testing amd benchmarking her code nowadays.
Even if its just to attempt to prove that her code is "better" then 
another example.

(Not comparing Brian to Godzilla, seperate topics)


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

Date: 13 Jun 2001 07:10:17 GMT
From: "agseuj" <no@spam.org>
Subject: Re: Perl is dead! Long live Perl!
Message-Id: <3b2703c9$1@news2.mibx.net>


tadmc@augustmail.com (Tad McClellan) wrote:

>You can flip burgers with 22 characters of Perl.
>
>   s/burgers/reverse$&/e;
>
>If anyone knows Java well, please post the guts of what it would
>take to get that done in Java.
>

if defined as a StringBuffer called buf
(StringBuffer buf = new StringBuffer( "burger"); )

then:
buff.reverse();
would be even shorter in VB.

However the length is irrelevent, its the code generated by the compiler
that counts.

>
>-- 
>    Tad McClellan                          SGML consulting
>    tadmc@augustmail.com                   Perl programming
>    Fort Worth, Texas



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

Date: 13 Jun 2001 04:30:21 GMT
From: "wgasdjf" <sagsg@dhdh.gf>
Subject: Re: PERL on PC
Message-Id: <3b26de4d@news2.mibx.net>


Philip Newton <pne-news-20010610@newton.digitalspace.net> wrote:
>On Sun, 10 Jun 2001 17:37:34 GMT, "redfive" <redfive_ls@yahoo.com>
>wrote:
>
>> I bought the book Learning PERL.
>
>There is no PERL. There is only Perl and perl. (The document 'perlfaq1'
>that comes with the Perl distribution explains the difference.)
>

The man page that also comes with Perl calls it PERL (expanding the
acronym and everything) is it little wonder that so many people call it this
besides what the difference? I mean really, its just a name, its pretty obvious
what they are talking about, what with the obsessive nit picking in the Perl
community?


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

Date: 13 Jun 2001 04:42:40 GMT
From: "wfgwgw" <lfhslhf@lkhsl.bk>
Subject: Re: PERL on PC
Message-Id: <3b26e130@news2.mibx.net>


Summary:
---------
You asked a question,
I replied in a condenscending fashion,
you got upset and insulted me,
I'm not going to play anymore.

And I _used_ to have such respect for your posts...

Philip Newton <pne-news-20010611@newton.digitalspace.net> wrote:
>[Please don't quote the entire previous article; snip appropriately.
> Please put your text below the quoted material.
> Please don't quote signatures.
> Thanks.]
<snip>


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

Date: 13 Jun 2001 04:33:32 GMT
From: ctcgag@hotmail.com
Subject: Scoping problem
Message-Id: <20010613003331.660$UD@newsreader.com>

I thought I was vaguely competent at perl, but this is giving me
problems:

#!/usr/bin/perl   -w
use strict;
my @t = ( qw{g b n k l o p} ) ;

for ( my $i = 0 ; $i<= $#t ;$i++  )  {
  my $file = $t[$i];
  print "starting $file\n" ;
  # do stuff
  add_data("first");
  # do stuff
  add_data("now_error");

  sub add_data {
    my $label=shift or die;
    print "Processing $file $label\n";
    # do stuff;
    if ( $label eq "now_error" ) {           # pretend there is an error
      warn "Error in file $file during $label\n" ;
    } ;
  } ;

} ;

starting g
Processing g first
Processing g now_error
Error in file g during now_error
starting b
Processing g first
Processing g now_error
Error in file g during now_error
starting n
Processing g first
Processing g now_error
Error in file g during now_error
starting k
Processing g first
Processing g now_error
Error in file g during now_error
starting l
Processing g first
Processing g now_error

The sub is declared within the lexical scope of the my $file declaration,
so I thought it should be able to access the value of $file

From perlsub --Begin--
This doesn't mean that a my() variable declared in a
statically enclosing lexical scope would be invisible.
Only the dynamic scopes are cut off.   For example, the
bumpx() function below has access to the lexical $x
variable because both the my and the sub occurred at the
same scope, presumably the file scope.

my $x = 10;
sub bumpx { $x++ }

--End--


It looks like the value of $file when the sub is first called is
getting locked in, as if it were a closure.

I can fix it by moving putting a my $file before the loop just
setting it, rather than my'ing it in the loop, but that doesn't
answer the conceptual problem.

So what's going on?

Thanks,

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
                       Usenet for the Web


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

Date: Wed, 13 Jun 2001 02:07:22 GMT
From: "Antoine Hall" <AHALL5@nc.rr.com>
Subject: Sending Attachments Via Sendmail
Message-Id: <uVzV6.89650$e34.12231665@typhoon.southeast.rr.com>

Is there a way to attach files to an email when using Sendmail?  I want to
be able to send an email to someone and attach log files but have the
process automatic using sendmail.  Can it be done?

==
'Toine





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

Date: Wed, 13 Jun 2001 11:10:10 +0800
From: "keng" <keng@spinalfluid.com>
Subject: Re: Sending Attachments Via Sendmail
Message-Id: <9g6lh1$eqh$1@dahlia.singnet.com.sg>

one short way is to try this unix command
uuencode filename.ext recieved_filename.ext | sendmail userid@company.com


--
regards

"Antoine Hall" <AHALL5@nc.rr.com> wrote in message
news:uVzV6.89650$e34.12231665@typhoon.southeast.rr.com...
> Is there a way to attach files to an email when using Sendmail?  I want to
> be able to send an email to someone and attach log files but have the
> process automatic using sendmail.  Can it be done?
>
> ==
> 'Toine
>
>
>




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

Date: Wed, 13 Jun 2001 06:16:11 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: Sending Attachments Via Sendmail
Message-Id: <slrn9ie19a.llk.see-sig@typhoon.xnet.com>

On Wed, 13 Jun 2001 02:07:22 GMT, Antoine Hall <AHALL5@nc.rr.com> wrote:
> Is there a way to attach files to an email when using Sendmail?  I want to
> be able to send an email to someone and attach log files but have the
> process automatic using sendmail.  Can it be done?

The Perl way would be to use the MIME::Lite module.  If you need to 
install it yourself, just put Lite.pm in a directory called MIME and point 
to the full path to the parent of MIME with use lib:

use lib '/path_to/mymodules';	# unshifts path to @INC
use MIME::Lite;		# looks for MIME/Lite.pm in @INC paths

-- 
David Efflandt  (Reply-To is valid)  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: 13 Jun 2001 06:18:24 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Sending Attachments Via Sendmail
Message-Id: <slrn9ie1ep.u78.rgarciasuarez@rafael.kazibao.net>

Antoine Hall wrote in comp.lang.perl.misc:
} Is there a way to attach files to an email when using Sendmail?  I want to
} be able to send an email to someone and attach log files but have the
} process automatic using sendmail.  Can it be done?

Of course, sendmail can handle emails with attachments. An attachment is
essentially a way to format the body of the mail. It's intended to be
decoded and encoded by mail user agents. The job of sendmail is only to
transport the mails over a network, not to handle its contents.

To answer your question: use the MIME::Lite module.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Wed, 13 Jun 2001 06:35:32 +0200
From: Philip Newton <pne-news-20010613@newton.digitalspace.net>
Subject: Re: Simplest code to test if web site is up?
Message-Id: <43rditk9as0bq85t9qdq8av69jdr1a6agr@4ax.com>

On Tue, 12 Jun 2001 14:52:56 -0700, brian d foy <comdog@panix.com>
wrote:

>     use LWP::Simple;

The original poster asked whether it was possible to do it only with
modules bundled with Perl.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: 13 Jun 2001 04:08:44 GMT
From: "ewyw" <eyheyh@dhd.dg>
Subject: Re: Sorting versions of a file, Help needed
Message-Id: <3b26d93c@news2.mibx.net>


"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
>Afshin Akbari wrote:
>
>(snipped)
>
>> ...I appreciate any comments or inputs on this.
>
>> I need to get the latest version of each file.
>> To do this, I read them to a hash and use file name
>> as the keys and version as values. 
>
>> The file that I read from stores them in the following format:
>> abc.pl  12.10
>> abc.pl  12.11
>> abc.pl  12.12
>> ......
>> abc.pl  12.16
>> abc.pl  12.9
>> abc.pl  12.8
>> .....
>> abc.pl  12.1
> 
>> Problem: when I read them into a hash and print the hash "abc.pl  12.9"
>> get to be the highest version. Which we all know it is not.

This looks like they are being compared as strings (left to right)
(in strings, 9.9 is higher then 9.10, since its only comparing 9.9 and 9.1,
when it makes its decision.)

Simply look at each line and compare it numerically (eg:  if ($old < $new)
{})
Then remember the details of the highest to date through the loop.

>
>Yes, much faster. Your method of creating your database is
>most illogical. You should be sorting by descending order
>before printing to your database. Retrieval is then a simple
>matter of pulling the first line of your database. Make it so.

who says he created it.  Often in the programming world you have to 
work with what your given.

>
>> Q2) Is there a perl utility to do this ?
>
>This utility is known as perl core.

No need to be a smart arse.

>Use of a hash for programming should be your last choice
>when a simple associative array or a common array could
>be used or, a method requiring neither can be used.

of course you do realise that in Perl a hash and an 
associative array refers to the same thing.

>
>Godzilla!
>--
>
>
>print "Less Efficient Array Method:\n\n";
>print "\n\nMore Efficient No Array Method:\n\n";

define efficient.  If you are talking about memory usage,
you have no idea if the data is only being used for this task
or if it is needed else where.  If you are talking about speed
that is highly debatable and would require benchmarks to back 
it up.

BTW I'd prefer to compare them as numbers rather then the way 
Godzilla does it.  Otherwise what happens if you reach
version 12.226?  (Bugfix to version 12.22)


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

Date: Tue, 12 Jun 2001 14:27:26 GMT
From: "Joe Bloggs" <joe@bloggs.com>
Subject: Re: Table/Cell formatting with CGI.pm
Message-Id: <iFpV6.197581$OB1.3554444@nlnews00.chello.com>

> > Why do I need this?

Exactly!

Why oh why do people try and do so much with CGI.pm?

CGI.pm began as a useful interface for CGI programming that has bloated to a
level of abstraction that is pointless. In general use I find it very
inefficient, (it can take up to 25% more typing to create a <TABLE>  or
<INPUT> statement using CGI.pm's rather obscure syntax than by simply typing
in the HTML!

Also why does no-one seem to notice this?

Why learn CGI.pm's abstraction of HTML and put that in a program where you
are mixing languages? It is (IMO) much more useful to learn HTML and write
that in one file, and use Perl as the programming language with a template
module. At least then you can play around with the HTML as much as you want
without changing the code.

For example, cgi-lib.pl is a short sweet and to the point library that does
99% of what you need 99% of the time for CGI programming. CGI.pm is bloated,
full of pointless features (e.g. compare vi to MSword) and encourages poor
programming practice.








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

Date: Wed, 13 Jun 2001 06:21:23 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Table/Cell formatting with CGI.pm
Message-Id: <tie1j3j4pf2383@corp.supernews.com>

Joe Bloggs (joe@bloggs.com) wrote:
: Why oh why do people try and do so much with CGI.pm?

It's all a matter of taste and style.  I happen to like being able to
describe the structure of a page functionally.

: CGI.pm began as a useful interface for CGI programming that has bloated to a
: level of abstraction that is pointless. In general use I find it very
: inefficient, (it can take up to 25% more typing to create a <TABLE>  or
: <INPUT> statement using CGI.pm's rather obscure syntax than by simply typing
: in the HTML!

Yes, but CGI.pm makes it a little easier to do things like map elements of
an array into a table neatly, has small conveniences like defaulting the
value of a form field to the inbound parameter of the same name if one
exists, and so forth.

: Also why does no-one seem to notice this?

The bloat is there; some of us like the side effects. :)

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Magick is the art and science of causing change in conformity
   |   with Will."  - Aleister Crowley


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

Date: Mon, 11 Jun 2001 15:21:59 -0600
From: "Alex Tatistcheff" <alex_tatistcheff@NOSPAM.non.hp.com>
Subject: Win32 - Return DOS Errorlevel
Message-Id: <3b2537dd$1@hpb10302.boi.hp.com>

I need to shell out and run an exernal program then check the exit status of
the program to see if there was and error.  It will set the DOS errorlevel
to 1 if it did not complete successfully.  I'm using backticks to run the
program, i.e.

$result = `myprog.exe`;

How can I check the errorlevel after this process runs?

--
Alex Tatistcheff





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

Date: Wed, 13 Jun 2001 03:23:46 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Win32 - Return DOS Errorlevel
Message-Id: <3b26dc6d.41821892@news.erols.com>

On Mon, 11 Jun 2001 15:21:59 -0600, "Alex Tatistcheff"
<alex_tatistcheff@NOSPAM.non.hp.com> wrote:

>I need to shell out and run an exernal program then check the exit status of
>the program to see if there was and error.  It will set the DOS errorlevel
>to 1 if it did not complete successfully.  I'm using backticks to run the
>program, i.e.
>
>$result = `myprog.exe`;
>
>How can I check the errorlevel after this process runs?

Divide $? by 256.

  $result = `myprog.exe`;
  $errorlevel = $? >> 8;


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

Date: 13 Jun 2001 05:22:11 GMT
From: Homer.Simpson@mindspring.con (Homer Simpson)
Subject: Re: Win32::OLE Question
Message-Id: <9g6ta3$nnq$1@216.39.134.39>

There's nothing wrong (except the # sign which I'm sure you know <G>) with the 
bit you show here.

Test using the sample code from Microsoft's website
http://support.microsoft.com/support/kb/articles/Q214/7/97.asp

Which should run fine...
If it doesn't you have something wrong with Excel and need to troubleshoot 
that.  A quick reinstall/repair using Add/Remove programs should correct 
things.


In article <9g4q7k$j81$1@violet.singnet.com.sg>, "keng" <keng@spinalfluid.com> 
wrote:
>my script as below
>
>use Win32::OLE;
>#can work
>$ex = Win32::OLE->new('Word.Application') or die "oops\n";
>$ex->{Visible}=1;
>
>#cannot work
>#$ex = Win32::OLE->new('Excel.Application') or die "oops\n";
>#$ex->{Visible}=1;
>


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 1123
***************************************


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