[12877] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 287 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 28 18:07:17 1999

Date: Wed, 28 Jul 1999 15:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 28 Jul 1999     Volume: 9 Number: 287

Today's topics:
        "system"-command on dual-processor maschine <schmickl@magnet.at>
        [Summary] Korn Shell or Perl? (Michael Wang)
    Re: [Summary] Korn Shell or Perl? <tchrist@mox.perl.com>
    Re: [Summary] Korn Shell or Perl? (brian d foy)
    Re: a bit of a bind.. <keithmur@mindspring.com>
    Re: Any Suggestions? <gellyfish@gellyfish.com>
    Re: Any Suggestions? <revjack@radix.net>
    Re: CGI to verify the SSN <laurens@bsquare.com>
    Re: Check if 2 dates are in the same week <emschwar@rmi.net>
    Re: Don't want to make file that owner is "NOBODY" <vlad@doom.net>
    Re: Easy way to emulate Unix's "sort" command? <paul.glidden@unisys.com>
    Re: Easy way to emulate Unix's "sort" command? <gellyfish@gellyfish.com>
    Re: Easy way to emulate Unix's "sort" command? <emschwar@rmi.net>
    Re: ebcdic packed numbers <earlw@kodak.com>
    Re: File maintenance algorithm required <sariq@texas.net>
    Re: Filehandler... Can you email attachments??? <emschwar@rmi.net>
    Re: Filehandler... Can you email attachments??? <gellyfish@gellyfish.com>
    Re: How to find first occurance of white space... (Larry Rosler)
    Re: How to find first occurance of white space... <gellyfish@gellyfish.com>
    Re: module for Oracle? <metalogician@earthlink.net>
    Re: newby rename problem (help) (Larry Rosler)
        NEWSFLASH: Supremes rule anti-advert-ware illegal <tchrist@mox.perl.com>
    Re: NEWSFLASH: Supremes rule anti-advert-ware illegal (I R A Darth Aggie)
        OOP question. <coljac@home.com>
    Re: Pass by value or pass by reference? (Neko)
        perl fetching site requiring cookies newsmf@bigfoot.com
    Re: perl port to windows CE ? <gellyfish@gellyfish.com>
    Re: Problem with spam in this group <gellyfish@gellyfish.com>
    Re: Q: compare two arrays <gellyfish@gellyfish.com>
    Re: Simple form problem <gellyfish@gellyfish.com>
        Using regular expressions in $\ mgcesar@my-deja.com
        Variable in File name problems <richara@ecf.toronto.edu>
    Re: Variable in File name problems <mike@crusaders.no>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Wed, 28 Jul 1999 22:26:09 +0200
From: Thomas Schmickl <schmickl@magnet.at>
Subject: "system"-command on dual-processor maschine
Message-Id: <379F6761.117168A6@magnet.at>

I am working on a latex-frontend that should run (unchanged) on more
than one OS. Thats a job for Perl I think.To be sure that all works, I
usually
tested my app on a Linux and a Win95 box.
But now I bought a dual-processor system (2x celeron and an adapter) an
switched to WinNT, and now it happens:
When I called
system "latex myfile.tex";
all runs fine, latex converts my sourcefile and writes the dvi-file
but the next thing I call is
system "yap myfile.dvi" ....this is a win-dvi-previewer, the process is
started in thw WinNT-taskmanager, but the window never apears on
screen. It consumes no CPU-time but some memory.
when I start "yap myfile.dvi" from command prompt, all works fine.
With Linux, system "latex myfile.tex" works fine too, but system "xdvi
myfile.dvi"
shows a window, but I have to press the Cancel-Button there to get back
to my app. when I simply kill the xdvi-window, my app is terminated too.

On my previos computer, my app continued after closing the started
external app.

I seems that "system" behaves on my new computer totally different than
on my old one. Console-apps are executed normally, but GUI-Apps
seem to behave strange on both OS.

I am workin with PERL 5.005 and Perl/Tk8.1on both OS.

Mybe somebody can help me, how to deal with this.

Do not reply to this adress, please answer to: schmickl@magnet.at



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

Date: 28 Jul 1999 20:25:43 GMT
From: mwang@tech.cicg.ml.com (Michael Wang)
Subject: [Summary] Korn Shell or Perl?
Message-Id: <7nnp07$3qk$1@news.ml.com>

Uri Guttman  <uri@sysarch.com> wrote:
>
>then loop over reading lines from ypcat which was opened with a pipe:
>(untested of course)
>open( YP, 'ypcat beepers.byname|' ) || die "beepers suck anyway $!" ;
>while( <YP> ) {
>	next if /^YP_/ ;
>	blah blah
>}
>
>no memory used except per line and the pipe buffering.

Right. If the <YP> is the only stream, then above code is perfect solution.
However if the stream comes from different source via if-elsif-else, for loop,
then I see two solutions. 

brian d foy solution:

use builtin qw(sum);
my $status = 
sum(
   map  { ( get_pin(0, 1, 0, $opt_b, $_) )[0] }
   grep { ! /^YP_/ }
      ( $opt_d ne 'all' ? split(/,\s*/, $opt_d) :
         map 
            { 
            if    ( /local/ )  { keys %beeper_name } 
            elsif ( /yp/ )     { map {/(\w+)/} `ypcat -k beeper.byname` }
            else               { () }
            } split  /,/, $opt_b
 
      )
   );

comment: I don't how memory gets used, some say that the whole thing
         `ypcat -k beeper.byname` has to be used before processing. 
         If this is the case, then it is of no much difference than using
         temp variables. 
         The performance is bad because of deeply nested loops. By performance 
         I mean slowness.

Randal L. Schwartz solution:

    my @hits;
    if ($opt_d eq "all") {
      for ( split /,/, $opt_b ) {
        if (/local/) {
          push @hits, keys %::beeper_byname;
        } elsif (/yp/) {
          push @hits, map /(\w+)\s+\w+/, `ypcat -k beeper.byname`;
        }
      }
    } else {
      @hits = split /,\s*/, $opt_d;
    }
    for (@hits) {
      next if $_ eq "YP_LAST_MODIFIED";
      next if $_ eq "YP_MASTER_NAME";
      ($k) = get_pin(0, 1, 0, $opt_b, $_);
      $exit_status += $k;
    }

comment: this is more like shell programming style, except in shell we
         use stdout where "push @hits" is used, and then it pipes to
         the last block, where "for (@hits)" is used. If there is a lot of
         stuff pushed to @hits, memory may be exhausted. 

Conclusion: There is no equivalent in Perl for Korn Shell pipelines. One can
            use one of the two type of solutions shown above, but has to 
            accept its limitations. 
-- 
Michael Wang
http://www.mindspring.com/~mwang


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

Date: 28 Jul 1999 14:40:25 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: [Summary] Korn Shell or Perl?
Message-Id: <379f6ab9@cs.colorado.edu>

In comp.lang.perl.misc, mwang@tech.cicg.ml.com (Michael Wang) writes:
:Conclusion: There is no equivalent in Perl for Korn Shell pipelines. One can
:            use one of the two type of solutions shown above, but has to 
:            accept its limitations. 

BAH!

1) There is no such thing as a "Korn shell pipeline".  Get your
   history straight.  David hardly invented it.  Do you even know
   who did?

2) You're wrong about Perl.

	$pwdinfo = `domainname` =~ /^(\(none\))?$/
			? '< /etc/passwd'
			: 'ypcat  passwd |';
	open(PWD, $pwdinfo)   or die "can't open $pwdinfo: $!";
	while (<PWD>) { ........... }

    Yes, I could put the ?: in the open.

3) You're an idiot, a troll, or both.  Die. 

--tom
-- 
"OSI: Same day service in a nanosecond world" Van Jacobsen.
T-shirt he produced for an Interop, a few years ago.


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

Date: Wed, 28 Jul 1999 18:14:15 -0400
From: brian@pm.org (brian d foy)
Subject: Re: [Summary] Korn Shell or Perl?
Message-Id: <brian-ya02408000R2807991814150001@news.panix.com>

In article <7nnp07$3qk$1@news.ml.com>, mwang@tech.cicg.ml.com (Michael Wang) posted:

> Uri Guttman  <uri@sysarch.com> wrote:
> >
> >then loop over reading lines from ypcat which was opened with a pipe:
> >(untested of course)
> >open( YP, 'ypcat beepers.byname|' ) || die "beepers suck anyway $!" ;
> >while( <YP> ) {
> >       next if /^YP_/ ;
> >       blah blah
> >}
> >
> >no memory used except per line and the pipe buffering.
> 
> Right. If the <YP> is the only stream, then above code is perfect solution.
> However if the stream comes from different source via if-elsif-else, for loop,
> then I see two solutions. 

all of that can be done dynamically.  you don't have to know which 
filehandle you will be using ahead of time.

> brian d foy solution:
> 
> use builtin qw(sum);
> my $status = 
> sum(
>    map  { ( get_pin(0, 1, 0, $opt_b, $_) )[0] }
>    grep { ! /^YP_/ }
>       ( $opt_d ne 'all' ? split(/,\s*/, $opt_d) :
>          map 
>             { 
>             if    ( /local/ )  { keys %beeper_name } 
>             elsif ( /yp/ )     { map {/(\w+)/} `ypcat -k beeper.byname` }
>             else               { () }
>             } split  /,/, $opt_b
>  
>       )
>    );
> 
> comment: I don't how memory gets used, some say that the whole thing
>          `ypcat -k beeper.byname` has to be used before processing. 
>          If this is the case, then it is of no much difference than using
>          temp variables. 
>          The performance is bad because of deeply nested loops. By performance 
>          I mean slowness.


are you being dense on purpose?  i used the things you see because 
that was what you were trying to force on the problem.  i could 
just as easily incorporated Uri's comments into similar code.

as for performance, are you just guessing?  you haven't profiled
these, have you?  why do you think time is the only performance
factor?  what do you think the slow parts are?  or are you guessing
that everything is infinitely fast except a magical penalty for
"deeply nested loops"?  where's your shell code, btw?  let's see
some memory use / CPU use numbers that support your claims.

here's the deal - you don't know enough Perl and you are unwilling
to learn more.  you want to think that Perl is bad based on your
limited knowledge of it.  that's fine. if you don't like it, don't use 
it.  just quit whining about it.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>


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

Date: Wed, 28 Jul 1999 15:42:35 -0500
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: a bit of a bind..
Message-Id: <379F6B3B.E4A6244A@mindspring.com>

Bart Lateur wrote:
> 
> Tom Christiansen wrote:
> 
> >I'd be more apt to do something like this:
> >
> >    my $fh = do { local *FH };
> >    open($fh, $filename) || die "can't open $filename: $!";
> 
> I thought this code was a bit suspect, and it turns out I was right.
> Well, I get different results on 5.004 and 5.005, with this code:
> 
>         $fh = do { local *FH };
>         open FH, ">file1" or die "Can't open file1: $!";
>         open $fh, ">file2" or die "Can't open file2: $!";
>         print FH "Print to file 1\n";
>         print $fh "Print to file 2\n";
> 
> 5.005 indeed considers $fh and FH as being different filehandles.
> 
> On 5.004, both files are created, but file1 is empty, and file2 gets
> both lines of text. In other words: FH and $fh is ONE handle.
> 
> How can this be? Because local() temporarily saves the contents of the
> localized stuff on the stack, and then reinitializes it. At the end of
> the block, the original value is restored. It turns out that on 5.004 ,
> localized or not, it's still the *same typeglob*.
> 
> So the second open() statement closes the first file while it's still
> empty, and opens the second file for both $fh and FH.
> 
> So there's your reason for the elaborate way it is done in the modules.
> It looks like it's not longer necessary, from 5.005.
> 
Well, yeah, see my message of two days ago.  I assume it's the same
problem: *FH is not really local to the do block. 

I thought the discrepancy was maybe confined to typeglobs, but no. 
Check out:

  $th = 3;
  my $fh = do { local $th };
  print "The value of \$th is: $th\n";

Under my copy of 5.004_04 running on Linux, $th becomes undefined! 
(Under 5.004_05 on Win95, it's working fine).

This would seem to be in direct contradiction to the docs (perldoc
perlsub):

       A local() modifies its listed variables to be local to the
       enclosing block, (or subroutine, eval{}, or do) and any
       called from within that block.  A local() just gives
       temporary values to global (meaning package) variables.
       This is known as dynamic scoping.  Lexical scoping is done
       with "my", which works more like C's auto declarations.

       If more than one variable is given to local(), they must
       be placed in parentheses.  All listed elements must be
       legal lvalues.  This operator works by saving the current
       values of those variables in its argument list on a hidden
       stack and restoring them upon exiting the block,
       subroutine, or eval.

It gets more interesting though.  Try:

  $th = 3;
  my $fh = do { local $th; $th = 4 };
  print "The value of \$th is: $th\n";

That works properly under my copy of 5.004_04 on Linux.  And that may be
why it's rarely encountered: you wouldn't normally local'ize something
that you didn't actually define in the same block.  But Tom C. did in
his example, and that's why I noticed it.

It's the worst bug I've seen in Perl, so far.  (Hmmm.  Could it be an
incorrect optimization: "Why restore the old symbol if we never defined
a new one?").
-- 
 ... if the problem persists ... get  a  3.5  ft ... length of sucker rod
and have a chat with the user in question.
                -- Linux System Administration,
                   SYSLOGD (8), page 7
                   (Dealing with DOS attacks exploiting SYSLOGD)


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

Date: 28 Jul 1999 20:52:36 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Any Suggestions?
Message-Id: <7nnqik$5hu$1@gellyfish.btinternet.com>

On Wed, 28 Jul 1999 12:59:46 -0500 Steve Wagner wrote:
> I am new to perl/cgi and have written the following code. Do you have any
> suggestions on how to restructure the code? 

<snip>

#!/usr/bin/perl -w

use strict;

use CGI qw/:standard/;

For starters.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 28 Jul 1999 21:49:03 GMT
From: revjack <revjack@radix.net>
Subject: Re: Any Suggestions?
Message-Id: <7nntsf$kd1$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight

Eric The Read explains it all:

:"Steve Wagner" <steven_crazyman@worldnet.att.net> writes:
:> @pairs = split(/&/, $buffer);
:> foreach $pair (@pairs) {
:>     ($name, $value) = split(/=/, $pair);
:>     $value =~ tr/+/ /;
:>     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
:>     $FORM{$name} = $value;
:> }

:Ack!  Why roll your own CGI decoding routine (that doesn't properly
:handle multiple values for a single key) when CGI.pm will do it for you?

It's funny - while looking for something else on the perl.com "Perl and
CGI FAQ" a few minutes ago, I noticed this:


    Q2.1: Should I use the Perl CGI modules to code all 
    my CGI scripts? Isn't it easier to do it myself?

    It really depends on what you are trying to do. The 
    CGI modules should generally be used for heavy-duty 
    CGI scripts. For simple scripts, its is far easier 
    and quicker to roll your own or use CGI Lite (current 
    version is v1.62). If you really want, you can even 
    use the old Perl 4 cgi-lib.pl library. 


"easier and quicker to roll your own". Hm.

Of course, you're right that the above cargo-cult code chunk has
many flaws.


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

Date: Wed, 28 Jul 1999 13:57:26 -0700
From: "Lauren Smith" <laurens@bsquare.com>
Subject: Re: CGI to verify the SSN
Message-Id: <7nnqs7$agq$1@brokaw.wa.com>

wmichaeln@my-deja.com wrote in message <7nnma1$bq3$1@nnrp1.deja.com>...
>Hello,
>I need to write the CGI script to verify
>the SSN ( Social Security Number ).

By verify, what do you mean?
1) The entered number is in valid SSN format (ie. ###-##-####)?
2) The SSN actually belongs to someone?

>Does anyone know how to do that ?

1) Yeah, sure.  perlre - lots of good info in there.
2) You could call the Social Security Department (1-800-772-1213) and ask
them.
     When they tell you that such information is private, you could ask in
alt.2600.

>Thanks a lot !!!
Hey, no problem!!!

Lauren




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

Date: 28 Jul 1999 15:59:14 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Check if 2 dates are in the same week
Message-Id: <xkfso68jv0t.fsf@valdemar.col.hp.com>

Victor Eijkhout <eijkhout@prancer.cs.utk.edu> writes:
> David Cassell <cassell@mail.cor.epa.gov> writes:
> > skyfaye@my-deja.com wrote:
> > > I did check the FAQ before posting but no help.
> > 
> > But you apparently failed to notice the references to Date::Calc
> > and Date::Manip .  If you download 
> 
> Download from where? What is CPAN?

May I commend you, also, to the FAQ?  Wherein is answered the question:

"What modules and extensions are available for Perl?  What is CPAN?
Whatdoes CPAN/src/... mean?" (in perlfaq2)

Finding this was very very simple.  Just "perldoc perltoc", and search
for CPAN, and Bob's yer uncle.  It's a fairly safe bet (though,
admittedly, not 100%) that if something you don't understand is
referenced in the FAQ, that thing is probably also in the FAQ.

-=Eric


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

Date: 28 Jul 1999 18:01:23 GMT
From: <vlad@doom.net>
Subject: Re: Don't want to make file that owner is "NOBODY"
Message-Id: <7nnghj$cs3$1@news.servint.com>

>> The only way around this that I know of is installing the suexec module for Apache
>> (if Apache is the web server you are using of course)
>> Check out http://www.apache.org/docs/suexec.html for more details on suexec

> No it's not, use chmod.

Nice smart ass response... But if you read the subject is says:
Subject: Don't want to make file that owner is "NOBODY" 

So can you acommplish that with chmod?  No.


The data files are owned or need to be owned by a valid user.

If the data files need to be created/modified by a program/script
that is spawned by the web server, then that program will run under 
user: nobody, and therefore won't be able to modify a file owned by the 
valid user (i.e. the user the files are owned by), unless of course the 
file is mode 0666 or at least 0606.

But now, what stops another user on the same system from writing his own
program/script that he can call via a web browser that runs under user:nobody 
as well, and can view/modify any data files owned by nobody or that are world 
writeable.

Thats one reason suexec exists...

-v


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

Date: Wed, 28 Jul 1999 15:24:30 -0500
From: "Paul Glidden" <paul.glidden@unisys.com>
Subject: Re: Easy way to emulate Unix's "sort" command?
Message-Id: <7nnotu$ao4$1@eanews1.unisys.com>

Don't be too upset about it, I hate reading those things, sometimes the
explanations are just not up to snuff, that's where a book like the camel
comes in handy.

>Doh!  I'll certainly peruse the FAQs next time; I didn't think the
>help was that elaborate!
>
>>





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

Date: 28 Jul 1999 20:04:13 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Easy way to emulate Unix's "sort" command?
Message-Id: <7nnnnt$5df$1@gellyfish.btinternet.com>

On Wed, 28 Jul 1999 18:38:53 GMT Jim Hutchison wrote:
> Newbie question here...
> 
> I'd like to sort a four-column table on a specific field.  Perl's sort
> is only for a simple list...
> 

I would read the article entitled :

  =head2 How do I sort an array by (anything)?

in perlfaq4.  Of course after you have read that and possibly still
have difficulties please feel free to ask again.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 28 Jul 1999 15:49:48 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Easy way to emulate Unix's "sort" command?
Message-Id: <xkfyag0jvgj.fsf@valdemar.col.hp.com>

jimhutchison@metronet.ca (Jim Hutchison) writes:
> Doh!  I'll certainly peruse the FAQs next time; I didn't think the
> help was that elaborate!

Not to pick on you, Jim, but this is great!  See, folks, we don't REALLY
hate newbies-- but Perl *does* have a wealth of documentation that comes
right with it on your very own hard drive.  If you can learn to consult
it first, then you can get faster and better answers than if you try
posting here.

Good job for learning that, Jim. :)

-=Eric


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

Date: Wed, 28 Jul 1999 16:30:06 -0400
From: Earl Westerlund <earlw@kodak.com>
Subject: Re: ebcdic packed numbers
Message-Id: <379F684E.630A@kodak.com>

Mark-Jason Dominus wrote:
> 
> In article <x7so68spd3.fsf@home.sysarch.com>,
> Uri Guttman  <uri@sysarch.com> wrote:
> >on a similar note, check out mjd's page on the perl of the 60's:
> >
> >http://www.plover.com/~mjd/perl/perl.html#perl67
> 
> I should point out that the folks who actually know about this who
> have written in over the years are in overwhelming agreement that PL/I
> was *not* very much like Perl.

I had a college professor who described PL/I as "8,000 statements in
search of a language."

I programmed in PL/I.  You could do anything in it... but you didn't
want to.
-- 
+-----------------+----------------------------------------+
| Earl Westerlund | Kodak's Homepage: http://www.kodak.com |
+-----------------+----------------------------------------+
|  The opinions expressed herein are mine and mine alone   |
|     (most people don't seem to want them anyway)         |
+----------------------------------------------------------+


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

Date: Wed, 28 Jul 1999 16:24:49 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: File maintenance algorithm required
Message-Id: <379F7521.BEF6E239@texas.net>

Roger Musson wrote:
> 
> I need to add a line of data to the front of a file (i.e. not
> appending). 
>
> Thanks,
> Roger Musson

The FAQ list is your friend.

perlfaq5:

How do I change one line in a file/delete a line in a file/insert a line
in the middle of a file/append to the beginning of a file?

- Tom


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

Date: 28 Jul 1999 14:11:46 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Filehandler... Can you email attachments???
Message-Id: <xkf7lnklekd.fsf@valdemar.col.hp.com>

"Peter Robichaud" <probichaud@nonlinear.ca> writes:
> I was wondering if it was possible to send a file attachment out with a form
> generated email...

Anything's possible, as long as you read and understand the appropriate
RFCs....

> is there a special script or program I need to perform this sort of
> operation? or is it not possible at all?

Look at MIME::Lite (available from CPAN).  It's probably what you want.

-=Eric


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

Date: 28 Jul 1999 20:53:40 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Filehandler... Can you email attachments???
Message-Id: <7nnqkk$5i1$1@gellyfish.btinternet.com>

On Wed, 28 Jul 1999 13:58:12 -0400 Peter Robichaud wrote:
> thanks,
> 
> I was wondering if it was possible to send a file attachment out with a form
> generated email...
> 

The module MIME::Lite available from CPAN (for what appears to be the
third time today).

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Wed, 28 Jul 1999 13:24:05 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to find first occurance of white space...
Message-Id: <MPG.120906bf5c672cf2989d67@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7nngf9$7kq$1@nnrp1.deja.com> on Wed, 28 Jul 1999 18:00:13 
GMT, cramey@my-deja.com <cramey@my-deja.com> says...
> i have a string that i would like to shorten to the data before the
> first space,
> 
> ex.
> 
> 123456 don't want any of this text in string
> ^^^^^^
> need this

Let me count the ways.  Did you try *any* of them?

I'll assume that you really mean the first space character ' ', and the 
last way requires that there be one.

perldoc perlop, perldoc perlre:

  $string =~ s/ .*//s;

perldoc -f split:

  $string = (split $string, / /, 2)[0];

perldoc -f substr, perldoc -f index:

  substr($string, index $string, ' ') = "";

Others -- comparably efficient, though?  Have "Fun With Perl"!
  
-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 28 Jul 1999 20:49:17 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How to find first occurance of white space...
Message-Id: <7nnqcd$5hq$1@gellyfish.btinternet.com>

On Wed, 28 Jul 1999 18:00:13 GMT cramey@my-deja.com wrote:
> i have a string that i would like to shorten to the data before the
> first space,
> 

First three off the top of my head :


#!/usr/bin/perl -w

use strict;

my $orig_string = '12345 blah woof weee';

my $new_string;

($new_string) = $orig_string =~ /^(\S+)\s+/;

print $new_string,"\n";

$new_string = substr $orig_string,0 , index $orig_string,' ' ;

print $new_string,"\n";

($new_string,()) = split / /,$orig_string;

print $new_string,"\n";

You might want to be reading the perlre and perlfunc manpages for an
explanation.

if you are concerned about the performance you might also be interested
in reading about the Benchmark module.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Wed, 28 Jul 1999 17:48:57 -0400
From: metalogician <metalogician@earthlink.net>
Subject: Re: module for Oracle?
Message-Id: <379F7AC8.64E9C7DF@earthlink.net>



David Cassell wrote:

> bing-du@tamu.edu wrote:
> >
> > Hello there,
> >
> > I am using Perl 5.005_02.  In this version, is there any
> > embedded standard module that can be used to access Oracle database?
> > What is the name of the module?  Thanks.
>
> Get the DBI module, and DBD::Oracle if you don't already have
> tem on your system.  I *think* that 5.005_02 has DBI already,
> but you should be able to check easily enough.  Just type:
>
> perldoc DBI
>
> and see if you get the manpage.  No manpage?  No DBI module
> yet.
>
> HTH,
> David
> --
> David Cassell, OAO                     cassell@mail.cor.epa.gov
> Senior computing specialist
> mathematical statistician

perldoc DBI and perldoc Oraperl are the two commands I found myself
entering
most often.

Oraperl is the specialized interface, containing a lot of special things
that you won't find in DBI.  Especially noteworthy are the shell
environment variables such as
TWO_TASK and ORACLE_HOME detailed in perldoc Oraperl and
perldoc DBI::Oracle.

Oraperl is a lot of fun.




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

Date: Wed, 28 Jul 1999 13:27:07 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: newby rename problem (help)
Message-Id: <MPG.12090773f7a31689989d68@nntp.hpl.hp.com>

In article <379F4C09.DDA738CE@mail.cor.epa.gov> on Wed, 28 Jul 1999 
11:29:29 -0700, David Cassell <cassell@mail.cor.epa.gov> says...
> Tad McClellan wrote:
> > David Cassell (cassell@mail.cor.epa.gov) wrote:
> > 
> > : [2] if you want to keep the old name, you *have* it - it's
> > :     %cgi_cfn{'upload'} and you can save it somewhere
> >       ^^^^^^^^^^^^^^^^^^
> > 
> >         $cgi_cfn{'upload'}   # typo, I'm sure.
> 
> D'OH!  Ouch.  Thanks for policing the careless there, Tad.
> 
> At least this typo isn't as shocking as yesterday's.  And
> a big thanks to Larry, Jonathan, and everyone else who was
> so kind as to point it out...

All of us off-line, apparently.  Maybe it wasn't such a good idea for 
you to mention it in public.  Now everyone will hie to Deja.com to see.  
:-)

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


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

Date: 28 Jul 1999 14:28:01 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: NEWSFLASH: Supremes rule anti-advert-ware illegal
Message-Id: <379f67d1@cs.colorado.edu>

							March 32, 2002

Washington DC - After more than two years in and out of the courts,
The Supreme Court today upheld the lower courts' ruling that the viewing
of a website in any layout and format other than the one set-up by that
site's authors was illegal.

The original suit was brought by a cartel of powerful web businesses
all over the country, initially sponsored by the Direct Marketers
Association (DMA). Defendants included Junkbusters Inc, a mysterious
Perl programmer named ``Abigail'', and thirty-four other businesses
and individuals who had created software to let users by-pass blinking
pictures, pop-ups advertisements, and intended controls on font, color,
size, and backgrounds.

This means that the lower courts' previous award of seventeen billion
dollars is due immediately. Upon hearing the ruling, Junkbusters quickly
filed for bankruptcy, but it is widely believed that their the software
authors and corporate directors and their children's children's children
will all be personally liable. Furthermore, the text-based web browser,
Lynx, is now illegal to use except on your own sites, as are any proxies
that filter or rewrite incoming webpages in any way, including the
suppression of blinking text. Both Microsoft and AOL Microsystems must
immediately issue mandatory patches to their browsers to disable the users
from being able to disable automatic loading of images or moving GIFs.
Users not applying the patch will be subject to criminal persecution
and forfeiture of their first-born child.

A joint statement issued by the not-for-profit American Association
for the Blind and the International Epileptics Support Center decried
the decision as essentially barring their members from the web. The
DMA praised the decision, stating that ``the needs of Commercial
Enterprise would no longer be stymied by Communists and other PBS and
NPR sympathizers.''

President Gore also weighed in with his pleasure at the decision,
levelly intoning in his best computer-speech-simulator simulation, ``This
just blasted away the roadblocks in my Information Superhighway. Next
term, we're going to the stars!'' This appeared to be an oblique
reference to his constituents' efforts to gather re-election funds
through click-through advertising fees. The president was in closed
conference this afternoon with top members of Congress and his InfoBahn
Czar, apparently discussing how soon they could implement a new,
mandatory A-chip to be placed in televisions and VCRs so TV and video
advertisements could no longer be avoided by consumers through editing,
muting, fast-forwarding, or channel-surfing.

A vexing and mysterious hacker squad known only as the Spamvert Amnesty
League (SAL) briefly seized control of the White House website, where
they replaced the campaign advertisements with malicious links to
charity and humanitarian sites around the world, as well as with threats
of revenge against spamvert supporters everywhere. At the same time,
a digitized parody video of _A_Clockwork_Orange_ appeared on the Fox
channel's satellite download, complete with credits to SAL.  The bogus
remake of Kubrick's disturbing masterpiece this time depicted American
consumers held prisoner as commercial advertising was blasted into
their propped-open eyes and ears. Credits on the video listed the SAL.
Their choice of the European anthem, Beethoven's Ninth Symphony, has
led authorities to look in Europe for their homebase, as it is widely
understood that Europe provides refuge to uncounted intellectuals,
artists, anti-commercial socialist sympathizers, and other commie rats,
all hiding from the righteous wrath of invasive American technoplutocracy.

Twenty-eight prominent American cyberbusiness leaders who spoke on
condition of anonymity all felt that pursuing nuclear options against
SAL would not be unjustified in defense of American national interests,
and that collateral damages in Europe would be a small price to pay,
especially now that their advertising revenues were guaranteed.

    +--------------------------------------------------------------+
    | ``Contempt, rather than celebration, is the proper response  |
    |   to advertising and the system that makes it possible.''    |
    |                             --Neil Postman                   |
    |   !!!This quote hacked into this press release by SAL!!!     |
    +--------------------------------------------------------------+



-- 
    "No, I'm not going to explain it. If you can't figure it out, 
     you didn't want to know anyway..." --Larry Wall 


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

Date: 28 Jul 1999 21:15:44 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: NEWSFLASH: Supremes rule anti-advert-ware illegal
Message-Id: <slrn7puss5.hvb.fl_aggie@thepentagon.com>

On 28 Jul 1999 14:28:01 -0700, Tom Christiansen <tchrist@mox.perl.com>, in
<379f67d1@cs.colorado.edu> wrote:

+ Users not applying the patch will be subject to criminal persecution
+ and forfeiture of their first-born child.

And this is bad...how? ;)

James


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

Date: Wed, 28 Jul 1999 21:09:19 GMT
From: Colin Jacobs <coljac@home.com>
Subject: OOP question.
Message-Id: <379F7282.4DC7A1BA@home.com>

Hi there, O Wise and Friendly Perl Gurus.

Although I've used Perl for a while, I haven't done much OOP with it, so
I'm trying to brush up. I came across an exercise that instructed me to
create a class C that inherits from classes A and B in that order. The
trick was, if a C object should have a particular value (in this case,
instance variable "name" has value "blah") the order of inheritance
should be reversed.

It seems to me that although it's easy to check the name of a C object
at the point at which it is instantiated or the name is modified, and
reverse @C::ISA accordingly, this will affect all C's. What am I missing
that lets you alter the order of inheritance of a particular object as
opposed to the whole class? I should hope it was impossible, but knowing
Perl and it's OOP, I wouldn't be surprised. :)

- Colin

-- 
------------
Colin Jacobs    col@earthling.net
     http://colspace.dhs.org


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

Date: 28 Jul 1999 21:45:55 GMT
From: tgy@chocobo.org (Neko)
Subject: Re: Pass by value or pass by reference?
Message-Id: <7nntmj$bi7$0@216.39.141.200>

On 28 Jul 1999 03:14:55 -0400, Uri Guttman <uri@sysarch.com> wrote:

>>>>>> "N" == Neko  <tgy@chocobo.org> writes:
>
>  N> Array and hash elements are still aliased though.  Neither aggregates nor
>  N> elements are passed by value.
>
>i seem to be wrong about arrays but hashes are passed by value as that
>makes no sense otherwise.
>
>perl -le '%a=(1,2);@b=(3,4);sub{ $_++ for @_}->(%a,@b);print %a,@b'
>1245

I was so sure that hashes were aliased as well.  Hmm... looks like I'm
confusing hashes with hash *slices*.

perl -le '%a=a..h;sub{$_=uc for @_}->(@a{c,e});print %a'
abcDeFgh
-- 
Neko | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=


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

Date: Wed, 28 Jul 1999 20:34:48 GMT
From: newsmf@bigfoot.com
Subject: perl fetching site requiring cookies
Message-Id: <7nnph8$dth$1@nnrp1.deja.com>

Hi -

I'm using a perl program and lwp to retrieve html pages. However,
there are some sites like http://www.newsunlimited.co.uk/ or
http://my.yahoo.com/ that require the user agent to accept cookies
before they serve a page. Can perl retrieve pages from such sites?

Thanks for helping.

Cheers,

Marc

++
newsmf@NOSPAMbigfoot.com
remove NOSPAM


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 28 Jul 1999 21:01:17 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: perl port to windows CE ?
Message-Id: <7nnr2t$5i6$1@gellyfish.btinternet.com>

On Wed, 28 Jul 1999 09:58:28 -0500 Dan Baker wrote:
> Has there been any action to port perl to windows CE? 
> 

I would would hope that its waaay behind the Palmpilot and the Psion 5
in priority. 

Of course if you have the CE SDK you could try yourself and report back ...

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 28 Jul 1999 21:07:02 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Problem with spam in this group
Message-Id: <7nnrdm$5i9$1@gellyfish.btinternet.com>

On 28 Jul 1999 09:59:30 -0600 llornkcor@earthlink.net wrote:
> SPAM is sent through the newsgroup servers, I believe. I just ignore
> them.
> 

What are you on about ?  Would you care to the examine the headers of
the next bit of junk you get and reconsider that.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 28 Jul 1999 20:07:53 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Q: compare two arrays
Message-Id: <7nnnup$5dl$1@gellyfish.btinternet.com>

On Wed, 28 Jul 1999 13:31:46 -0500 milan andric wrote:
> 
> I'm a little baffled on how to compare two arrays and print the
> elements that exist in both.
> 

I would recommend reading the section entitled :

=head2 How do I compute the difference of two arrays?  
       How do I compute the intersection of two arrays?

in the document perlfaq4.  If after you have tried the method described
there and still have difficulties please feel free to ask again with
a sample of the code you are having trouble with.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 28 Jul 1999 21:17:46 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Simple form problem
Message-Id: <7nns1q$5ic$1@gellyfish.btinternet.com>

On Tue, 27 Jul 1999 16:21:05 -0400 The Barry Family wrote:
> I copied the code from a tutorial at
> http://www.speakeasy.org/~cgires/cgi-tour.html directly to a test file
> on my web page.

I would strongly suggest that you look at Lincoln Stein's pages at
<http://stein.cshl.org> as this is most definitely not the most
highly recommended way to be doing things with a modern version of Perl.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Wed, 28 Jul 1999 21:23:52 GMT
From: mgcesar@my-deja.com
Subject: Using regular expressions in $\
Message-Id: <7nnsd0$fsi$1@nnrp1.deja.com>

Does any body know how (or if) regular expression can be used as an
INPUT_RECORD_SEPERATOR ($\)?  I have a file to parse where the 'RS' in
Awk would be defined as "\\\xB3{1,4}" (ie 1 to 4 hex B3s).
Any ideas?

Michael


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 28 Jul 1999 20:00:21 GMT
From: RICHARDS  AMANDA DAWN <richara@ecf.toronto.edu>
Subject: Variable in File name problems
Message-Id: <Pine.SGI.3.96.990728155509.11451C-100000@skule.ecf>

When opening a file, I am placing a variable in the file name.  I have
done this before and have been successful.  I do not know what I am doing
incorrectly.  The only thing different is that I am defining the
variable by using the split command as opposed to the HTML form(action
and submit). Please help.

My code:

$PreviousInfoPath = "~mypath/$PFcode.txt";

open(PreviousInfo, "<$PreviousInfoPath") or die "Cannot open $!";
	$previousProgramInfo = <PreviousInfo>;
close PreviousInfo

This gives me a server error, but when I subsititute 10000004 for $PFcode
(what it is supposed to be), my program works fine.

Amanda



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

Date: Wed, 28 Jul 1999 22:45:17 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: Variable in File name problems
Message-Id: <IZJn3.502$ZU.4329@news1.online.no>


RICHARDS AMANDA DAWN <richara@ecf.toronto.edu> wrote in message
news:Pine.SGI.3.96.990728155509.11451C-100000@skule.ecf...
> When opening a file, I am placing a variable in the file name.  I have
> done this before and have been successful.  I do not know what I am doing
> incorrectly.  The only thing different is that I am defining the
> variable by using the split command as opposed to the HTML form(action
> and submit). Please help.
>
> My code:
> $PreviousInfoPath = "~mypath/$PFcode.txt";
> open(PreviousInfo, "<$PreviousInfoPath") or die "Cannot open $!";
> This gives me a server error, but when I subsititute 10000004 for $PFcode
> (what it is supposed to be), my program works fine.

I would suggest to write the open statement like this:
open(PreviousInfo, "<$PreviousInfoPath") or die "Cannot open
$PreviousInfoPath - $!";

That way, you'll be told what file the program tries to open.

My guess is that the tilde character is your problem, so I'll quote recipe
7.3 from the Perl  Cookbook:

$PreviousInfoPath =~ s{ ^ ~ ( [^/]* ) }
               { $1
                    ? (getpwnam($1))[7]
                    : ( $ENV{HOME} || $ENV{LOGDIR}
                         || (getpwuid($>))[7]
                      )
}ex

--
Trond Michelsen





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

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

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


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