[13714] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1124 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 20 02:05:30 1999

Date: Tue, 19 Oct 1999 23:05:10 -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: <940399510-v9-i1124@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 19 Oct 1999     Volume: 9 Number: 1124

Today's topics:
    Re: %hash array problem <jon@midnightbeach.com>
    Re: Baffled! <lr@hpl.hp.com>
    Re: Beginner question - chomp <yosikim@lgeds.lg.co.kr>
        Creating files in perl scripts on NT <n2142945@droid.fit.qut.edu.au>
    Re: creating variable question? (Tad McClellan)
        Emulating grep (and map) syntax? <jon@midnightbeach.com>
    Re: Further Musings (Craig Berry)
    Re: Help - Can't figure this out <partner@casinofantasy.com>
    Re: Help - Can't figure this out (Abigail)
    Re: help with substrings (Tad McClellan)
    Re: How to print password by "crypt" ? <hmaster@factory.co.kr>
    Re: I pass by reference, but my array is unchanged. (Tad McClellan)
    Re: I pass by reference, but my array is unchanged. (Tad McClellan)
    Re: I pass by reference, but my array is unchanged. <slanning@bu.edu>
    Re: Importing symbols and memory usage - Apahce::Regist <ltl@rgsun40.viasystems.com>
    Re: linux perl editor? <neil@pacifier.com>
    Re: Matching an asterisk (Abigail)
    Re: Matching an asterisk <ltl@rgsun40.viasystems.com>
    Re: Matching an asterisk <ltl@rgsun40.viasystems.com>
        Missing Good Old Utilies <th.bossert@z.zgs.de>
        New Perl/TK Tutorial on perl.com netwit2@my-deja.com
    Re: New Perl/TK Tutorial on perl.com (Ilya Zakharevich)
    Re: newbie - counting data lines <r42317@email.sps.mot.com>
    Re: newbie <lr@hpl.hp.com>
    Re: OT: Newsreader? a.k.a Re: Ignore the idiots (J. Moreno)
    Re: Problem w/ PERL and SQL (Sam Holden)
        Program to use cgi with out a server? lil help deltren@my-deja.com
    Re: Q: Truncate string length? (Craig Berry)
    Re: Want to CGI for checking Domain name at Internic (David Efflandt)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 19 Oct 1999 22:58:47 -0700
From: Jon Shemitz <jon@midnightbeach.com>
Subject: Re: %hash array problem
Message-Id: <380D5A17.E4E3AC59@midnightbeach.com>

Marc wrote:

> foreach (keys %mydata)
> { print "$_ = $mydata{$_}\n";  }
> 
> this is the proper solution.

Is it? It sure seems to me that this is iterating over the hash to
produce a list (in keys), then iterating over the list (in foreach),
then going back and doing random access to the hash (in the lookup).
Seems like

  my ($key, $value);
  while (($key, $value) = each %mydata) {print "$key == $value\n";}

is better.

In fact, I just supplemented gedanken experiments with real ones. On a
PII 300 laptop, Win 98, ActivePerl, iterating a 9265 entry hash, saving
each value to a my var:

* "foreach keys" gets  75,721 iterations/second
* "while each"   gets 236,091 iterations/second

Pretty close to 3 to 1.

# Just another WANNABE Perl hacker

-- 

http://www.midnightbeach.com    - Me, my work, my writing, and
http://www.midnightbeach.com/hs - my homeschool resource pages


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

Date: Tue, 19 Oct 1999 21:36:49 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Baffled!
Message-Id: <MPG.1276e68d5b9df7ee98a0c7@nntp.hpl.hp.com>

In article <7ug01d$8er$1@engnews2.Eng.Sun.COM> on 18 Oct 1999 20:30:37 
GMT, Joe Petolino <petolino@joe.Eng.Sun.COM> says...
> >A few weeks ago, I suggested that the use of a literal string as the 
> >first argument to split() should draw a warning.  If that were the case 
> >(and assuming the programmer used '-w'), this incessant problem *might* 
> >go away!

When you quote someone verbatim, it is polite and proper to provide some 
form of attribution.

> Good idea.  Is it even defined what happens when you use a literal string
> that can't be parsed as a regular expression match?  The documentation of
> split(), both in the Camel book and in perlfunc, says nothing about it
> except for the special case of ' '.

I just tried it.  (Why didn't you?)  I'm not at all surprised that the 
quoted string is parsed as a regex, even if it is invalid.  That's 
because it *is* a regex, as documented.  (I tried '(' for simplicity.  
Why didn't you?)

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


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

Date: Wed, 20 Oct 1999 13:22:56 +0900
From: Yongsik Kim <yosikim@lgeds.lg.co.kr>
Subject: Re: Beginner question - chomp
Message-Id: <380D43A0.DAFBC2A7@lgeds.lg.co.kr>



Boon Hoo wrote:
> 
> Hi,
> 
> I understand that chomp removes newline from the end of a string. I was
> trying it one day to format some HTML files(grab each line, remove
> newline, and write it to a text-file), when I found out that if I had
> earlier "ftp" the files using binary mode, chomp doesn't seem to work -

I think it worked. 
set $/ = "\r\n"; to change INPUT_RECORD_SEPARATOR
   (perldoc perlvar, and find the meaning of $/)
or 
if you doesn't want to changed the value, just add  s/\r$//; just
above the chomp() line

> i saw many  ^M control characters instead in my output file. What is the
> correct way to remove newlines from textfiles transferred through binary
> mode?
> 
> TIA,
> Jonathan


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

Date: Wed, 20 Oct 1999 14:33:04 +1000
From: DAVID GODFREY <n2142945@droid.fit.qut.edu.au>
Subject: Creating files in perl scripts on NT
Message-Id: <Pine.GSO.4.10.9910201432140.25930-100000@droid.fit.qut.edu.au>

Hello,

I have written a Perl script which is meant to append text to a file each
time it is run.  The script works fine when I run it on my stand alone 95
machine using a perl interpreter, but when I placed it onto the NT server
it doesn't create the files that it is meant to write to.  No error
messages are given.  I am guessing that the problem may be to do with NT
permissions.  I would appreciate if anyone has any ideas if they can reply

The code I use to open the file is

$outputfile="massmin.log";

open(OUT_FILE,">>$outputfile");                                                


Thankyou in advance

david



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

Date: Tue, 19 Oct 1999 18:19:52 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: creating variable question?
Message-Id: <8qqiu7.u6d.ln@magna.metronet.com>

beta1_version@yahoo.com wrote:

: I want to do a
: system("cat $one $two $three);


   No you don't.

   You want to check the return value from your system() call.

      system("cat $one $two $three") && die "problem running system()";

   :-)


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


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

Date: Tue, 19 Oct 1999 22:25:11 -0700
From: Jon Shemitz <jon@midnightbeach.com>
Subject: Emulating grep (and map) syntax?
Message-Id: <380D5237.73619DCF@midnightbeach.com>

I had a case where I wanted to check if a list contained a given value.

  grep /^$next$/, @thislist

worked fine, but as @thislist is potentially rather long, seemed like
overkill: I'd prefer an operator that stopped on the first match, and
returned a simple boolean scalar, rather than a list of all matches.

  sub anyExpr ($@) {
    my ($match, @list) = @_;
    die "\nFirst argument to anyExpr must be an expr\n" 
	if ref $match ne '';
    foreach (@list) { return 1 if m/$match/; }
    return 0;
  }

  sub anyBlock (&@) {
    my ($match, @list) = @_;
    die "\nFirst argument to anyBlock must be a block\n" 
	if ref $match ne 'CODE';
    foreach (@list) { return 1 if &$match; }
    return 0;
  }

were certainly straightford enough - but I'd like to have a single
function that can take an expr or a block, just like grep and map. I've
tried a few things (including, yes, reading the FAQ and using perldoc
-q), but I can't seem to do this.

Is it possible to do what I want, here? Or does this sort of overloading
rely on compiler magic?

-- 

http://www.midnightbeach.com    - Me, my work, my writing, and
http://www.midnightbeach.com/hs - my homeschool resource pages


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

Date: Wed, 20 Oct 1999 04:38:56 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Further Musings
Message-Id: <s0qhr0rcr0191@corp.supernews.com>

Wyzelli (wyzelli@yahoo.com) wrote:
: Craig Berry <cberry@cinenet.net> wrote in message
: news:s0p7q2hcr0166@corp.supernews.com...
: > Not true.  On Unix-ish systems, the epoch is midnight Jan 1 1970 UTC.
: > localtime returns years since 1900.  Big difference.
: 
: I guess that varies by system, as I recall that on Mac's the epoch is a
: different date again, so that further confuses things!

That's why I specfied Unix-ish, and even that may hide some weaseling
(Every Un*x variant I've ever met uses the 1970 epoch, but I haven't met
'em all).  Under VMS it's some date around 1860 IIRC.  And so forth.

I'm reminded of my all-time favorite technical-book footnote, in a Rogue
Wave C++ library manual, in the section discussing their time
representation which used epoch 1900.  The footnote to this piece of
information was something like "Though many modern operating systems place
the origin of time on January 1, 1970, our extensive research proves
conclusively that time actually began significantly earlier than that." 

: I guess similar things could be applied to the month which is 0 indexed.

Yes, though again this was intended as a convenience, perhaps with better
justification than the year-1900 fiasco.

: How hard would it have been to make localtime return the month rather
: than an index?

Utterly, mind-numbingly trivial, of course.  Almost certainly a
single-line, probably less than four character change to the localtime
implementation.

: I guess hindsight is a wonderful thing!  And good programmers probably just
: cut and paste a standard block for their date calls anyway so once you got
: it right you never need to do it again... but imagine the drop off in ng
: questions (about time and date related stuff anyway).

Exactly.  You get used to it, and after a while the idea of the month
beign 1..12 rather than 0..11 sounds bizarre, contrived, somehow obscene.
Isaac Asimov once pointed out that if you showed a chemist a formula
containing the (nonexistent) chemical symbol 'Ld' the chemist would
probably take a long time to guess you might mean 'Lead' -- but put 'Pb'
in, and the chemist will read that as 'Lead' without even being aware of
the transformation.

: Oh to dream...

Just get working on that time machine, okay?  After visiting Bell Labs
1975, I have stops to make at CERN 1989 to get HTTP_REFERER spelled right,
and at Microsoft 1980 to force them to use / as the directory separator.

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--  http://www.cinenet.net/users/cberry/home.html
   |   "They do not preach that their God will rouse them
      a little before the nuts work loose." - Kipling


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

Date: Wed, 20 Oct 1999 15:07:59 +1000
From: Anonymous <partner@casinofantasy.com>
Subject: Re: Help - Can't figure this out
Message-Id: <380D4E2F.B1ABC968@casinofantasy.com>

your actually a female who is a perl hacker? way too cool marry me please please
please.
;).


Abigail wrote:

> AcCeSsDeNiEd (dillon_rm@magix.com.sg) wrote on MMCCXXXVIII September
> MCMXCIII in <URL:news:380a2aca.11379580@news.magix.com.sg>:
> ;; Hi folks. Firstly, sorry for the intrusion. I know this is not the
> ;; right place to post my question, but I have not been able to get into
> ;; comp.infosystems.www.authoring.cgi for the past 2 days. Yes, I do know
> ;; about their new regulation with first time posters and their "approve"
> ;; stuff. But I still don't see my post.
>
> Why should this group suffer because you have problems posting in
> comp.infosystems.www.authoring.cgi? Why not post in alt.bork.bork?
> Or in sci.math?
>
> ;; And for this, we want to make use of the same alphabet table A-Z.
> ;; I'm not allowed to create a second alphabet table A-Z which will
> ;; obviously solve the problem.
>
> If you are make arbitrary restrictions for yourself, and are seeking an
> algorithm to solve this - try rec.puzzles. This has absolutely nothing
> to do with any programming language; and specially not Perl.
>
> ;; I have therefore added two Radio buttons named "Find Company Names by
> ;; using an Alphabet" & Find Category Names by using an Alphabet"
> ;;
> ;; I am now stuck here, I don't have idea how to combine the two into one
> ;; (Radio and alphabet table A-Z) and sent the info to my cgi script to
> ;; be processed. The info that my script must get from the html form are
> ;; the radio button selection and the alphabet selected.
>
> It looks you are on the wrong track. Backtrack, and try again.
>
> Abigail
> --
> perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
>          / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
>          % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
>          BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
>
>   -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
>    http://www.newsfeeds.com       The Largest Usenet Servers in the World!
> ------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----



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

Date: 20 Oct 1999 00:15:07 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Help - Can't figure this out
Message-Id: <slrn80qjub.fji.abigail@alexandra.delanet.com>

Anonymous (partner@casinofantasy.com) wrote on MMCCXLI September MCMXCIII
in <URL:news:380D4E2F.B1ABC968@casinofantasy.com>:
`` your actually a female who is a perl hacker? way too cool marry me please please
`` please.


Leave your teenage attitude at home.



Abigail
-- 
package Z;use overload'""'=>sub{$b++?Hacker:Another};
sub TIESCALAR{bless\my$y=>Z}sub FETCH{$a++?Perl:Just}
$,=$";my$x=tie+my$y=>Z;print$y,$x,$y,$x,"\n";#Abigail


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Tue, 19 Oct 1999 18:13:13 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: help with substrings
Message-Id: <pdqiu7.u6d.ln@magna.metronet.com>

Johannes (jspangen@my-deja.com) wrote:
: In article <380B817A.1045A3F1@unity.ncsu.edu>,
:   kpmonroe@unity.ncsu.edu wrote:


: > @data = <NEW>;
: This reads only the first line in the first element of @data,


   No it doesn't.

   The <> (input operator) reads _all_ of the remaining lines
   when in list context, as it is there.


: you can directly use a simple $line eg.


   I agree that there is no need to have the whole thing in
   memory though.


: I think you wanted to do something like:
: #!/usr/local/bin/perl -w
: use strict;
: open DATA, "./data" or die "Can't open data:$!";
: my $line;
: while (defined ($line = <DATA>)) {
:   chomp $line;
:   my @data = split (/,/,$line);


   You don't need a temp array either:

      my($first, $third, $fifth) = (split /,/, $line)[1,3,5];

   Or, even print them directly

      { local $, = ' ';  # put a space between list elements
         print( (split /,/, $line)[1,3,5], "\n");
      }


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


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

Date: Wed, 20 Oct 1999 12:25:24 +0900
From: "Yeong Mo/Director Hana co." <hmaster@factory.co.kr>
Subject: Re: How to print password by "crypt" ?
Message-Id: <5hdgVkqG$GA.221@news.thrunet.com>

Thank you sir,

I need to create .htpasswd file for just one user.
Then, is this right ?

$name = "0101";
$password = "0000";

$passwd = crypt($password, salt);

open(FILE4, ">htpasswd") || die "I can't open .htpasswd \"Checking
user\"\n";
flock (FILE4, 2) or die "can't lock data file\n";
print FILE4 "$name:$passwd";
close(FILE4);

`mv htpasswd .htpasswd`;

I tried this, But access was denied.
Please help.

>You are destroying the password file when you open it, then printing a
>single value into it, so all other accounts will be deleted.  And if
>open() fails, you silently fail to update the file.
>
>Also, if $file is ".htpasswd" and someone tries to fetch a web page
>while you're doing this, .htpasswd may be empty and they may get
>spuriously denied access.  (This may be acceptable, depending on your
>application.) Create a new file and rename it to .htpasswd when you're
>done.  (Is there a safe way to do this on Win32?  rename() doesn't work
>there.)
>
>Also, I notice you're crypting $FORM{new}, not $password, which makes
>me wonder what $password is for, and you have apparently three
>different names for the username: $ID, $user, and $name.
>--
><kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
>Tue Oct 19 1999
>21 days until the Internet stock bubble bursts on Monday, 1999-11-08.
><URL:http://www.pobox.com/~kragen/bubble.html>




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

Date: Tue, 19 Oct 1999 17:59:26 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: I pass by reference, but my array is unchanged.
Message-Id: <ujpiu7.u6d.ln@magna.metronet.com>

Jeff Moser (agon@unm.edu) wrote:

: # I want to pass an array reference to a gah() and have gah()
: # make changes to the array.  Since the array is being passed
: # by reference, I expect that any changes made in gah() will
: # actually occur to @blorg in subroutine blah().  That's not
: # what is happening though. 

[snip actual and expected output]

: #!/usr/bin/perl -w
: use strict;


   Oh good!

   Now I can read the rest of the post instead of skipping
   to the next article.

   :-)


: blah();
: exit 0;

: sub blah()
: {
:     my @blorg = ("a","b","c");
:     gah(\@blorg);
:     
:     my $i;
:     for $i (0 .. $#blorg){
: 	print "$blorg[$i]\n";
:     }
: }

: sub gah()
: {
:     my $foo = shift;
:     my @arr = @$foo;


   What do you expect to happen if the RHS was an array instead
   of a (dereferenced) reference to an array?

      e.g.      my @arr = @_;

   If you expect that all of the elements of @_ are copied into
   @arr, then you expect correctly.

   That is what you are doing here.


:     my $i;
:     
:     for $i ( 0 .. $#arr ){
: 	print "$arr[$i]\n";
: 	$arr[$i] = $i;


   Then you go on to modify the _copy_, not the original array.

        $foo->[$i] = $i;   # or $$foo[$i] = $i;


: # Thanks a lot for the help.


   You're welcome.


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


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

Date: Tue, 19 Oct 1999 18:16:55 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: I pass by reference, but my array is unchanged.
Message-Id: <nkqiu7.u6d.ln@magna.metronet.com>

Jeff Moser (agon@unm.edu) wrote:

: sub blah()
[snip]
:     
:     my $i;
:     for $i (0 .. $#blorg){
: 	print "$blorg[$i]\n";
:     }
: }


   You are writing C code in Perl there, since you don't make
   use of the $i loop variable, other than for subscripting.

   You can put the "my" right in the for() also:

       for my $blorg_element ( @blorg ){
          print "$blorg_element\n";
       }


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


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

Date: 20 Oct 1999 00:12:59 -0400
From: Scott Lanning <slanning@bu.edu>
Subject: Re: I pass by reference, but my array is unchanged.
Message-Id: <kusaepemzzo.fsf@strange.bu.edu>

tadmc@metronet.com (Tad McClellan) writes:
>    You can put the "my" right in the for() also:
> 
>        for my $blorg_element ( @blorg ){
>           print "$blorg_element\n";
>        }

<double take>
I did not know that... :)

-- 
"If there were gods, how could I bear to be no god?
Consequently there are no gods." --Nietzsche


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

Date: 20 Oct 1999 03:50:12 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: Importing symbols and memory usage - Apahce::Registry
Message-Id: <7uje5k$bqb$1@rguxd.viasystems.com>

Bill Moseley <moseley@best.com> wrote:
:>I'm looking at converting some scripts over to run under 
:>Apache::Registry.

:>One of the scripts uses CGI.pm's function interface, importing :standard 
:>& :html.  I've read that importing the symbols can add up to quite a bit 
:>of memory usage.  Should I a) not import any symbols and just use the 
:>package name in all the calls, or b) switch over to using the Object 
:>interface (and why, if you don't mind), or c) not worry about it?

I suppose you really want someone to explain why you should
choose one of the above.  You imply reducing the memory footprint
is a consideration.  You already know how to use 'top'.  Try
it each way and see.  Then come back and tell us.  I would be 
surprised if the difference is that great.  All of the variables
and subroutines are defined whether you import them or not.
Adding them to your package's symbol table couldn't take up that
much of a memory footprint, could it?

:>Running 'top' show one script using 11MB, so it's hard to imagine how 
:>much effect not importing the symbols would have overall.

Oh.  You surmise the same thing.  But now that you have asked
the question, go find out and come back and tell us.

Or not.  I would be amazed if it made much difference in the
scheme of things.  This is probably one of those times where
you shoudn't worry about optimization. Memory is cheap.  Buy
more memory.

:>Speaking of 11MB -- this script also forks a bunch of children (at one 
:>point there are ten children running around.  Is there really 10 x 11MB 
:>memory usage happening?  I'd guess most of it is swapped out.  But I 
:>don't know enough about Unix to know what's happening.  Any other tools 
:>available to look (and understand) how my program's using memory?

Once upon a time there were systems that actually copied the
entire memory footprint when you did a fork.  Nowadays most
do something called "Copy on Write", so you don't need to
worry about that.    

:>Another question about running under Apache::Registry.  In a few 
:>programs I open STDERR to a log file.  Under mod_perl do I end up 
:>capturing all the STDERR from all the scripts running under that server 
:>process?

No.  Your script inherits the STDERR from whichever server process
launches that particular incarnation of your script.  When you open a
new STDERR it is only for that particular process and any children
that your process forks (after doing the open).   Beware that
multiple simultaneous incarnations of your script can interleave
their STDERR output into the file unless you use file locking.

:>Clueless about mod_perl:

The above are not what is going to get you.  The documentation that
comes with mod_perl describes the things to watch out for.  Beware
file scoped lexicals which lead to accidental closures from
mod_perl wrapping your entire script in a block.

-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: 19 Oct 1999 23:01:58 PST
From: Neil <neil@pacifier.com>
Subject: Re: linux perl editor?
Message-Id: <380d5ad6.0@news.pacifier.com>

Marc H. Robards <mhrobards@nospam.tasc.com> wrote:
> Anyone have any recommendations for a perl editor under Linux?  Or is emacs
> or vim the way to go?  I've just started using Linux, so any suggesstions
> would be appreciated.

pico is an excellent editor that is intuitive to use.

Neil


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

Date: 19 Oct 1999 22:44:11 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Matching an asterisk
Message-Id: <slrn80qejr.fji.abigail@alexandra.delanet.com>

Brett W. McCoy (bmccoy@foiservices.com) wrote on MMCCXLI September
MCMXCIII in <URL:news:slrn80qb2o.frt.bmccoy@moebius.foiservices.com>:
--
-- The last character in a a string?
--
-- text =~ /.*\*$/;

That's going to fail on "foo\nbar*" (false negative).

It's also going to fail on "foo*\n" (false positive).



Abigail
-- 
perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 20 Oct 1999 04:18:08 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: Matching an asterisk
Message-Id: <7ujfq0$bqb$2@rguxd.viasystems.com>

Adam Mendlik <mendlik@pop.dnvr.uswest.net> wrote:
:>I can't seem to write the code that will match if and only
:>if an asterisk appears
:>as the last character in a string. I have tried several
:>variations:

Well.  You certainly can't be accused of not reading the
documentation and trying things.  I'm truly amazed that you could
have come up with all of these and not stumbled onto one that works.
Go back and read perlre a bit more carefully instead of skimming.
The location of the $ to match end of string and the left to right
nature of pattern matching seems to have passed you by.

:> ($text =~ /$*/)        #The obvious first try
$text =~ /\*$/;		# A correct answer

:> ($text =~ /$\x2A/);  #Match the hex for '*'
:> ($text =~ /$\052/);   #Match the octal for '*'
No comment.

:> ($text =~ /$\Q*\E/); #Disable metacharacters
$text =~ /\Q*\E$/;

:> ($text =~ /$$asterisk/); #Define a variable for '*'
Nope



-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: 20 Oct 1999 04:33:36 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: Matching an asterisk
Message-Id: <7ujgn0$bqb$3@rguxd.viasystems.com>

Abigail <abigail@delanet.com> wrote:

:>It's also going to fail on "foo*\n" (false positive).

I'm ambivalent about that, as is Perl.  The documentation may
be explicit that $ matches either at the end of the string
or before \n, but for most of us that is the same thing.  Except
when we don't want it to be.


-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: Wed, 20 Oct 1999 07:57:58 +0200
From: "T. Bossert" <th.bossert@z.zgs.de>
Subject: Missing Good Old Utilies
Message-Id: <380D59E6.6BD440FF@z.zgs.de>

Hi,

in the 'good old days' there were utilies ( or compiler options ) to
output a cross reference list of ( at least ) the variables in a
program. Up to now I was unable to locate such a thing for Perl. Am I
overlooking something or doesn't it really exist ( and I'm the only one
missing it ) ? I was unable to check the output of 'perl -D1024' since
debug appears not have been included in the binary I'm using :-(
Then I'm not quite happy with the way EMACS indents my programs -
therfore the question if there's some sort of 'Perl Beautifier' ( with
e.g. some options for indentation ). As for my efforts to find one: same
as above.

Thomas



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

Date: Wed, 20 Oct 1999 04:53:52 GMT
From: netwit2@my-deja.com
Subject: New Perl/TK Tutorial on perl.com
Message-Id: <7ujhss$ggj$1@nnrp1.deja.com>

Check out the new Perl/TK tutorial at   http://www.perl.com


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


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

Date: 20 Oct 1999 05:05:41 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: New Perl/TK Tutorial on perl.com
Message-Id: <7ujij5$t3l$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to 
<netwit2@my-deja.com>],
who wrote in article <7ujhss$ggj$1@nnrp1.deja.com>:
> Check out the new Perl/TK tutorial at   http://www.perl.com

All I see is

                                                  Essential Perl/TK Programming

   [first.gif] [prev.gif] [1]Next [2]Last [space.gif] [3]Index [4]Home
   [5][USEMAP:img001.gif]

                               Slide 1 of 31

Does not look very educative...

Ilya


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

Date: Wed, 20 Oct 1999 11:39:55 +0800
From: Noira Hadi <r42317@email.sps.mot.com>
To: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: newbie - counting data lines
Message-Id: <380D398B.E770A464@email.sps.mot.com>

Let say I want to have the script processing something when line number is
less than 29. I use the script below in addition to your script. However, it
does not print anything inside the innermost 'if' statement which should
print ' do something' and count the line number. Here's the script that I
altered.

#!/usr/local/bin/perl -wl
use strict;
my @buf;
my @count_sbr;
open(INF,"data") || die "no datafile" ;

while (<INF>)
{
    chomp;
    push @buf, $_;
    if (/MRR/)
    {
        my $length = @buf;
        if ($length < 29)
        {
           print "oops...";
           chomp;
           push @count_sbr, $_;
           if (/SBR/)
           {
              print "do something";
              my $length_sbr = @count_sbr;
              print "$length_sbr";
           }
        }
        elsif ($length == 29)
        {
           print "nice";
        }
        else
        {
           print "no way!";
        }
        @buf = ();
    }
}

data file :

MIR1,98/11/21 06:38:36
MIR2,TECH,25,TSG,TSG,
SBR2,1,2
SBR1,1,3
SBR2,1,3
SBR1,1,4
SBR2,2,2
HBR,2,2
HBR,2,3
HBR,2,4
SDR,2
MRR,98/11/26 16:44:09,2234
MIR1,98/11/21 06:38:36
MIR2,TECH,25,TSG,TSG,
SBR1,1,1,1,0,0,0,0,0,
SBR2,1,1,0,0,0,0,0,0,
HBR,1,1,0,0,0,0,0,0,
MRR,98/11/21 06:39:3
MIR1,98/11/21 06:38:36
MIR2,TECH,25,TSG,TSG,
SBR1,2,3
SBR2,2,3
SBR1,2,4
SBR2,2,4
HBR,1,1
HBR,1,2
HBR,1,4
SDR,1
HBR,2,1
HBR,2,3
HBR,2,4
SDR,2
MRR,98/11/26 16:44:09,2234
MIR1,98/11/21 06:38:36
MIR2,TECH,25,TSG,TSG,
SBR1,1,1,1,0,0,0,0,0,
SBR2,1,1,0,0,0,0,0,0,
HBR,1,1,0,0,0,0,0,0,
MRR,98/11/21 06:39:3






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

Date: Tue, 19 Oct 1999 18:36:43 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: newbie
Message-Id: <MPG.1276bc85db15c36a98a0c5@nntp.hpl.hp.com>

In article <7uige5$pgg$1@nnrp1.deja.com> on Tue, 19 Oct 1999 19:23:01 
GMT, jspangen@my-deja.com <jspangen@my-deja.com> says...

 ...

> > I want to do something like the following:
> >
> > while ($line = <FILE>) {
> >    ($word, $number, $array_of_files) = split(" ", $line);
> >
> > but how would I get the array_of_files to work?
> almost correct, try:
> 
> ...
> while (defined ($line = <FILE>)) {
>   ($word, $number, @files) = split / /,$line;  # @files = array

'split / /' is not the same as 'split " "'.

>   $word =~ s/^.*:$/; # ;-)

What did you intend by that non-compilable line of code?  Is that why 
there is a smiley?

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


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

Date: Wed, 20 Oct 1999 00:12:33 -0400
From: planb@newsreaders.com (J. Moreno)
Subject: Re: OT: Newsreader? a.k.a Re: Ignore the idiots
Message-Id: <1dzy5ud.1bd81cz272feeN%planb@newsreaders.com>

Jonathan Stowe <gellyfish@gellyfish.com> wrote:

> Cameron Dorey <camerond@mail.uca.edu> wrote:
> > [cc'd to mv, just in case he doesn't read my post]
> > 
> > Martien Verbruggen wrote:
> >> 
> >> [original question snipped]
> >> 
> >> Since I started doing that, my clpm experience has improved a lot. It
> >> was definitely worth the change of news reader.
> > 
> > OK, you've got my curiosity piqued. What newsreader do you use?
> > 
> 
> slrn apparently ...

Since Cameron is a Windows user, he might want to take a look at Xnews,
it does scoring.

(I'd suggest going to newsreaders.com and looking around).

-- 
John Moreno


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

Date: 20 Oct 1999 03:20:57 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Problem w/ PERL and SQL
Message-Id: <slrn80qd8p.ohb.sholden@pgrad.cs.usyd.edu.au>

On Tue, 19 Oct 1999 23:59:08 GMT, sabentle@hotmail.com wrote:
>
>Yes, I am using ODBC (more specifically, the Win32::ODBC module) to
>connect to my MS SQL Server via perl. The original data is coming from a
>form that I am parsing out and sending to the DB.  I am having the
>problem with a large text area (field is set to 1000 chars max in the
>db).  The data goes into the db in full, but when I retreive it to
>populate a new form, it gets truncated somewhere along the way.

Does the field of the table have a type like :

char(255)
varchar(255)
text(255)

or something?


-- 
Sam

why can't newbies use hash slices in their hello world programs? :-)
	-- Uri Guttman in <x74skxhve5.fsf@home.sysarch.com>


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

Date: Wed, 20 Oct 1999 03:08:40 GMT
From: deltren@my-deja.com
Subject: Program to use cgi with out a server? lil help
Message-Id: <7ujbng$cdk$1@nnrp1.deja.com>

IS there a program i could use to make my forms work when both the html
and cgi are on my computer which isnt a server?
If not any advise to test out simple cgi programs?


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


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

Date: Wed, 20 Oct 1999 04:20:15 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Q: Truncate string length?
Message-Id: <s0qgnv8sr018@corp.supernews.com>

Charles DeRykus (ced@bcstec.ca.boeing.com) wrote:
: I'm suprised that C<s> hasn't been mentioned:
: 
: $TheField =~ s/(.{500}).*/$1/; 

I included this possibility in my benchmarking post, several days ago.
This wtdi was slower by more than a factor of two compared to the
second-to-the-worst variant (using a match).  substr (in either lvalue or
rvalue forms) wins handily on speed.

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--  http://www.cinenet.net/users/cberry/home.html
   |   "They do not preach that their God will rouse them
      a little before the nuts work loose." - Kipling


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

Date: 20 Oct 1999 05:33:45 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Want to CGI for checking Domain name at Internic
Message-Id: <slrn80ql2p.28u.efflandt@efflandt.xnet.com>

On Wed, 20 Oct 1999 09:50:19 +0700, Akkadate Siripongwattana
<akkadate.s@tfb.co.th> wrote:
>I creating my homepage.
>I want have from for checking Domain name.
>How can I do it?
>Please,Help

http://thunder.prohosting.com/pub/whois.cgi (source is whois.txt}.  I
think there may be a whois module, but this simply uses the shell command
with backticks from a CGI.pm table form.

-- 
David Efflandt  efflandt@xnet.com  http://www.xnet.com/~efflandt/
http://www.de-srv.com/  http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/


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

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


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