[7762] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1387 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 28 21:13:24 1997

Date: Fri, 28 Nov 97 18:00:23 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 28 Nov 1997     Volume: 8 Number: 1387

Today's topics:
     Re: , but I can't go to bed now.  REGEXPS question - TI <mak@mark.dircon.net>
     Re: ??? $ENV ??? <ckpwong@undergrad.math.uwaterloo.ca>
     Re: ACK! What am I doing wrong??!! <jan@chipnet.cz>
     Re: Help! unexpected token (William R. Ward)
     Re: How can I change real UID under Solaris? <rootbeer@teleport.com>
     Re: How i leave HTML tags alone ? (Charles Demas)
     Re: How To Test if number is ODD or EVEN? (John Moreno)
     Initialising Associative Array From text File (Alan)
     Is this database solution feasable? (Tom)
     Re: Is this database solution feasable? <rootbeer@teleport.com>
     Re: LWP with NT <garyng@ibm.net>
     Re: perl 5 good simple book? (William R. Ward)
     Re: PERL Hourly Rates (I R A Aggie)
     Perl Plug-In for Netscape? <eric@hilding.com>
     Re: perl shorter than csh challenge!! <Adam.Clarke@StrategicData.com.au>
     Re: Regex for three equal characters (John Moreno)
     Resource Kit Anomaly <pjhousto@cse.dnd.ca>
     Re: Silly diamond operator (<>) problem? (Andrew M. Langmead)
     Re: sort() corrupts data when using an "illogical" func <Sven.Neuhaus@de.uu.BLOCKSPAM.net>
     Re: sort() corrupts data when using an "illogical" func (Tushar Samant)
     Re: sort() corrupts data when using an "illogical" func <rootbeer@teleport.com>
     Re: sort() corrupts data when using an "illogical" func (Thomas A. Horsley)
     Re: Win32::ODBC Question <mchase@ix.netcom.com>
     Writing to files paul@pkamf.demon.co.uk
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 28 Nov 1997 17:28:24 +0000
From: Mark Morgan <mak@mark.dircon.net>
Subject: Re: , but I can't go to bed now.  REGEXPS question - TIA
Message-Id: <347EFF38.1EB90791@mark.dircon.net>

$m~c%l&l!h#n@worldnet.att.net wrote:
> 
> #  Why none of these are working?
> 
> $s_ = "bah baah  baaah ";
> 
> print "Go to bed now.\n" if (/a{1,3}/) ;
> print "Go to bed now.\n" if (/a+/) ;
> print "Go to bed now.\n" if (/a{1,}/) ;
> print "Go to bed now.\n" if (/ba+/) ;
> print "Go to bed now.\n" if (/ba{1,}/) ;
> print "Go to bed now.\n" if (/ba*/) ;
> print "Go to bed now.\n" if (/ba{0,}/) ;
> print "Go to bed now.\n" if (/ba?/) ;
> print "Go to bed now.\n" if (/ba{0,1}/) ;
> print "Go to bed now.\n" if (/bah{1,3}/) ;
> 
> # Something simple, but I can't go to bed now.
> # ver; Windows NT Version 4.0, Perl -v; This is perl, 5.004_02

The default variable to perform matches on is $_, not $s_...always look
for a common cause. :)

Mark.


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

Date: Fri, 28 Nov 1997 16:44:50 GMT
From: Cindy Wong <ckpwong@undergrad.math.uwaterloo.ca>
To: joeifox <foxfox@hkstar.com>
Subject: Re: ??? $ENV ???
Message-Id: <Pine.SUN.3.95q.971128112848.17772B-100000@napier.uwaterloo.ca>

> #!/usr/local/bin/perl
                         ^^^^ use your "-w" here!!

> print "Content-type: text/html", "\n\n";
> print "<HTML>", "\n";
> print "<HEAD><TITLE>About this Server</TITLE></HEAD>", "\n";
> print "<BODY><H1>About this Server</H1>", "\n";
> print "<HR><PRE>";
> print "Server Name: ", $ENV{'SERVER_NAME'}, "<BR>", "\n";
> print "Running on Port: ", $ENV{'SERVER_PORT'}, "<BR>", "\n";
> print "<HR></PRE>", "\n";
> print "</BODY></HTML>", "\n";
> exit(0);
  ^^^^^^^^  You don't really need an exit(0) here...

> I got the result as follow:
> 
> Content-type: text/html

If you really tried running the above script, there should be an empty
line here.

> <HTML>
> <HEAD><TITLE>About this Server</TITLE></HEAD>
> <BODY><H1>About this Server</H1>
> <HR><PRE>Server Name:   <BR>
> Running on Port: <BR>
> <HR></PRE>
> </BODY></HTML>
> 
> Would anyone tell me why I can't obtain the $ENV varible?

Maybe because there's no such $ENV{'SERVER_NAME'} and $ENV{'SERVER_PORT'}
existing?  ;) Try a 
	$ENV{'SERVER_NAME'} || 
	  die q(Oh no!! $ENV{'SERVER_NAME'} does not exist!); 

in your script. Or try something like:

foreach $key (sort keys %ENV) { print "$key: $ENV{$key} \n"; }

to see what environment variables you actually have.  It seems to be
completely normal if the SERVER_HOST environment variable doesn't exist,
'cause it seems to me you're trying to run a cgi script on a shell...

> And why I need to run pl file by typing "perl filename.pl" at prompt to
> execute instead of typing file name only?

If you're on UN*X, maybe your perl isn't in /usr/local/bin? Try "which
      perl".  If that doesn't work, try "where perl".  If that still
      doesn't work, try "find / -name perl", or, better yet, try ask
      someone else who knows.
If you're on some M$ windoze, you probably haven't associate the extension
 .pl with perl.exe.


Cindy

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS/IT/M/O dx s-:- a--- C+++>$ U++>++++$ 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++ x? 
------END GEEK CODE BLOCK------



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

Date: Fri, 28 Nov 1997 23:56:44 -0800
From: Jan Krynicky <jan@chipnet.cz>
To: Shafayat Kamal <sk@iessoft.com>
Subject: Re: ACK! What am I doing wrong??!!
Message-Id: <347FCABC.61F6@chipnet.cz>

Shafayat Kamal wrote:
> 
>  Hi all!
> 
> I have a little problem sending an email attachment that's base64 encoded.
> Please remember that I'm still a novice Perl programmer (but I can get
> around in it). The problem is when I encode the file, the file ends up being
> 9.12kb when the original file size is 9.11kb. Eudora also tells me that
> there were errors converting the attachment. If I put in a Chop; just before
> I go around encoding it the file size drops to 9.09kb and no matter what I
> do I still get errors from Eudora when converting attachment.
> 
> Please reply to sk@iessoft.com if possible!
> 
> open(MAIL,"|$mailprog -t");
> 
>          print MAIL "To: $email ($realname)\n";
>          print MAIL "From: $fromaddr ($fromname)\n";
>          if ($organization) {
>             print MAIL "Organization: $organization\n";
>          }
>          else {
>             print MAIL "Organization: Auto sent file\n";
>          }
>   print MAIL "MIME-Version: 1.0\n";
>   print MAIL "Subject: $file\n";
>          print MAIL "Content-Type: multipart/mixed;
> boundary=iessoftabcdefghklopqz\n";
>          print MAIL "Content-Type: application/octet-stream;
> name=azp1090.zip\n";
>    print MAIL "Content-Transfer-Encoding: base64\n";
>          open(INPUT,"$filebase/$file")||&error;
>          while (<INPUT>) {
>             $base64_string = &base64'b64encode($_); ## Should I put in a
> Chop? If I do, the file becomes ## 9.09kb and Eudora still gives me errors
> when trying to decode the attachment
>             print MAIL $base64_string;
>          }

No need to chop. There is another problem. Look at the data you print
out.
You will see something like
DBFUR4DSJDFG54SDDF54G4321DDS54D54FGDF6G421DSFG6842D1F45DF4G51DFG=
5DSFG654DF984C12N89R4H651FGN54F5J4H6F5GH654FY984F65G16J5F4Y6H4F8T7HD54G6546
DFGD465F4J6H54FD==
546546546546546DC46FG545D4F6656H1DF5GN46DF5HDF
DFGD54F65GDF4G6D6F5Y4RJ654DF5J4DGH=

which is definitely wrong. All the lines should be of the same size
and the padding = should be only on the end of FILE.
You should read the file in parts so big that the encoded version
creates full lines and doesn't need any padding.
I use 1024 which works OK.


So the loop will look like this.

while (read FILE, $str, 1024) {
 print MAIL (encode_base64 $str);
}


>          close (INPUT);
>          close (MAIL);
> 
> Regards,
> Shafayat Kamal
> http://www.iessoft.com/scripts/index.shtml

BTW, It's silly to use any standalone mailer if you may mail directly
from
perl. Use some module : Net::SMTP from CPAN or 
Mail::Sender from http:/www.chipnet.cz/depot/perl.htm
 (supports binary attachments  $sender->SendFile({file =>
'file.zip',encoding => 'Base64'}))

HTH, Jenda


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

Date: 28 Nov 1997 17:13:15 -0800
From: hermit@cats.ucsc.edu (William R. Ward)
Subject: Re: Help! unexpected token
Message-Id: <waasosg8puc.fsf@ese.UCSC.EDU>

Sometimes this kind of error message means that the previous line
might be missing a semicolon or something like that... sometimes the
Perl parser doesn't notice something's wrong until it hits the next
line of code.

Another thing to try is to add "use diagnostics;" to the code, which
will give more detailed error messages.  Also use the -w switch to
perl.

Or you could give us some more context for your code....

HTH.

--Bill.
[posted and mailed]

rqy1319@is4.nyu.edu (Ryuji Yokoyama) writes:
> I have encountered really strange thing.  I declared the same array in
> two different program, which is following.
[...]
> It works nicely in one program;however, I got an error message at the
> other program.
> 
> ./search2.pl:syntax error near unexpected token 'qw('
> .search2.pl:./search2.pl:line 4 @files = qw('
> 
> I totally don't understand why I got this error message even it works
> another program.  I wrote both program the same enviroment(Emacs for
> linux).  Please somebody tell me the reason why this thing happen.

-- 
William R Ward          Bay View Consulting   http://www.bayview.com/~hermit/
hermit@bayview.com     1803 Mission St. #339        voicemail +1 408/479-4072
hermit@cats.ucsc.edu  Santa Cruz CA 95060 USA           pager +1 408/458-8862


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

Date: Fri, 28 Nov 1997 15:55:01 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Mike Williams <mikew@ico.com>
Subject: Re: How can I change real UID under Solaris?
Message-Id: <Pine.GSO.3.96.971128155404.16101H-100000@user1.teleport.com>

On 28 Nov 1997, Mike Williams wrote:

> My Solaris 2.4 system has no setruid() call, but it does have setuid().
> Why doesn't perl use that?  

I'd guess because your copy of perl is (mis-)compiled not to know about
setuid. Try recompiling. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 28 Nov 1997 17:59:55 GMT
From: demas@tiac.net (Charles Demas)
To: <venice@euronet.nl> 
Subject: Re: How i leave HTML tags alone ?
Message-Id: <65n0qr$kpf@news-central.tiac.net>

In article <65cnos$h21$2@news.NL.net>,
Patrick, http://www.fictional.net <Venice@ euronet.nl> wrote:
>I want to replace the text in a HTML document...
>but i don't want to change the HTML code...
>
>blabla <HTMLTAG>tag is a fun game..</HTMLTAG> blablabla
>
>Like i want to replace tag in the above with whatever...
>
>I thought of searching between < and > but then again, tag is also
>between < and > (from the left and right htmltag)
>
>I can't just replace between "> text <" cause the starting and ending
>text wouldn't be checked...

In Unix I'd just use sed to do the job.  See man sed.

sed -e 's/old-text/new-text/g' < oldfile.html > newfile.html

in your case it would be:

sed -e 's/tag/whatever/g' < oldfile.html > newfile.html

the g flag says global, ie every time it appears on a line.

I thought sed was part of perl, but I'm very new to perl.

There are sed utilities available for most platforms.

Hope this helps.


Chuck Demas
Needham, Mass.

--
  Eat Healthy    |   _ _   | Nothing would be done at all,
  Stay Fit       |   @ @   | If a man waited to do it so well,
  Die Anyway     |    v    | That no one could find fault with it.
  demas@tiac.net |  \___/  | http://www.tiac.net/users/demas


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

Date: Fri, 28 Nov 1997 15:41:42 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: How To Test if number is ODD or EVEN?
Message-Id: <1d0fosd.1o0n7p9ni5vejN@roxboro-180.interpath.net>

Roy Brander <branderr@cuug.ab.ca> wrote:

> Ken Fox (fox@pt0204.pto.ford.com) wrote:
> : jay@dixonssurgical.co.uk (Jay Dixon) writes:
> : > I want to test if a variable is Odd (or Even)
> : 
> : As inspired by abigail:
> : 
> : perl -wle 'print "Even" if (1 x shift) =~ /^(1+?)\1$/'
> : 
> 
> It's now official.  I will never be a perl guru.  I've been
> staring at that one for a minute and still can't figure it.

For a value of 4 1xshift equals 1111

The regrex looks for as many 1's as it can (starting at the beginning of
the string) and still find a equal number afterwords (ending at the end
of the string).  With a odd number it can't match it.  Of course you
certainly wouldn't want to do this with a large number and it doesn't
work with negative numbers or zero

-- 
John Moreno


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

Date: Fri, 28 Nov 1997 20:25:28 GMT
From: alan@joker.force9.co.uk (Alan)
Subject: Initialising Associative Array From text File
Message-Id: <347f231d.43152834@news.force9.net>


 I am wanting to initialise an associative array from an encrypted
text  file using a persons name as the key to their account no. thus:
File contents when decrypted:
John
Ac1091
Jane
Ac1099

print " Enter Key: ";
chop($key = <STDIN>;

    %data = `crypt $key <file.bin`


Works fine but the carriage returns are also read in, so I need to
chop them off and if $key is wrong crypt uses it anway and returns
spurious data.
So I have gotten it down to placing 2 dummy vars at the head of the
list thus:
DUMMY1
DUMMY2
John
Ac1091
Jane
Ac1099

   @data = `crypt $key <file.bin`;
   chop(@data);
   if($data[0] ne "DUMMY1) {
     die "Wrong Key \n";
   }   else {
     
   %list = @data;
  
    access list from here on
   }


Also, how do I detect if I'm going to use a key that doesnt exist ie,
someone enters James which isnt in the list.
    As you can probably tell I'm new to this game,  but using the
encrypted file this way, means I dont have to make temporary files
which may be tracable through ps etc.
I'm sure there is much improved way to do this, however like I said,
I'm new so ALL suggestions/advice welcome       
       
  Hope this makes sense, many thanks for your time.

  Alan.
   









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

Date: 28 Nov 1997 22:18:16 GMT
From: ii@fairhope.com (Tom)
Subject: Is this database solution feasable?
Message-Id: <65nfv8$od8$1@gte2.gte.net>

Hi,

I have a datafile of comma delimited fields. The data file stucture
has a fixed number of fields but each with variable length. The
datafile typically looks like this:

John Doe:123 First Lane:(222)222-3333:\n
Lisa Smith:321 Street:(111)111-1111\n
 ...

It all works fine right now with currently about 10 fields for each
person. However, I now need to expand this to about 250 fields. Which
is the most efficient way to read and write to such datafile when the
size of each record is this large?

I current use this simple method:

while ($rec = <FILE>)
{
  ($name:$street: ....) = split(/:/,$rec);
  ...
}

Can $rec handle such a long line of text?

Any advice is greatly appreciated.

Tom


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

Date: Fri, 28 Nov 1997 15:59:25 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Tom <ii@fairhope.com>
Subject: Re: Is this database solution feasable?
Message-Id: <Pine.GSO.3.96.971128155805.16101J-100000@user1.teleport.com>

On 28 Nov 1997, Tom wrote:

>   ($name:$street: ....) = split(/:/,$rec);

I don't know what you mean by the colons on the left. It's clear that this
is pseudocode, but maybe you meant to use commas? 

> Can $rec handle such a long line of text?

Perl scalars have no fixed size limit.

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 28 Nov 1997 18:29:10 GMT
From: "Gary Ng" <garyng@ibm.net>
Subject: Re: LWP with NT
Message-Id: <01bcfc2c$8d2c9100$f21952ca@dkkong>

Get Sarathy's 5.004_02 binary or 5.004_04 (should be out
real soon).

If you are running the ActiveState port, LWP needs to be
patched.

Gary


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

Date: 28 Nov 1997 17:05:38 -0800
From: hermit@cats.ucsc.edu (William R. Ward)
Subject: Re: perl 5 good simple book?
Message-Id: <waavhxc8q71.fsf@ese.UCSC.EDU>

Miten S Mehta <mehta@mama.indstate.edu> writes:
> I am wanting to learn perl 5 oo stuff.  I have read the perl programming
> book by Randal and it is somewhat hard for me when it gets to packages.
> could you please guide?
> 
> I mean I want to write some classes and use them just as I would in java.
> sorry about that.

It's not as hard as you think.  Look at some of the modules that come
with Perl, or download some from CPAN.  A good guilde to Perl modules
is on the Web at:
	http://world.std.com/~swmcd/steven/perl/
Also look at the perlmod and perlobj and perltoot documents that come
with Perl 5.004.

Books cost money and become obsolete quickly.  It's better to read
this stuff online, IMHO.

Good luck!

--Bill.

-- 
William R Ward          Bay View Consulting   http://www.bayview.com/~hermit/
hermit@bayview.com     1803 Mission St. #339        voicemail +1 408/479-4072
hermit@cats.ucsc.edu  Santa Cruz CA 95060 USA           pager +1 408/458-8862


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

Date: Fri, 28 Nov 1997 15:54:43 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: PERL Hourly Rates
Message-Id: <-2811971554430001@aggie.coaps.fsu.edu>

In article <65kqbt$pb6@shoga.wwa.com>, scribble@shoga.wwa.com (Tushar
Samant) wrote:

+ fearless@io.com writes:
+ >I think about the old FORTRAN code I used to write. I took one programming
+ >class the first time through college -- Introductory FORTRAN, I believe it
+ >was called -- and got a D+. Of course, there WAS this girl . . .
+ 
+ That's the difference between Fortran and Perl I think -- I got *better*
+ at Perl because of the girl.

Hey, you guys quit bashing fortran, willya? Good fortran, like good perl,
requires a lot of programmer discipline...

James

-- 
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: Fri, 28 Nov 1997 14:34:21 -0800
From: Eric Hilding <eric@hilding.com>
Subject: Perl Plug-In for Netscape?
Message-Id: <347F46ED.3953@hilding.com>

I've looked around but just can't seem to find the
info on an alleged Perl 'Plug-In' for Netscape.  Any
references would be appreciated.  Tnx.


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

Date: Fri, 28 Nov 1997 17:58:46 +1100
From: "Adam Clarke" <Adam.Clarke@StrategicData.com.au>
Subject: Re: perl shorter than csh challenge!!
Message-Id: <b1c7cd$113a31.76@woofa.strategicdata.com.au>

open FOO, 't.txt';
while (($myleft, $myright) = split /[=,\n]/, <FOO>)
    {if ($myleft eq 'c') {$cvalue = $myright}};

(note that my second line is split to be 80 char friendly.)

>Here is situation:
>
>We have a text file with arbitrary number of lines:
>
>a = 1
>b = 2
>c = 3
>d = 4

>In a csh script, to get the value of c (assuming all the values on the left
>side of the equal sign are unique):
>
>set str = `grep c filename`
>set cvalue = $str[ 3 ]
>






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

Date: Fri, 28 Nov 1997 15:41:46 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: Regex for three equal characters
Message-Id: <1d0fq17.10o98x5yy41kzN@roxboro-180.interpath.net>

? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
wrote:

> comdog@computerdog.com (brian d foy) writes:

> >that only matches three cosecutive characters...
> 
> It metches three equal characters wich is what the person asked in the
> subject line.
> 
> /(.)\1\1*/
> 
> Matchers what the person asked in the body.  I'm a programmer if I'm given
> confilicting specks I'll interprate them in the way to give me the less
> typing.

Then why didn't you go with
/(===)/;

That was the first thing that popped into my mind when reading the
subject.

-- 
John Moreno


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

Date: Sat, 29 Nov 1997 01:26:21 GMT
From: Phil Houstoun <pjhousto@cse.dnd.ca>
Subject: Resource Kit Anomaly
Message-Id: <347F6DB0.26630BCA@cse.dnd.ca>

Hi there,
   Has anybody else who has received the Resource Kit found that HTML
indexes of files contained in the CPAN archive on the CD are a tad
messed up? I've got URLs in the index.html files that point to the
basenames of compressed (.Z) files, so when you try to follow the
links you get the 'File Not Found' message, e.g. the first URL in
/CPAN/scripts/admin/index.html points to adduser, which doesn't exist,
but adduser.Z does. In addition, my /CPAN/CPAN.html is a link (ln -s,
that is) to a compressed file which, of course, loads the browser with
gibberish. Thanks.

-- 

Phil Houstoun            Voice: (613) 991-7173 
Email: remove the 'j' in pjhousto@cse.dnd.ca
-----------------------------------------------------------------------


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

Date: Fri, 28 Nov 1997 18:59:18 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Silly diamond operator (<>) problem?
Message-Id: <EKDE2u.Ax8@world.std.com>

"Greg McDermid" <mcdermidg@acm.org> writes:

>I tried your program and it worked, but I don't have a problem with @ARGV,
>it is just the <> that causes me problems! E.g. I can use the following bit
>of code:

>foreach $file (<@ARGV>)

The diamond operator has too different functions. If given a
filehandle, a glob, or a sclar containing the name of a filehandle, it
acts like the readline() method from the FileHandle package.  (It gets
the next line from the file.)

If given a list, or a scalar that doesn't evaluate to the name of a
filehandle, it is close to a synonym for the glob() function (it
returns the files that match, expanding wildcards.) The diamond
operator and glob function are a little bit different in that the
diamond operator handles lists, while glob does not.)

So in the line above, you are doing the following:

Getting a list of files passed to you from the shell.

Passing them to a shell and asking it to expand any wildcards that it
sees.

Taking the list that is returned (which would most likely be the same
list.) and iterating over it with a for loop.

You probably would be better off saying:

for $file (@ARGV)

Now the diamond operator has one additional trick.

If you don't put a scalar between the two angle brackets, (have a null
filehandle) the diamond operator works in its readline() like
function. For the file to read, it opens up each line contained in
@ARGV, so a simple script like


perl -e "print while <>" *

will print all the lines of all the files in the current directory.

See the perlop man page for details.
-- 
Andrew Langmead


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

Date: Fri, 28 Nov 1997 20:18:37 +0100
From: Sven Neuhaus <Sven.Neuhaus@de.uu.BLOCKSPAM.net>
Subject: Re: sort() corrupts data when using an "illogical" function to sort.
Message-Id: <347F190D.1253@de.uu.BLOCKSPAM.net>

Dear debugger,

as a followup to my previous observation - i have not been able
to produce this error on 
* Linux/Intel 2.0.x with Perl 5.003,
* Linux/Intel 2.1.x with Perl 5.004_4,
* FreeBSD freebsd 3.0-971022-SNAP with Perl 4 and Perl 5.004_1,
* OSF1 3.2/Alpha AXP with Perl 5.003,
* AIX 3.2 on RS/6000 with Perl 5.000.

The bug shows on Solaris/Sparc 2.5.1 and also on
* SunOS 4.1.3_U1 with Perl 5.001 and 5.004_04

Cheers,
-Sven
--
PS: $replyaddress =~ s/\.BLOCKSPAM// to reply by mail.


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

Date: 28 Nov 1997 16:05:40 -0600
From: scribble@shoga.wwa.com (Tushar Samant)
Subject: Re: sort() corrupts data when using an "illogical" function to sort.
Message-Id: <65nf7k$mik@shoga.wwa.com>

I guess nobody is guaranteeing anything when the comparison is
"illogical". But I was wondering -- if the sort is exactly like
we see quicksort described in textbooks, what could possibly go
wrong? You are only swapping elements, you can't get into an
infinite loop during the partitioning pass, it ends in n steps
no matter what the comparisons say, and all recursive calls are
on disjoint intervals, and have nothing to do with previous
comparisons.

Why am I dithering on about this? My point is maybe in your
installation the data gets corrupted for some consistent
compares too. Have you checked that.



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

Date: Fri, 28 Nov 1997 15:57:18 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Sven Neuhaus <Sven.Neuhaus@de.uu.BLOCKSPAM.net>
Subject: Re: sort() corrupts data when using an "illogical" function to sort.
Message-Id: <Pine.GSO.3.96.971128155532.16101I-100000@user1.teleport.com>

On Fri, 28 Nov 1997, Sven Neuhaus wrote:

> I think i've found a minor bug. I was trying to find a quick neat
> way to randomize an array. I found something using sort() and rand()
> that works ... but not always. It seems that certain results confuse
> perl's sort() enough to corrupt the resulting array:

Perl's sort routine requires that you have a stable sort order, since it
usually calls your system's qsort(3) which has the same requirement. Not a
bug. Cheers!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 28 Nov 1997 19:10:36 -0500
From: Tom.Horsley@worldnet.att.net (Thomas A. Horsley)
Subject: Re: sort() corrupts data when using an "illogical" function to sort.
Message-Id: <65nmhv$okg@mtinsc04.worldnet.att.net>

>I guess nobody is guaranteeing anything when the comparison is
>"illogical". But I was wondering -- if the sort is exactly like
>we see quicksort described in textbooks, what could possibly go
>wrong?

Depends on which textbook :-). This is actually a well known problem with
some vendor's implementation of qsort. Some qsorts rely the initial best of
3 sort in a partition moving array elements to the outer ends of the
partition which they "know" will stop the scan when it hits them so they
"know" they don't have to check the partition bounds, when the compare
routine returns inconsistent results, the scan of the partition goes merrily
whizzing past the end of the partition (and probably the end of the array as
well) once that happens, anything can occur.

I've been working on a qsort which I hope will eventually wind up built into
perl. My qsort does not have this problem (which is a foolish "optimization"
anyway, since calling the compare routine is vastly more overhead than
checking an index value against the partition boundary).

The latest and greatest version of my qsort routine can be found on my
web page (see my signature below for a pointer). But beware, the current
version isn't an adequate general purpose replacement since it does no
optimization of array element swaps and moves (it just calls memmove or
memcpy - a problem which will disappear when it is built into perl since
perl always sorts the same size elements (pointers) and that can easily
be optimized).
--
>>==>> The *Best* political site <URL:http://www.vote-smart.org/> >>==+
      email: Tom.Horsley@worldnet.att.net icbm: Delray Beach, FL      |
<URL:http://home.att.net/~Tom.Horsley> Free Software and Politics <<==+


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

Date: Fri, 28 Nov 1997 09:13:05 -0800
From: "Michael A. Chase" <mchase@ix.netcom.com>
Subject: Re: Win32::ODBC Question
Message-Id: <65n379$a3e@dfw-ixnews12.ix.netcom.com>

It looks like your SQL sorts by the fixed string 'Author'.  In the Oracle
RDBMS, if you need to sort by a column named "Author" as opposed to
"AUTHOR", you use quotes (") instead of (') around the column name.
Other  SQL databases may use different conventions.

Try the SQL via the normal interface for whatever RDBMS you are using to
see what results the SQL gives you.  This is always a good cross check on
the behavior of a script's logic.

To store something in order in Perl you need to use an array instead of a
hash.  If you want both, store the data in an array and use the index
number as the value in a hash element which has what you want to search
by as the hash key.

--
Mac :})   mchase@ix.netcom.com

Brent Michalski wrote in message <3479E04F.8FBF4D51@inlink.com>...
>I am trying to use a SQL command like the following in a database:
>
>$SQL="SELECT * FROM Documents ORDER BY 'Author'";
>  $db->($SQL);
>  while($db->FetchRow()) {
>    $checkin=""; # Moved 11/17/97 (Fixed problem)
>    undef %Data;
>    %Data = $db->DataHash();
>    ... more code ...
>  } # End of while.
>
>The command gets the required data properly, it just doesn't sort it.
>
>Win32::ODBC stores the result into a hash.  How can I get to all of my
>data, but in a sorted manner?
>
>Is this a limitation of Win32::ODBC?
>
>Is there a way to fix this?





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

Date: Sat, 29 Nov 1997 04:34:53 GMT
From: paul@pkamf.demon.co.uk
Subject: Writing to files
Message-Id: <880749299.17440.0.nnrp-09.9e98ada2@news.demon.co.uk>

Hi Guru's

I want to open a file, search for two 'markers' then insert text - a
variable - between the two.  Do I open the file so:

open(FILE,+<filename);   ?

or will this zap everything in the file?

Will 

$_ =~ /"marker"/ work... then {print $var;}

or someting similar work or am I missing something?

(Apart from locating the end of the marker ie the other string to mark
the boundary fot text insertion.)

Thanks for any help,

Paul



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

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

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