[6843] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 468 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 13 17:17:14 1997

Date: Tue, 13 May 97 14:00:25 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 13 May 1997     Volume: 8 Number: 468

Today's topics:
     Re: clever coding required <merlyn@stonehenge.com>
     Re: control-M makes for very long $_ (Tad McClellan)
     Re: dbf database files and perl <bob_knight@hotmail.com>
     Re: Definition of $<digit> in perlvar.pod <ajohnson@gpu.srv.ualberta.ca>
     Graphing a tree from a text (Mike McLeod)
     Re: how do I get a binary representation of a number in (Andrew M. Langmead)
     Hurry - Still Time to Register for Randal's Advanced Ma <s..vanechanos@postoffice.worldnet.att.net>
     Re: I Need HELP in reseting @INC!!!!!!!!!!!! (Mike Stok)
     Re: I Need HELP in reseting @INC!!!!!!!!!!!! <psrc@corp.airmedia.com>
     Installing Perl5 (Mark Bainter)
     Lists question (Triantafyllos Marakis)
     Re: Loosing clpm regulars (was Re: Perl auto-replier) (Jan Fure)
     Re: More problems with FileHandle <merlyn@stonehenge.com>
     Need help on Oraperl !!! pdemeyer@cri.univ-lr.fr
     Re: passing arguments to scripts using STDIN (Honza Pazdziora)
     Re: persistent regular expressions (Bill Mitchell)
     Re: Randal Schwartz (Mike Stok)
     Re: Randal Schwartz (Abigail)
     Re: Randal Schwartz (Tad McClellan)
     Re: reading a complex record from file (Even Holen)
     Re: Regex problem - removing trailing form input (A. Deckers)
     Re: Regex problem - removing trailing form input (Mike Stok)
     Re: regular expression (Andrew M. Langmead)
     Re: sockets and port 23 <merlyn@stonehenge.com>
     Top of the page format problem <ranjbar@cig.mot.com>
     Re: Update: Comparing C, Lisp, Tcl, Perl, Python, Java, (Terrence M. Brannon)
     Want perl on Win95 Platform <donb@wcnet.org>
     Re: Win32::ODBC and Win32 Perl <jon_brule@nt.com>
     Win95+modems <Chris.King@swindon-fc.demon.co.uk.mars>
     Year 2000 compliance <sysmm@smtp.ais.ucla.edu>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 13 May 1997 05:21:41 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: mcohen@arl.mil
Subject: Re: clever coding required
Message-Id: <8cn2pzbm0a.fsf@gadget.cscaper.com>

>>>>> "Martin" == Martin Cohen <mcohen@arl.mil> writes:

Martin> Any reason not to use /\b\s*|\s*\b/ as the regular expression for the
Martin> split?  Then you would only have to trim the front of the first field
Martin> and the back of the last.  I did *not* test this.

Careful!  Never mix \b or \B with \s or \S in the same regex, unless
you are VERY VERY sure what you are doing.

The \b is the boundary between \w and \W, not between \s and \S.

For example, "fred!  " does *NOT* match /\b\s/ because the only \w-\W
boundary (between the d and the !)  is not near a space.

Get Jeffrey Friedl's "mastering regular expressions" book for details.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 476 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

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


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

Date: Mon, 12 May 1997 17:24:48 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: control-M makes for very long $_
Message-Id: <gb58l5.v83.ln@localhost>

Tom Lewis-Flood (t.lewisflood@elsevier.com) wrote:
: I'm debugging someone's perl cgi script and I hardly know perl, so here
: it goes:

: 1. I look at a file with less and I see control-Ms where I would expect
: to see newlines. I presume this is because the file was created with
: DOS.


Yep.


: 2. The script is supposed to print the file between html <PRE> tags.
: When the script says, 
:     while  (<FILEHANDLE>) {
:         print;
:     }
: and nothing comes out, but when I change the file with the commandline,
: 	perl -p -i -e 's#^M#\n#g' filename.txt
: it outputs the file properly.

: 3. I've tried things like,
:     s#\cM#\n#g;
      ^^^^^^^^^^

substitute in a line. (it should work, if there was anything in $_ to
                       match against)


:     while  (<FILEHANDLE>) {

now read a line?


I expect you should read it first, then fix it ;-)


:         print;
:     }
: but it doesn't seem to change a thing.

: I could really use a hand. Thanks.


while  (<FILEHANDLE>) {
   s/\r//g;
   print;
}


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Tue, 13 May 1997 14:55:20 -0600
From: Robert PMC <bob_knight@hotmail.com>
To: Paul Denman <pdenman@ims.ltd.uk>
Subject: Re: dbf database files and perl
Message-Id: <3378D538.46D7@hotmail.com>

Paul Denman wrote:
> 
> Does anyone know how compatible Perl is with .dbf database files?
> Has anyone worked with them before? Will I need a module written
> especially to handle .dbf files (I think foxpro uses .dbf files).
> 

Paul:

I don't know whether you're wedded to the Perl approach, but if you're
looking for a _much_ easier way to work with databases on the web, I
would recommend that you check out WebFiler (http://www.webfiler.com).
It supports DBF files intrinsically (Fox, specifically) and you can even
upload and download the DBFs directly from the browser (or you can zip
them up, convert them to delimited text, if necessary).

Also, it requires no programming or SQL knowledge; uses its native
engine or ODBC for legacy data; has multi-user/multi-group security
control built-in; runs on about any NT/95 web server; has a complete
end-user, DBMS interface through the browser. You basically start with a
working system and customize it on the server itself.

Based upon your post, it might be worth a look. It works great with
FrontPage, as an aside. Also, it is the only system I know of where you
can upload and download data on the fly (you will need Netscape 2+ for
direct browser uploads - or FTP if using IE3; means you don't have to do
anything with ODBC to get something up and running). You can try it on
their site and also download a free trial.

Cheers Bob


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

Date: Tue, 13 May 1997 09:33:15 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Definition of $<digit> in perlvar.pod
Message-Id: <33787BAB.565A338A@gpu.srv.ualberta.ca>

John L. Allen wrote:
> 
> 
> Ok, fine.  I fell into the '*' trap.  Again.  I should have used a '+'
> 
>         perl -e '$_="abcd"; /(?:(b)|(c))+/; print "$1:$2:$3:$4\n"'
>         :c::
> 
>         perl -e '$_="bcde"; /(?:(b)(c)|(d)(e))+/; print "$1:$2:$3:$4\n"'
>         :c:d:e
> 
> One or both of these examples exhibit bugs.  I'm asking what the correct
> output should be and why.  In the name of consistency, the outputs should
> be either
> 
>         :c::   and   ::d:e
> 
> or
> 
>         b:c::  and   b:c:d:e
> 
> Now, which is it?
> 

my understanding is that the results should be
        :c::  and  ::d:e

but it would seem that re-entry of the enclosing parentheses only
resets $1 and nothing higher---which is why your first example
appears to work correctly, but the second example doesn't as it
fails to reset $2. (I've checked similar constructs with several
sets of parentheses, and it seems $1 is the only one reset)

and further, it appears that the reset of $1 is to a null string and
not to undef---meaning that if in the first example the string is "cd",
$1 could be tested with a defined and fail, but will be defined if 
the string is "abcd", just empty.

regards
andrew


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

Date: 12 May 1997 10:44:56 GMT
From: mcm@mround.bt.co.uk (Mike McLeod)
Subject: Graphing a tree from a text
Message-Id: <5l6sb8$5i9@pheidippides.axion.bt.co.uk>

Does anyone know of a chunk of code that will take a text representing a tree and
convert it into a graphical representation in say gif format?

Thanks in advance.

Mike McLeod
---
MLB 3/65 PP4,
BTL,
Martlesham Heath,
IP5 7RE.

E-mail me at:  mcleodmc@boat.bt.com
or             mcm@mround.bt.co.uk

Phone:  (01473) 649326
Fax:    (01473) 637523




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

Date: Sat, 10 May 1997 13:15:59 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: how do I get a binary representation of a number in a string
Message-Id: <E9yvIn.4AK@world.std.com>

Thomas Oelke <tpo9617@rit.edu> writes:

>Here's what I want to have, 

>  $i = "12";   # or any number 0-15.
>  $tmp = somefunc($i);
>  print "$i in binary is $tmp\n";

>Then get for output:
>  1110

>(if $i = 3, it would return 0011, etc.)

>So the question is, how can I implement 'somefunc'?

First pack() the perl number into binary data, and then use unpack() to get
a bitstring representation of the binary data.

If you want it in a function:

sub somefunc {
  return substr(unpack('B1', pack 'S1', $_[0]), -4, 4);
}

Or you could do it the way one might do it in C, with a bunch of bit
shifting and bitwise ANDing.

sub somefunc {
  my ($num) = @_;
  my $bitpos;
  for($bitpos = 0; $bitpos < 4; $bitpos++) {
    if($num & (1 << $bitpos)) {
      unshift @bits, 1;
    }
    else {
      unshift @bits, 0;
    }      
   }
   return join '', @bits;
}

You could even use an array to store the pre-computed results:

@nybbles = ( '0000', '0001', '0010', '0011',
             '0100', '0101', '0110', '0111',
             '1000', '1001', '1010', '1011', 
             '1100', '1101', '1110', '1111');

sub somefunc {
 return $nybbles[$_[0]];
}

-- 
Andrew Langmead


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

Date: 13 May 1997 12:14:50 GMT
From: Steve Vanechanos <s..vanechanos@postoffice.worldnet.att.net>
Subject: Hurry - Still Time to Register for Randal's Advanced May 15 Perl Class in NYC/NJ Area
Message-Id: <5l9lvq$q39@mtinsc05.worldnet.att.net>


We are sponsoring an open enrollment, one day, advanced perl class, taught 
by Camel Book Co-Author Randal Schwartz, on May 15th, in Fairfield NJ.

Details at http://www.dynamicweb.com/perl_class.html.

-- 
Steve Vanechanos, CEO                   http://www.dynamicweb.com
DynamicWeb Enterprises, Inc             Voice: 201-244-1000
271 Rt 46 West; Building F              Fax:   201-777-7428
Fairfield NJ 07004                      Email: stevev@dynamicweb.com




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

Date: 13 May 1997 15:14:16 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: I Need HELP in reseting @INC!!!!!!!!!!!!
Message-Id: <5la0g8$1uq@news-central.tiac.net>

In article <Pine.SOL.3.96.970513102339.10483C-100000@svmp01>,
Efren Serra  <eserra@svmp01.hisd.harris.com> wrote:
>Hi all,
>  Do you know how to reset @INC from its default value?

If you're adding directories (in perl 5) then

  use lib '/whatever/path';

is available, if you want to remove then you should check the description
of the lib module on line or in the camel book.  If you want to get dirty
then any @INC manipulations need to be in a BEGIN block otherwise they'll
happen *after* the compile phase...

Hope this helps,

Mike


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Tue, 13 May 1997 13:13:15 -0400
From: Paul S R Chisholm <psrc@corp.airmedia.com>
To: Efren Serra <eserra@svmp01.hisd.harris.com>
Subject: Re: I Need HELP in reseting @INC!!!!!!!!!!!!
Message-Id: <3378A12B.27AF@corp.airmedia.com>

Efren Serra wrote:
>   Do you know how to reset @INC from its default value?

How do you get down from an elephant?-)

The best way to add to @INC is the the "use lib" directive. The -I
command line argument to the Perl interpreter works, too, but it's
dangerous to put in the #! line because it might be truncated. (You
don't get down from an elephant; you get down from a duck.-)

If you really need to modify @INC directly, do it in a BEGIN block
before any "use" directives. ("use" directives are essentially "require"
directives in a BEGIN block. BEGIN blocks are handled in order. To
impact your "use" directives, the hacks to @INC must be done in an early
BEGIN block.)

--Paul S. R. Chisholm, AirMedia, Inc.      (formerly Ex Machina)
mailto:psrc@corp.airmedia.com http://www.corp.airmedia.com/~psrc
  I'm not speaking for the company, I'm just speaking my mind


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

Date: Tue, 13 May 1997 18:08:57 GMT
From: mark@michiana.net (Mark Bainter)
Subject: Installing Perl5
Message-Id: <3378ae11.76011829@news.michiana.net>

I'm preparing to make the move from perl4 to perl5 at our companies
web site.  I will freely admit that I'm new to perl.  I have ordered
the learning perl book, but it's release date has been pushed back to
next month sometime.  So, I'm hoping you guys can help me with what
might be a basic question for you.  I installed perl5 on an extra
machine that I have here, after throwing sco5 on it.  It compiled ok,
and seemed to work fine.  So, I ran the cgi scripts we have through it
with the -w script and piped the output to a printer.  I found that
there were quite a few errors there.  (Some were due to the upgrade,
like needing to escape the @ character, and some were just poor
programming)  :)   Anyway, for the time being, I'd like to put perl5
on our webserver alongside of perl4, instead of replacing it.  I'm
wondering if I'm going to run into any problems by doing this. 

Thanks for your help
(If you choose to email me your reply as well, make sure you change
the reply to address to mark@turnergroup.com)

		
---
mailto:mark@turnergroup.com          
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GB/CS/CM/G/IT/P/O d++(+) s+(++):(-) a-- C++(+++)$ ULSC++++(on+++)$ P+>+++ L+ E--- W+$ N++$ !o !K w(++++)$ !O- M--(-) V-- PS--(---) PE++(+++) Y++ PGP++(+++)>++++ t+(++) 5++++(+++) X(-) R tv+ b+++(++++) DI++(+++)>++++ !D-- G>+++ e>+ h---(--) r+++ y+++(++++) 
------END GEEK CODE BLOCK------ 


--------------------------------------------------------------------------------------
 ex abusu non arguitur in usum                                      
 (the abuse of a thing is no argument against its use)  
--------------------------------------------------------------------------------------



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

Date: Mon, 12 May 1997 14:11:09 GMT
From: ceetm@cee.hw.ac.uk (Triantafyllos Marakis)
Subject: Lists question
Message-Id: <EA2nEL.9MK@cee.hw.ac.uk>

I am trying to write a function that will delete a number of words from
a given string

Is it possible to search for that word within the array like in Pascal
  eg. if word IN array

So far thats what I've written
sub remove_words { 
  local ($string) = @_;
  local return_string = "";
  local @unwanted_words = ("and", "or", "not", "then", "that", "if", "on",
			   "in", "the", "it", "is", "when", "from", "all", 
		           "but", "can", "be", "will");
  if ($string in $unwanted_words) #how can this be implemented?
  {
      
     $return_string = $string;
  }
  return $return_String;
}

Thanks
--
TRIANTAFYLLOS MARAKIS     |George Burnett Hall(2.54), Heriot-Watt Univ.,
BSc in Computer Science IV|Edinburgh,EH14 4AS, Scotland UK
HERIOT-WATT University    |Email:ceetm@cee.hw.ac.uk
WEB: www.cee.hw.ac.uk/~ceetm, members.tripod.com/~tmarakis



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

Date: 13 May 1997 14:22:25 -0500
From: jan_fure@io.com (Jan Fure)
Subject: Re: Loosing clpm regulars (was Re: Perl auto-replier)
Message-Id: <5laf1h$mt4@bermuda.io.com>

I also agree with the need need for an (auto)moderated perl group
where people like Dr. Schwartz and Tom Christiansen can answer challenging
questions if they so desire. 

One choice of admittance criteria could be the proof that the potential
posters have helped newbies solve perl problems.

Other deeds that qualify would be contribution to the perl source code or
other public services to the perl community.

I personally have used perl only for about a week, and most of the
problems I encountered were answered by FAQ's or the "Camel".

Jan Fure


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

Date: 12 May 1997 03:33:16 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: trs@azstarnet.com (Tim  Smith), gej@spamalot.mfg.sgi.com
Subject: Re: More problems with FileHandle
Message-Id: <8cwwp5nfo3.fsf@gadget.cscaper.com>

>>>>> "Tim" == Tim Smith <trs@azstarnet.com> writes:

Tim> In article <5l44lg$e18$1@murrow.corp.sgi.com>,
Tim> Gene Johannsen <gej@spamalot.mfg.sgi.com> wrote:
>> my $fh = new FileHandle ">>$file";
>> 
>> return bless \$fh, $class;
>> 
Tim> You shouldn't need to return a reference to the FileHandle.  Just:

Tim> return bless $fh, $class;

But you don't want to do *that* either, unless your class @ISA
FileHandle, which if I recall, doesn't work quite right.

Just return $fh.  Let it stay a FileHandle.  (Of course, you should
be using IO::File as of 5.004, but that's another story... :-)

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 477 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

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


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

Date: 13 May 1997 14:51:46 GMT
From: pdemeyer@cri.univ-lr.fr
Subject: Need help on Oraperl !!!
Message-Id: <5l9v62$ob0@hpuniv.univ-lr.fr>

Hi !

Where can I get detailed help on oraperl ???

Or maybe someone of you already had the problem :
my function ora_login doesn't work with the new version of Oracle database,  
version 7.3.2.2, I don't even get any error message...
What happens ??

Thanks for your help.

-------------------------------
Patrice
pdemeyer@cri.univ-lr.fr


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

Date: Tue, 13 May 1997 16:03:21 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: passing arguments to scripts using STDIN
Message-Id: <adelton.863539401@aisa.fi.muni.cz>

BAHILL@ELECTRICAL.uwaterloo.ca (Brian Safety Boy Hill) writes:

> Hi,
> 
> (I appoligize if you've already read this, I thought I posted it but
> can't seem to find it).
> 
> I've written a script to process incoming mail into my Unix-based account. 
>  I've modified the .forward file to the following:
> 
> bahill, "| perl /u1/bahill/script.pl"
> 
> My problem is, how do I pass an argument to the script without it being 
> mistaken for a filename.

If you pass arguments to your script, they come in the @ARGV array.
You can do anything you want with this array, and of course you can
remove elements from it using shift:

my $param = shift @ARGV;

This will take the $ARGV[0] and put it into variable $param, the rest
of the @ARGV array will "shift left". Tha't what you probably mean by
"mistaken for a filename". The construct <> will read from files whose
names are in @ARGV afterwards.

[...]

> BTW: When using 'perl -e' and the 'command line' why can arrays ( @a ) and 
> subroutines ( &a ) be used by single variables ( $a ) cannot?

Because you seem to call it perl -e "script" instead of perl -e 'script'.
In the first case, your shell (ksh, bash, ... ) will substitute $a
scalar variables with its variables of the same name, in most cases
resulting in empty string. When you use '' to surround your script,
you prevent the shell from doing this.

Hope this helps.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 11 May 1997 13:43:39 GMT
From: mitchell@leadbelly.math.ufl.edu (Bill Mitchell)
Subject: Re: persistent regular expressions
Message-Id: <MITCHELL.97May11094339@leadbelly.math.ufl.edu>

In article <5l3m2p$lmt@shoga.wwa.com> scribble@shoga.wwa.com (Tushar Samant) writes:
> Bill Mitchell <mitchell@leadbelly.math.ufl.edu> wrote:
> >pattern.  The following avoids the need for such a string:
> >
> >   "" =~ /($pat)|$/;
> >   while(...) { ...
> >      $whatever =~ //; 
> >      if (defined($1)) { ... }
> >    }
> >
> >If $1 is not needed, and the matches are long enough that copying
> >them slows things down, then /$pat|($)/ could be used instead, 
> >with  the test changed to "if (!defined($1))".
> 
> Unless $pat contains parentheses.
> 

Good point.  How about  "/()(?:$pat)|$/", with the test back to 
"if (defined($1))"?  
--
    Bill Mitchell
    Dept of Mathematics,        The University of Florida
    PO Box 118105, Gainesville, FL 32611--8105
    mitchell@math.ufl.edu	(352) 392-0281 x284

  


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

Date: 13 May 1997 17:08:23 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Randal Schwartz
Message-Id: <5la767$a9n@news-central.tiac.net>

In article <hf38l5.f53.ln@localhost>, Tad McClellan <tadmc@flash.net> wrote:
>Michael Lauzon (ce940@torfree.net) wrote:
>: This is a question for Randal Schwartz.
>
>
>Well, then you delivered it the wrong way.

>Individual communications should use an individual communication medium
>such as email.

Maybe that's why he said

>: appreciate it if you would take a look at it, though I will need to email 
>: it to you...and for that I will need your email address.  I would really 

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Tue, 13 May 1997 18:07:55 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Randal Schwartz
Message-Id: <EA4t17.720@nonexistent.com>

On 12 May 1997 19:15:29 -0700, Randal Schwartz wrote in
comp.lang.perl.misc URL: news:8cwwp4rubi.fsf@gadget.cscaper.com:
++ >>>>> "Tung-chiang" == Tung-chiang Yang <tcyang@netcom.com> writes:
++ 
++ Tungchiang> He/she wants to catch everyone's attention by using
++ Tungchiang> Randal's name in the subject :)
++ 
++ Well, at least he-she spelled my name right.  You wouldn't believe the
++ number of incorrect ways to spell either Randal or Schwartz, and
++ therefore the number of permutations of both.

Hmm, the other day I read a thread in rec.puzzles about which name
has the most different misspellings.... Perhaps you should submit
yours. ;)

++ Of course, some would argue that my first name is spelled wrong
++ anyway. :-)

Yeah, your name should be Randy Black.



Abigail


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

Date: Mon, 12 May 1997 16:52:49 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Randal Schwartz
Message-Id: <hf38l5.f53.ln@localhost>

Michael Lauzon (ce940@torfree.net) wrote:
: This is a question for Randal Schwartz.


Well, then you delivered it the wrong way.

Posts to Usenet go to THOUSANDS of computers around the entire World,
and are also read by thousands of people.

Individual communications should use an individual communication medium
such as email.

Do you think that Randal is the only one who can help you with
a syntax error? That is abolutely the most simple of all types of
errors to fix.

Logic errors are much harder to fix.


I would not expect Randal to be able to bother with fixing syntax
errors. That's kind of like asking F. Lee Bailey what to do
about a parking ticket.


How many requests for individual help would you expect a world famous
person such as Randal gets? Is your's somehow more worthy than any of
the other hundreds of requests to give away for free the knowledge
that he makes his living with.

Offer him a contract if you want individual help.

Or, just post your broken code here, and let any of the thousands
of people who read the newsgroup (and are surely competent enough
to deal with a simple syntax error) help you for free...


[ snip an explanation of getting syntax error, without including the
  code that produces said error...
]


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 13 May 1997 16:07:11 GMT
From: evenh@bigblue.pvv.ntnu.no (Even Holen)
Subject: Re: reading a complex record from file
Message-Id: <slrn5nh4df.tgo.evenh@bigblue.pvv.ntnu.no>

In article <337287bb.26103361@news.ultranet.ca>, Shawn wrote:
>I have a hash of a hash of arrays that looks something like this:
>
>541:
>may 11 1997 = teefeld 'May 11 1997' 'may 17 1997'  n 8 8 
>may 4 1997 = teefeld 'may 4 1997' 'may 10 1997'  3 7 7.5 n 
>
>542:
>mar 11 1997 = allent 'mar 11 1997' 'mar 17 1997'  7 n 5 5
>mar 4 1997 = allent 'mar 4 1997' 'mar 10 1997' 4 3 n 5 
>
>I can create it manually and print it to a file. But I'm not sure how
>to load it from the file back into the complex hash.

If it's yours to decide I would choose a simpler format for your text
file. As an example you might use:

[541]
may 11 1997;teefeld;may 11 1997;may 17 1997;n;8;8;
may 4 1997;teefeld;may 4 1997;may 10 1997;3;7;7.5;n 

[542]
mar 12 1997;allent;mar 12 1997;mar 17 1997;7;n;5;5
mar 2 1997;allent;mar 2 1997;mar 10 1997;4;3;n;5 

In other words ;-separated file with headings which divides the primary
hashes. To read in such a file you might use something along the lines
of :

#!/usr/bin/perl

$newPrimaryKey = 0;

while(<>) {
  next if /^\s*$/;
  if (/^\s*\[(\d*)\]\s*$/) {
     # Are at divider line for 
     $newPrimaryKey = $1;
     next;
  }
  chomp;

  my $arrayRef;
  (@{$arrayRef}) =  split(';');
 
  $secondaryKey = shift @{$arrayRef}; 
  $newHash{$newPrimaryKey}{$secondaryKey} = $arrayRef;
}

print "Print whole new array";

foreach $key (keys %newHash) {
  print "[$key]\n";
  foreach $secKey (keys %{$newHash{$key}} ) {
     print "$secKey => @{$newHash{$key}{$secKey}}\n";
 }
}

print "First date of every record";

foreach $key (keys %newHash) {
  print "[$key]\n";
  foreach $secKey (keys %{$newHash{$key}} ) {
     print "$secKey => @{$newHash{$key}{$secKey}}[1]\n";
 }
}

Here I presume that your primary key is 541 and 542 in your test set,
and that whatever was before the '=' was the secondary key...

If you can't change the format of the file you've got some reading to
do on regexp's...

The following might work, but ain't foolproof. It does give an 'error'
on your first line which does only have three 'number' fields at the end
instead of four... (I just give the while-block, the rest is identical):

while(<>) {

  next if /^\s*$/;
  if (/^\s*(\d*):\s*$/) {
     # Are at divider line for 
     $newPrimaryKey = $1;
     next;
  }
  chomp;

  # Split secondary key and rest of line
  ($secKey, $restOfLine) = /(.*)\s+?=\s+(.*)/;
  
  # Pick out the field from the rest of the line and convert to an array
  my $arrayRef;
  (@{$arrayRef}) =
    /(\S+)\s+'([^']*?)'\s+'([^']*?)'\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/;
  
  $newHash{$newPrimaryKey}{$secKey} = $arrayRef;
}

Hope this is of some help to you. The code given is tested and functions
according to the given facts (as far as I can see) but you may need to
change here there to suit your needs... :-)

I haven't given any much explanation on the regexp's given. To that read
some of the excellent documentations which is almost everywhere... :)

Regards,
Even Holen
-- 
<><   Even Holen, evenh@pvv.ntnu.no, http://www.pvv.ntnu.no/~evenh/   :-)


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

Date: 13 May 1997 17:44:21 GMT
From: I-hate-cyber-promo@man.ac.uk (A. Deckers)
Subject: Re: Regex problem - removing trailing form input
Message-Id: <slrn5nha3k.aud.I-hate-cyber-promo@nessie.mcc.ac.uk>

In <EA4JLC.C9y@ciba-geigy.ch>,
	David M Holmes <david.holmes@bigfoot.com> wrote:
>Hi,
>
>I'm having a problem deleting trailing form input from a URL.  Here is 
>the code.
>

1>#!/usr/local/bin/perl -w
2>
3>use strict;
4>use diagnostics;
5>
6>my $testurl = "http://www.here.com/path/to/file/me.html?a=b&c=d";
7>
8>print "$testurl\n";
9>
0># remove trailing form input
1>
2>$testurl =~ m/.*?(\?.*)/;

Did you try anchoring your pattern? This is usually a good idea. But
there's a simpler way of doing this. See below.

3>$testurl =~ s/$1//;
4>
5>print "$testurl\n\n";

>
>The error message I get is:
>
>Uncaught exception from user code:
>        /?a=b&c=d/: ?+* follows nothing in regexp at testurl.pl line 13.
>
>I haven't been able to find this error message in Programming Perl (2e).

Try this:

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

my $testurl = "http://www.here.com/path/to/file/me.html?a=b&c=d";
my $data_split;
my $data_regex;

print "$testurl\n";

(undef, $data_split) = split /\?/, $testurl, 2; # split on left-most '?'
($data_regex) = $testurl =~ m/^[^?]+\?(.+)$/;   # split on left-most '?'

print "data_split: $data_split\n";
print "data_regex: $data_regex\n";

__END__

Produces the following output:

http://www.here.com/path/to/file/me.html?a=b&c=d
data_split: a=b&c=d
data_regex: a=b&c=d

Achieves the same thing both ways. Remember that in a list context, m//
returns a list of matched (), or a list of every match if no () are
present. Have a look at man perlre.

HTH,

Alain

-- 
Perl information: <URL:http://www.perl.com/perl/>
        Perl FAQ: <URL:http://www.perl.com/perl/faq/>
    Perl archive: <URL:http://www.perl.com/CPAN/>


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

Date: 13 May 1997 17:55:26 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Regex problem - removing trailing form input
Message-Id: <5la9ue$e65@news-central.tiac.net>

In article <EA4JLC.C9y@ciba-geigy.ch>,
David M Holmes <david.holmes@bigfoot.com> wrote:

>my $testurl = "http://www.here.com/path/to/file/me.html?a=b&c=d";
>
>print "$testurl\n";
>
># remove trailing form input
>
>$testurl =~ m/.*?(\?.*)/;
>$testurl =~ s/$1//;
>
>print "$testurl\n\n";
>
>The error message I get is:
>
>Uncaught exception from user code:
>        /?a=b&c=d/: ?+* follows nothing in regexp at testurl.pl line 13.

That's 'cos $1 is being interpreted as a regex and starts with a ? (which
follows nothing (if $1 has been set at all...)

  $testurl =~ s/(.*?)\?.*/$1/;

might do what you want, or you could say

#!/usr/local/bin/perl -w

use strict;
use diagnostics;

use URI::URL;

my $testurl = new URI::URL
"http://www.here.com/path/to/file/me.html?a=b&c=d";

print $testurl->scheme, '://', $testurl->netloc, $testurl->path, "\n";

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Mon, 12 May 1997 11:07:18 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: regular expression
Message-Id: <EA2Ew6.J9q@world.std.com>

Zaheed Haque <zaheed.haque@ein.ericsson.se> writes:

>I am just wondering If there is any regular expression software or
>something out there anyone aware of.. Someting that takes input
>and shots out the correct regular expression in other words something
>thats makes regular expression easier.. I am just trying to
>find out if there any shortcut! -:)

I haven't look at it, but a few weeks ago someone announced here a
graphical regular expression creation tool called TkREM. Information
is at <http://www.phys.ksu.edu/~bailey/tkWorld.html>

-- 
Andrew Langmead


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

Date: 12 May 1997 03:43:32 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: "Jonathan R. Seagrave" <jrs@abiogenesis.com>
Subject: Re: sockets and port 23
Message-Id: <8crafdnf6z.fsf@gadget.cscaper.com>

>>>>> "Jonathan" == Jonathan R Seagrave <jrs@abiogenesis.com> writes:

Jonathan> The following bit of code is a simple client program (much
Jonathan> like that in the camel book) that connects and talks to a
Jonathan> server.  I've tested it and it does what I expect it to do
Jonathan> for almost all of the ports on my system.  (e.g. echo-7,
Jonathan> daytime-13, ftp-21, smtp-25, time-37, finger-79, httpd-80)

Jonathan> However, when I connect to port 23, there is nothing to read
Jonathan> on SOCKET

Jonathan>     $stdin = ReadLine (-1, $in);
Jonathan>     $socketin = ReadLine (-1, $sock);

Two problems:

(1) if you connect to 23, you gotta handle the "telnet" protocol (grep
the RFC database for "telnet" and you'll see a half-dozen RFCs that
involve the use of the [\xfc-\xff] chars to handle in-band what should
ahve been out-of-band].

(2) ReadLine can't mean a thing to a socket connection.  You've just
done an ordinary "read" there.  And then what if nothing is coming in?
(Actually, I haven't used ReadLine... so this is just a serious hunch,
so yell at me if I'm wrong there.)

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 477 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

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


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

Date: Tue, 13 May 1997 12:03:27 -0500
From: Ali Ranjbar <ranjbar@cig.mot.com>
Subject: Top of the page format problem
Message-Id: <33789EDF.41C67EA6@cig.mot.com>

Fellows;

I have the following in my code but it does not print the headers.

   format STDOUT_TOP =
   File Name                       Total     Passed    Failed    Aborted
   ========                        =====     ======    ======    =======
    
    .
And I invoke it with 
write;

I tried:
write STDOUT_TOP;
but it did not work. Did not print anything. I got the message
Write on closed filehandle at final.pl line 25.

And line 25 is the line:
 25        write STDOUT_TOP;

Couple of questions.
1. Is this top of the page only works in Perl5?

2. I thought STDOUT is the default for write, and XXXX_TOP is the
default TOP of the page for XXXX format. So I did not open STDOUT_TOP
for writing to STDOUT or any other file for that matter. Any comments?

PS: Thanks to the the folks who replied to my earlier posting (A perl
Question, (problem with detecting ()).

-- 
Ali N. Ranjbar			Motorola CIG, IL75-3J5
Phone:(847)435-9797		Fax:(847)632-5959     E_mail:ranjbar@cig.mot.com

I will not let anyone walk through my mind with their dirty feet.
							Mahatma Gandhi


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

Date: 12 May 1997 15:57:28 -0700
From: brannon@bufo.usc.edu (Terrence M. Brannon)
To: John Watton <john.watton@alcoa.com>
Subject: Re: Update: Comparing C, Lisp, Tcl, Perl, Python, Java, & Scheme (Guile) Using a Floating Point Numerical Test - Point Inside Polygon
Message-Id: <ysizrafc9u3y.fsf@bufo.usc.edu>

Did you use the Perl Data Language
(http://www.aao.gov.au/local/www/kgb/perldl/)?

With PDL the perl variable $a can hold a 1024x1024 floating point
image, it only takes 4Mb of memory to store it and expressions like
$a=sqrt($a)+2 would manipulate the whole image in a few seconds. 

As a result perlDL is very fast --- for example one can mulitiply a
2048*2048 image in exactly the same time as it would take in C or
FORTRAN (0.1 sec on my SPARC). A further advantage of this is that for
simple operations (e.g. $x += 2) one can manipulate the whole array
without caring about its dimensionality. 

John Watton <john.watton@alcoa.com> writes:

> 
> Comparing C, Lisp, Tcl, Perl, Python, Java, & Scheme (Guile) Using a
> Floating Point Numerical Test - Point Inside Polygon

-- 
o============o Sending  unsolicited commercial e-mail (UCE) to this address
 Legal Notice  is indication of your consent to pay me $120/hour for 1 hour
o============o minimum for professional proofreading & technical assessment.
terrence brannon * brannon@rana.usc.edu * http://rana.usc.edu:8376/~brannon


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

Date: 13 May 1997 17:01:06 GMT
From: "Don Botten" <donb@wcnet.org>
Subject: Want perl on Win95 Platform
Message-Id: <01bc5fbf$858e0280$62ab85cd@mardon>

I am running windows 95 and would like to test my perl scripts in my
computer.  Up to now I have telneted into my isp and checked them out on
unix.  The perl interpreters I have found are for Windows NT or OS2.

Can anyone help me with this.

donb@wcnet.org


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

Date: Fri, 9 May 1997 21:23:31 GMT
From: Jon Brule <jon_brule@nt.com>
To: "Patrick C. K. Wu" <ckwu6@iesun21>
Subject: Re: Win32::ODBC and Win32 Perl
Message-Id: <337395D3.51C4@nt.com>

Patrick C. K. Wu wrote:
> 
> Hi all
> 
> Could anyone tell me that what version of Win32 Perl should be used with
> Win32::ODBC (v970208).  As I use Win32 Perl 5.003 with this Win32::ODBC,
> I get "Parse Exception" using the test.pl provided in Win32::ODBC.
> 
> Thanks for any comments or pointers
> 
> Regards/Patrick C. K. Wu
> 
> email: ckwu6@ie.cuhk.edu.hk


Patrick,

I encountered a similar error...  I also noticed that I could not call
any module.  I, therefore, looked at the registry entries for Win32
Perl and noticed they were in error.  I proceeded to reinstall Win32
Perl; only this time, I hard-coded the line which determines the
current pathname.  It appeared that the installation script could not
detemine this on its own.

Once I reinstalled Win32 Perl, the error you mentioned went away;
however, I ran into a similar problem later on in the test script.  I
hard-coded the test scripts current directory line as well.  Finally,
the test script worked...

Does anyone have any thoughts?  The first time I ran installed both
Win32 Perl and Win32::ODBC, all went well (My PC had the leprosy virus
which trashed the hard disk)...

See y'all later...


Jon Brule
jon_brule@nt.com


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

Date: Mon, 12 May 1997 18:57:06 +0100
From: Chris King <Chris.King@swindon-fc.demon.co.uk.mars>
Subject: Win95+modems
Message-Id: <gL0znFAyn1dzEwpw@swindon-fc.demon.co.uk>

Anyone been remotely succesful talking to a modem on a standard PC com
port? Here's my latest effort which seems to do absolutely bugger all
apart from hang waiting for a response...

#!/bin/perl

# Next attempt at talking to the flipping modem

open (MODEM,"+<COM2") || die "Can't grab COM2\n";
select (MODEM);
binmode (MODEM);
$|="1";
select (STDOUT);

print MODEM "ATI3\r\n";

print "message sent\nNow waiting for a reply";

while (<MODEM>) {
  $reply=<MODEM>;
  print $reply;
}
close (MODEM);

__END__


-- 
Chris King
The similarity of any fact mentioned within this post and
any in reality, living or dead, is purely coincidental.
Remove 'mars' from address when replying. I hate spam.
I like corned beef though.


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

Date: Tue, 13 May 1997 11:01:57 -0700
From: Susan Malisch <sysmm@smtp.ais.ucla.edu>
Subject: Year 2000 compliance
Message-Id: <3378AC94.3AF2@smtp.ais.ucla.edu>

We have several scripts in production using perl 5.001.  Has anyone seen
any mention of Year 2000 compliance or issues with perl?  We are trying
to determine how much work/installations/upgrades we have outstanding in
preparation for the millenium change.  I'd appreciate a direct response
to my email address so I don't miss any postings.

Thanks for any information on this,
Susan Malisch
sysmm@smtp.ais.ucla.edu


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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 V8 Issue 468
*************************************

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