[10401] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3994 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 16 16:01:40 1998

Date: Fri, 16 Oct 98 13:00:23 -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           Fri, 16 Oct 1998     Volume: 8 Number: 3994

Today's topics:
    Re: Anyone for a Tyne+Wear.pm ?? <gellyfish@btinternet.com>
    Re: Are there any "perl.newbie" group or forum? birgitt@my-dejanews.com
    Re: ARGV inconsistent on subsequent runs (Larry Rosler)
    Re: Assigning a value to a var (Andrew M. Langmead)
        Chat server? <mkshanx@uxmail.ust.hk>
    Re: Combining two @array's (Clinton Pierce)
    Re: Compile Perl on As400 ? <jhi@alpha.hut.fi>
        count files.... <jamdiaz@klaskycsupo.com>
    Re: count files.... <matt@whiterabbit.co.uk>
    Re: count files.... <shawn@magma.ca>
    Re: count files.... (Larry Rosler)
    Re: count files.... <shawn@magma.ca>
    Re: Counting URLs (Craig Berry)
    Re: Counting URLs (Craig Berry)
    Re: getting all matches <uri@camel.fastserv.com>
    Re: How can I read HTML file in another host?? (Michael Budash)
    Re: Is this a bug? <jdporter@min.net>
    Re: Is this a bug? <rjanosi@uakron.edu>
    Re: Need help with this script (Greg Bacon)
        Perl Books briley@manning.com
    Re: Perl FAQ - error found in "#How_do_I_get_a_file_s_t <dgris@perrin.dimensional.com>
    Re: Printing in Landscape <jdubois@keane.com>
        Search Engine Question (Danny Groppo)
    Re: sorting <jdporter@min.net>
    Re: sorting <jdporter@min.net>
    Re: The space deletion woes... (Larry Rosler)
    Re: The space deletion woes... <eashton@bbnplanet.com>
    Re: The space deletion woes... (Richard S. Holmes)
    Re: The space deletion woes... (Larry Rosler)
        Too stupid <tim.hicks@lineone.net>
    Re: Too stupid <tim.hicks@lineone.net>
    Re: Too stupid (Larry Rosler)
    Re: Too stupid <shawn@magma.ca>
    Re: Using a variable in a grep search <aqumsieh@matrox.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 16 Oct 1998 17:40:23 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Anyone for a Tyne+Wear.pm ??
Message-Id: <707stn$i9$1@gellyfish.btinternet.com>

On 15 Oct 1998 22:58:46 +0100 Chris Benson <chrisb@jesmond.demon.co.uk> wrote:
> I fear I may regret this but:-
> 
> 	Are there any other Perl uses in the Tyne+Wear area who would 
> like to meet to discuss the furthering of Perl in the area, develop
> their Perl skills, or (even) have a sociable evening swapping IT 
> reminiscences?
> 
> The world is waiting to know!

No jokes about Alice in Sunderland I promise.

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


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

Date: Fri, 16 Oct 1998 19:16:50 GMT
From: birgitt@my-dejanews.com
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <708632$dqr$1@nnrp1.dejanews.com>

In article <703nm3$o19@kiev.wall.org>,
  larry@kiev.wall.org (Larry Wall) wrote:

>
> The trouble with teaching Perl as a second language is that there's
> no single suitable first language to go in front.

That means any language will do fine for the first one ? :-)

>
> Don't teach them Perl as a first language, or they'll never make it to
> their second language...

Does that mean Perl is like Pidgin ? :-)

Birgitt Funk

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 16 Oct 1998 10:54:03 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: ARGV inconsistent on subsequent runs
Message-Id: <MPG.1091281a703ef89b98981d@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <%pKV1.331$Sp1.3548@news.eli.net> on Fri, 16 Oct 1998 
16:23:23 GMT, frank brown <frank.brown@ci.seattle.wa.us> says...
 ... 
! print "ARGV == $#ARGV\n";
! foreach $i (0..$#ARGV) {
!   print "$i: $ARGV[$i]\n";
!   }
 ...
! D:\reg>testargs.pl
! ARGV == 0                    # what's this?
! 
! Is there some global perl variable which controls this strange
! behavior?

How could there be?  A registry change?  Please!!!

! What's going on here?  I'm running perl 5.005 built for MSWin32-x86-
! object (the ActiveState build from Win32 Resource Kit) on NT 4.0/SP3.

I just tried your code with the latest build (504, which I finally 
successfully downloaded yesterday -- see the relevant thread) in the 
same OS environment, and it worked properly, as expected.

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


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

Date: Fri, 16 Oct 1998 18:08:28 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Assigning a value to a var
Message-Id: <F0xME4.KGv@world.std.com>

Mark Priatel <mpriatel@chat.carleton.ca> writes:

>I actually have a fair amount of experience with Perl, but all the
>scripts I've created have taken data from forms.  However, if your
>running a script from a DOS environment  how can users assign data to
>variables?

There are many different ways of getting input to a program, the
command line, environment variables, standard input, and files for
instance.

The contents of the command line are stored in the array @ARGV.

Environment variables are stored in the hash %ENV.

Standard input and files behave very similarly. One of the key Unix
ideas was to treat all I/O as reading and writing to files. The big
difference though, between standard input and other files is that
STDIN is opened for you automatically when the program starts, where
other files have to be opened by you explicitly with the open()
function to associate a file with (in perl) a construct called a
filehandle. Perl on other operating systems has retained this Unix
idea, no matter how difficult for the person who developed that port
of perl. Once you have a filehandle, you can read data from it using
any of perl's input operators (<>, read(), sysread(), and getkey())

-- 
Andrew Langmead


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

Date: Sat, 17 Oct 1998 02:03:42 +0800
From: Shanx <mkshanx@uxmail.ust.hk>
Subject: Chat server?
Message-Id: <Pine.GSO.3.95L.981017020040.22119A-100000@uststf1>

Hi, 

I need a chat server to put on the web site of a client. Okay I scoured
the web and found several of them in Java, but they are either incomplete
and you have to pay for the fully functional version or are so shabby and
useless that you cannot use them on a popular business site. 

I would really appreciate if someone in this newsgroup could recomment me
some FREE chat server (and if possible something that does not need the
users of my site to download a client, for instance, something that can
be embedded in my web page). 

Thanks very much in advance. If possible, please reply to me directly as
well. 

Best regards,
Shashank



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

Date: 16 Oct 1998 17:51:50 GMT
From: cpierce1@cp500.fsic.ford.com (Clinton Pierce)
To: al.woods@pbi.ab.ca
Subject: Re: Combining two @array's
Message-Id: <70813m$4sk9@eccws1.dearborn.ford.com>

In article <705od9$td3$1@nnrp1.dejanews.com>,
	al.woods@pbi.ab.ca writes:
>Afternoon,
>
>I'm probably looking for a complex solution where a simple one is available
>but is there an easy way to combine 2 @array's?

As Tom C. points out in the Perl Cookbook, section 4.9: push.

If you want to preserve the original arrays, use it like this:

	push(@NEW, @A1, @A2);

Otherwise:

	push(@A1, @A2);

The last one is apparently optimized for speed, and does a lot less work
than the solution of:

	@A1=(@A1, @A2);


-- 
+------------------------------------------------------------------------+
|  Clinton A. Pierce    |   "If you rush a Miracle Man,   | http://www.  |
|  cpierce1@ford.com    |     you get rotten miracles"    | dcicorp.com/ |
| fubar@ameritech.net   |--Miracle Max, The Princess Bride| ~clintp      |
+------------------------------------------------------------------------+
GCSd-s+:+a-C++UALIS++++P+++L++E---t++X+b+++DI++++G++e+>++h----r+++y+++>y*



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

Date: 16 Oct 1998 21:23:01 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Compile Perl on As400 ?
Message-Id: <oeeyaqgnz7e.fsf@alpha.hut.fi>


Not compilation, sorry, but a binary distribution:

http://www.perl.com/CPAN/ports/index.html

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

Date: Fri, 16 Oct 1998 10:51:05 -0700
From: Jaime Diaz <jamdiaz@klaskycsupo.com>
Subject: count files....
Message-Id: <36278731.10D7@klaskycsupo.com>

looking for a piece of perl code that will count files in a
directory.........


thanks ...

Jamie


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

Date: Fri, 16 Oct 1998 20:00:59 +0100
From: Matt Pryor <matt@whiterabbit.co.uk>
To: jamdiaz@klaskycsupo.com
Subject: Re: count files....
Message-Id: <362797EB.91A7CFCF@whiterabbit.co.uk>

Jaime,

opendir (DIRECTORY,".") || die "FUBAR: $!\n";
@dircontents = readdir DIRECTORY;
$num = @dircontents;

print "There are $num files in the current directory!\n";
exit(0);

Matt
--


Jaime Diaz wrote:
> 
> looking for a piece of perl code that will count files in a
> directory.........
> 
> thanks ...
> 
> Jamie

-- 
Matt's daily comic strip
Porridge and Fartcakes
http://www.whiterabbit.co.uk/cartoons


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

Date: Fri, 16 Oct 1998 19:13:17 GMT
From: Shawn Corey <shawn@magma.ca>
Subject: Re: count files....
Message-Id: <36279A99.CA266B58@magma.ca>

This is a multi-part message in MIME format.
--------------6B0DC28774564D51AEB1E488
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

#!/usr/local/perl
#
use strict;

my $DEBUG = $ENV{ 'DEBUG' };

my $name;
my $count = 0;

for $name ( `ls -a` ){
	chomp( $name );
	if( -f $name ){
		$count ++;
		print STDERR "DEBUG: file $name\n" if $DEBUG;
	}
}

print "Total files: $count\n";


Jaime Diaz wrote:
> 
> looking for a piece of perl code that will count files in a
> directory.........
> 
> thanks ...
> 
> Jamie

-- 
Shawn Corey

s  @m  .c
 h   a   a
  a   g
   w   m
    n   a

PS: Larry, I tested it this time.
--------------6B0DC28774564D51AEB1E488
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Corey, Shawn
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Shawn Corey
n:              Corey;Shawn
org:            Corey Consultants
adr:            51 Wessex Road;;;Ottawa;Ontario;K2J 1X3;Canada
email;internet: shawn@magma.ca
title:          President
tel;work:       823-4132
tel;home:       823-4132
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard


--------------6B0DC28774564D51AEB1E488--



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

Date: Fri, 16 Oct 1998 12:16:33 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: count files....
Message-Id: <MPG.10913b6936b9bbe5989822@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <362797EB.91A7CFCF@whiterabbit.co.uk> on Fri, 16 Oct 1998 
20:00:59 +0100, Matt Pryor <matt@whiterabbit.co.uk> says...
> opendir (DIRECTORY,".") || die "FUBAR: $!\n";
> @dircontents = readdir DIRECTORY;
> $num = @dircontents;
> 
> print "There are $num files in the current directory!\n";
> exit(0);
 ... 
> Jaime Diaz wrote:
> > 
> > looking for a piece of perl code that will count files in a
> > directory.........

Well, not quite.  That will also count the pseudo-directories '.' and 
'..' and any other directories.

  $num = grep -f => readdir DIRECTORY;

ought to do it.

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


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

Date: Fri, 16 Oct 1998 19:27:21 GMT
From: Shawn Corey <shawn@magma.ca>
Subject: Re: count files....
Message-Id: <36279DE5.1CF4E79@magma.ca>

This is a multi-part message in MIME format.
--------------CEBADC847A4A1B2C1FED78D5
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi Matt,

The code you presented counts all entries in a directory. Although a
directory can be considered a type of file, pipes and devices can not.
You need to filter the directory list.

#!/usr/local/perl

opendir (DIRECTORY,".") || die "FUBAR: $!\n";
@dircontents = grep( -f $_, readdir DIRECTORY );
$num = @dircontents;

print "There are $num files in the current directory!\n";
exit(0);

Matt Pryor wrote:
> 
> Jaime,
> 
> opendir (DIRECTORY,".") || die "FUBAR: $!\n";
> @dircontents = readdir DIRECTORY;
> $num = @dircontents;
> 
> print "There are $num files in the current directory!\n";
> exit(0);
> 
> Matt
> --
> 
> Jaime Diaz wrote:
> >
> > looking for a piece of perl code that will count files in a
> > directory.........
> >
> > thanks ...
> >
> > Jamie
> 
> --
> Matt's daily comic strip
> Porridge and Fartcakes
> http://www.whiterabbit.co.uk/cartoons

-- 
Shawn Corey

s  @m  .c
 h   a   a
  a   g
   w   m
    n   a
--------------CEBADC847A4A1B2C1FED78D5
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Corey, Shawn
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Shawn Corey
n:              Corey;Shawn
org:            Corey Consultants
adr:            51 Wessex Road;;;Ottawa;Ontario;K2J 1X3;Canada
email;internet: shawn@magma.ca
title:          President
tel;work:       823-4132
tel;home:       823-4132
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard


--------------CEBADC847A4A1B2C1FED78D5--



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

Date: 16 Oct 1998 19:07:43 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Counting URLs
Message-Id: <7085hv$is1$1@marina.cinenet.net>

bill davidsen (davidsen@tmr.com) wrote:
: I want to count URLs in a (long) string.

Here's how I'd do it, using your match criterion, and fixing your 'mail'
to 'mailto' among a few other minor cleanups:

  $N_URL = () = m#\b(http|news|mailto|ftp)://\S#gi;

The () forces the m//g into list context.  A list of things that look like
urls is generated, then the assignment to the scalar converts the list to
its member count.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: 16 Oct 1998 19:11:20 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Counting URLs
Message-Id: <7085oo$is1$2@marina.cinenet.net>

Larry Rosler (lr@hpl.hp.com) wrote:
: Instead of splitting into a list and returning the number of elements, 
: you could simply return the number of matches directly.  This will 
: surely be faster (but I haven't benchmarked it).  Also, the '\S*' at the 
: end doesn't do anything, and the 'o' is superfluous because there are no 
: interpolations into the regex.
: 
:      $N_URL = m#\W(?:http|news|mail|ftp)://#g;

At long last I get to correct you, Larry (bringing our score to 1,321 to
1, I believe).  m//g in a scalar context just performs the next match, and
returns a boolean indicating whether it succeeded.  You need something
along the lines of

  $N_URL = () = m#\W .... #g;

to make this work properly.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: 16 Oct 1998 13:58:02 -0400
From: Uri Guttman <uri@camel.fastserv.com>
Subject: Re: getting all matches
Message-Id: <sar90igpexh.fsf@camel.fastserv.com>

>>>>> "EM" == Emmanuel Michon <michon@news.enst.fr> writes:

  EM> Jonathan Feinberg (jdf@pobox.com) wrote:

  EM> I found indeed this kind of thing:

  EM> $_ =  "ABCBD";

  EM> while (/(B.*)/g) {
  EM>     print("$1\n");

  EM> }

  EM> which returns one match: BCBD, and I would like to get
  EM> B, BC, BCB, BCBD, B, BD, not just the first-then-longest rule.

i don't think regexes can do this directly. by definition they move on
and don't give all possible matches at the current spot. perl allows you
to control if it the longest or shortest match (the ? modifier).

i doubt any other language could do this directly as perl's regex is
deemed by many to be the most powerful around.

  EM> : That depends on what you mean.
  EM> yes, the question wasn't very clear.

yes it wasn't.

  EM> any idea then?

IMO you would have to make this a program with loops. just grab the
first match (longest it would seem) and then make all the submatches by
looping and truncating the matched string.

as for you regex above it probably isn't the right match for what you
ask. 

	'ABCBD' =~ /(B.*)/

	gets 'BCBD' since it is the longest match

	'ABCBD' =~ /(B.*?)/

	gets 'B' since it is the shortest match (and silly since .*?
	will always match the null string)

you seem to want both the first longest string starting with B and of of
its shorter substrings AND the next string starting with B even if it
overlaps with the first string.

using index and substr would seem to be a better method for that. you
can find each occurence of 'B' and get the string to the end and then do
the truncate loop.

so again, be more clear on EXACTLY what you want. the example above is
not good enough to come up with a complete answer.

hth,

uri


-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: Fri, 16 Oct 1998 11:32:33 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: How can I read HTML file in another host??
Message-Id: <mbudash-1610981132330001@d37.nas1.napa.sonic.net>

In article <36273F51.AC462E7C@hitel.net>, ajou2 <ajou2@hitel.net> wrote:

>> Hi~
>> 
>> I am trying to wite perl program that read HTML files in another host.
>> I heard, I must use 'socket'.... is right?
>> 
>> My first try is....
>>    open (FILE,"<./http://www.abc.com/~any/index.html")
>> but failed...  -.- (yes, i'm beginer)
>> 
>> I'll wite the perl-cgi that check the HTML syntex in another host.
>> Is it impossible? or possible?
>> 
>> Thabks to any information and script!

see cpan for the LWP perl module - it's just what you need

specifically: http://www.perl.com/CPAN-local/modules/by-module/LWP/

(the libwww-perl module)

-- 
Michael Budash ~ Michael Budash Consulting
707-255-5371 ~ 707-258-7800 x7736
mbudash@sonic.net


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

Date: Fri, 16 Oct 1998 14:08:01 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Is this a bug?
Message-Id: <36278B81.C6698B3@min.net>

Renata Janosi wrote:
> 
> % sed -e '/^ *$/d' -e 's/[^|]$/&|/g' xx
> -rw-rw-r--   1 misjad   idf          1952 Sep  8 10:23 AK|
> -rw-rw-r--   1 misjad   idf           488 Sep  8 10:24 AN|
> -rw-rw-r--   1 misjad   idf           244 Sep  8 10:28 AS|
> -rw-rw-r--   1 misjad   idf           732 Sep  8 10:28 AU|
> 
> 
> % perl -ne 'unless ( /^ *$/ ) { s/[^|]$/$&|/; print }' < xx
> -rw-rw-r--   1 misjad   idf          1952 Sep  8 10:23 AK|
> -rw-rw-r--   1 misjad   idf           488 Sep  8 10:24 AN|
> -rw-rw-r--   1 misjad   idf           244 Sep  8 10:28 AS|
> |-rw-rw-r--   1 misjad   idf           732 Sep  8 10:28 AU|

The difference is that perl doesn't remove the trailing newline
automatically; it's included in $&, so the | gets appended AFTER
the newline.  Try this version:

perl -ne 'unless ( /^ *$/ ) { s/(.*[^|])\n/$1|\n/; print }' < xx

-- 
John "Gashlycrumb" Porter

"A fugitive and lurid gleam
  Obliquely gilds the gliding stream." -- EG


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

Date: Fri, 16 Oct 1998 15:32:51 -0400
From: Renata Janosi <rjanosi@uakron.edu>
Subject: Re: Is this a bug?
Message-Id: <36279F63.1C35@uakron.edu>

Jonathan Feinberg wrote:
> 
> Renata Janosi <rjanosi@uakron.edu> writes:
> 
> > % perl -ne 'unless ( /^ *$/ ) { s/[^|]$/$&|/; print }' < xx
> 
> Try this:
> 
>   % perl -wlne 'next if /^\s*/; chomp; s/([^|])$/$1|/; print';
> 
I tryed:

   % perl -wlne 'next if /^\s*/; chomp; s/([^|])$/$1|/; print;' < xx

and I got no output at all. I assumed switching the last 2 characters in
your suggestion was a typo. I'm definitely mystified.


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

Date: 16 Oct 1998 19:33:41 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Need help with this script
Message-Id: <70872l$88t$2@info.uah.edu>

In article <707r22$svo$1@nnrp1.dejanews.com>,
	w.wilson@mailexcite.com writes:
: $LOCK_EX = 2;
: $LOCK_UN = 8;

Don't do that.  It's better to say

    use Fcntl qw( :flock );

: while(<STDIN>) {
:         until(\cD) {
:                 @comment_array = <STDIN>;
:         }
: }

No.  The expression \cD will always be true (i.e. it's not one of
the values that Perl considers false), so the until loop won't
execute.  If you had said use strict (why didn't you?) this wouldn't
have even compiled.

To read everything into @comment_array, use

    @comment_array = <STDIN>;

instead of the while loop.

: sub unlock_file {
:         flock LOG, $LOCK_UN;
: }

It would be simpler to just close the file because that would release
any locks.

Greg.
-- 
VMS is a text-only adventure game. If you win you can use Unix.
    -- Bill Davidsen


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

Date: Fri, 16 Oct 1998 19:08:44 GMT
From: briley@manning.com
Subject: Perl Books
Message-Id: <7085jr$crr$1@nnrp1.dejanews.com>

Manning Publications Co. has recently received several book proposals for a
planned Perl series.  The topics of these books include.  OOP in Perl, Web
Database Design Using Perl and introductory programming concepts with Perl as
the implementing language.  If one or more of these topics interest you and
you want to review these proposals for us and tell us their worth, please
contact Brian Riley at briley@manning.com.  Thank You


--
Brian Riley
Publishing Assistant
Manning Publications Co.
Greenwich Ct.
(203)629-2211

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 16 Oct 1998 18:16:09 GMT
From: Daniel Grisinger <dgris@perrin.dimensional.com>
Subject: Re: Perl FAQ - error found in "#How_do_I_get_a_file_s_timestamp_"
Message-Id: <m3ems8js9a.fsf@perrin.dimensional.com>

cberry@cinenet.net (Craig Berry) writes:

> : - Amazed at the fact that so many people use free software
> : but still don't get it.
> 
> Not everyone knows how to do that.  A pointer to doc on the topic would be
> more helpful than this unwarranted slam.  (I'd provide said pointer, were
> I not among those who don't know.)

Take a look at Porting/patching.pod in your 5.005 distribution.
I also believe it's going to be in 5.004_05, but I don't have
a copy handy to check.

dgris
-- 
Daniel Grisinger          dgris@perrin.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: Fri, 16 Oct 1998 15:09:31 -0400
From: Joseph DuBois <jdubois@keane.com>
Subject: Re: Printing in Landscape
Message-Id: <362799EB.703C8601@keane.com>



mark_chunn@hp.com wrote:

> To anyone who may know:
>
> Someone mentioned to me that you could programatical change to print in
> landscape mode from a Netscape window. My web-site is written in
> HTML/perl.
> Any thoughts?

  It depends. Do you want to have the browser view the content in portrait
mode and then print in landscape mode, or do you want to have the browser
view the content in landscape mode and print in same?

   I have looked at ways to force the browser to print in landscape mode
the content as displayed, but have mostly failed from a perl point of
view. To get around the problem I have recently found a text 2 pdf perl
script
that will convert a text/html file into pdf (adobe acrobat reader) format
which
can be viewed/used by almost any browser. I still have to work on a few
things to get the printing right, but you can check out the following URL
to get a copy of the software. It is not free, but the price is very
reasonable
for what I hopefully will get it to do.

http://www.geocities.com/CapeCanaveral/Hangar/4794/

  Hope this helps. If you find another way in perl, post it here.

--
-------------------------------------------------------
Joseph DuBois            (Internet/Intranet Specialist)
mailto:jdubois@keane.com  (Work)  http://www.keane.com/




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

Date: Fri, 16 Oct 1998 18:29:46 GMT
From: gosdpads@yahoo.com (Danny Groppo)
Subject: Search Engine Question
Message-Id: <36279088.178235609@nntp.cts.com>

I am fairly new the whole programming world, so please be gentle.

I am working on a CGI program right now.  An HTML form is created,
asking for a person's first and last name, city, state, zip, and
country.  Of course, this is all pretty easy.  When someone hits
submit, the data is sent to my CGI program.  I am using the CGI
module.

First (which is actually not that difficult), I will be generating an
ID for the person, similar to Internic, based upon their initials.

The second part is giving be difficulty.  I would like to store their
information in a way that will make it easy to search for them via
their city, state, zip, country or name - a basic search engine.  What
kind of data structure and algorithm is used to do this? I would like
to be able to store 1_000_000 records and still have an efficient
search.  Can I do this with pure Perl, or do I need to implement some
SQL database?  

Oh, one final thing, during my search for "search engine" code, I
noticed that CPAN has a search engine.  I don't suppose that code is
available?

Any help is truly appreciated...

Danny Groppo
gosdpads@yahoo.com


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

Date: Fri, 16 Oct 1998 15:47:43 -0400
From: John Porter <jdporter@min.net>
Subject: Re: sorting
Message-Id: <3627A2DF.CDD9482C@min.net>

Uri Guttman wrote:
> 
> is some cases the actual code may be better to use since it may be more
> complex than a hash lookup. depending on the sort field you might need
> to do more work. so your opcode hash is more limited in its flexibility.

Indeed.

>   >> my @output = sort $sort_sub @input
> 
>   JP> My perl (5.004_04) complains that $sort_sub is not a GLOB ref.
>   JP> This fixes it:
> 
>   JP> my @output = sort( *sort_sub, @input );
> 
> as i said i didn't test it, i just invented it. :-)
> 
> &{$sort_sub} should work too.

Only if you think Perl "should" work some way other than
how it currently does.

You have now given two answers that don't work.
Care to step down to the world of mortal men, and test one
response before you post it?

Btw, the "solution" I gave before also doesn't work.
It really appears that Perl requires a code block, or the
bareword name of a subroutine.

Of course, it's easy to assign the desired code to a named
subroutine: assign to a glob ref, like so:

  *sort_sub = &build_sort_sub( 'age', 'name' );

Then you can:

  @output = sort sort_sub @input;

-- 
John "Gashlycrumb" Porter

"A fugitive and lurid gleam
  Obliquely gilds the gliding stream." -- EG


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

Date: Fri, 16 Oct 1998 15:59:25 -0400
From: John Porter <jdporter@min.net>
Subject: Re: sorting
Message-Id: <3627A59D.B3921C62@min.net>

John Porter wrote:
> 
> It really appears that Perl requires a code block, or the
> bareword name of a subroutine.

Interestingly, the subroutine name can be given via a scalar variable,
e.g.

  sub sort_routine { $b <=> $a }

  $sr = 'sort_routine';

  @out = sort $sr @in;

But a literal string is not allowed (5.004_04, anyway):

  @out = sort 'sort_routine' @in;

String found where operator expected at - line 6, at end of line
        (Missing semicolon on previous line?)
Can't find string terminator "'" anywhere before EOF at - line 6.

-- 
John "Gashlycrumb" Porter

"A fugitive and lurid gleam
  Obliquely gilds the gliding stream." -- EG


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

Date: Fri, 16 Oct 1998 11:03:45 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: The space deletion woes...
Message-Id: <MPG.10912a5ecd566aaa98981e@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <36278565.53871A11@bbnplanet.com> on Fri, 16 Oct 1998 
17:52:40 GMT, Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> 
says...
> Tk Soh wrote:
> 
> > Benchmark: timing 50000 iterations of All, One, tr...
> >        All:  8 wallclock secs ( 7.11 usr +  0.00 sys =  7.11 CPU)
> >        One: 11 wallclock secs (10.67 usr +  0.00 sys = 10.67 CPU)
> >         tr:  3 wallclock secs ( 2.81 usr +  0.00 sys =  2.81 CPU)
> 
> Hmmmm. Why is this so much faster? Larry? And would it work as
> advertised in all cases?

Absolutely right.  'tr/...//d;' is faster than 's/...//g;' all the time 
(pun?).

As I told Tk Soh by email, I just didn't think of enumerating the values 
represented by the character class "\s" in order to use 'tr'.  In other 
posting, I and others mentioned 'tr/ //d;' as the best choice if he 
really wanted to delete 'space' instead of 'whitespace'.

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


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

Date: Fri, 16 Oct 1998 18:32:13 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: The space deletion woes...
Message-Id: <36278EA9.C288D3EF@bbnplanet.com>

Larry Rosler wrote:

> Absolutely right.  'tr/...//d;' is faster than 's/...//g;' all the time
> (pun?).

Indeed, but _that_ much faster? Why, I guess I never took the time to
scrutenise the nuances between them before.

> As I told Tk Soh by email, I just didn't think of enumerating the values
> represented by the character class "\s" in order to use 'tr'.  In other
> posting, I and others mentioned 'tr/ //d;' as the best choice if he
> really wanted to delete 'space' instead of 'whitespace'.

Yes, I got that part and know the diff between space and whitespace, but
tr wouldn't have been as natural a choice for me as s in this instance.
Cool to see, that in this application it is not only useable but much
faster.

e.

After all, the cultivated person's first duty is to
always be prepared to rewrite the encyclopedia.  - U. Eco -


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

Date: 16 Oct 1998 14:48:10 -0400
From: rsholmes@rodan.syr.edu (Richard S. Holmes)
Subject: Re: The space deletion woes...
Message-Id: <xzcyaqg9wd1.fsf@rodan.syr.edu>

In article <36277B28.7D16E4C@email.sps.mot.com> Tk Soh <r28629@email.sps.mot.com> writes:

>#!/usr/local/bin/perl -w
>use Benchmark;
>
>$x = "  Here    goes     nothing one space now\t\fend\nhere";
>
>timethese (50000, {
>  All => sub { $_ = $x;  s/\s+//g },
>  One => sub { $_ = $x;  s/\s+?//g },
>  tr=> sub { $_ = $x; tr/ \t\n\r\f//d},
>} );

When I try running this I get:

   Ambiguous use of tr => resolved to "tr" => at foo line 9.
   Benchmark: timing 50000 iterations of All, One, tr...
   Undefined subroutine &main::CODE called at (eval 2) line 1.

But if I change sub {...} to '{...}', I get:

   Ambiguous use of tr => resolved to "tr" => at foo1 line 9.
   Identifier "main::x" used only once: possible typo at foo1 line 4.
   Benchmark: timing 50000 iterations of All, One, tr...
	  All:  2 secs ( 1.47 usr  0.00 sys =  1.47 cpu)
	  One:  3 secs ( 2.27 usr  0.00 sys =  2.27 cpu)
	   tr:  0 secs ( 0.36 usr  0.00 sys =  0.36 cpu)
	       (warning: too few iterations for a reliable count)

Leaving aside -w's nattering, how come Tk Soh can benchmark a sub
reference and I can only benchmark a string?  Do we have an out of
date Benchmark.pm here, or something?

-- 
- Rich Holmes
  Syracuse, NY /             We have more important things to do...
  Newport News, VA           Censure and move on!  Sign the petition at
  rsholmes@earthling.net     <http://www.moveon.org>


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

Date: Fri, 16 Oct 1998 12:08:20 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: The space deletion woes...
Message-Id: <MPG.1091397ea460f58e989820@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <xzcyaqg9wd1.fsf@rodan.syr.edu> on 16 Oct 1998 14:48:10 -
0400, Richard S. Holmes <rsholmes@rodan.syr.edu> says...
 ... 
> Leaving aside -w's nattering, how come Tk Soh can benchmark a sub
> reference and I can only benchmark a string?  Do we have an out of
> date Benchmark.pm here, or something?

No, you have an out of date perl processor.  The symptom you report 
occurs with 5.002 but not with 5.004 (or 5.005, of course).  I don't 
know about 5.003, but who cares?

Update your perl, or use the string form exclusively for Benchmark.pm

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


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

Date: Fri, 16 Oct 1998 19:09:11 +0100
From: "Tim Hicks" <tim.hicks@lineone.net>
Subject: Too stupid
Message-Id: <OZLV1.19821$tF.473@news-reader.bt.net>

I apologise for the utter stupidity of my post but it is driving me crazy.
I have written a very basic program and have made it run.  The outcome of
the program is to print the circumference of a circle.  Therefore, the final
line in the program is...

print ("$circumference");

 ... The problem is that the DOS window closes too quickly to actually see
the result.  I'm not even sure if this is a perl or windows/dos problem, but
how can I stop this happening.  It doesn't happen with any other dos prompt
windows that I open, they just say 'finished' in the title bar (or something
like that).

Thanks for any help; I'll try to make my posts a little more beneficial to
others in future.

Tim




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

Date: Fri, 16 Oct 1998 19:48:11 +0100
From: "Tim Hicks" <tim.hicks@lineone.net>
Subject: Re: Too stupid
Message-Id: <jyMV1.19826$tF.480@news-reader.bt.net>

Here is what I have managed to write so far.  See message below for more
details.

#!/usr/bin/perl -w
print ("Enter the radius of the circle.  ");
$radius = <STDIN>;
 chomp ($radius);
$circumference = ((2 * 3.1415)* $radius);
print ("$circumference");


Tim


Tim Hicks wrote in message ...
>I apologise for the utter stupidity of my post but it is driving me crazy.
>I have written a very basic program and have made it run.  The outcome of
>the program is to print the circumference of a circle.  Therefore, the
final
>line in the program is...
>
>print ("$circumference");
>
>... The problem is that the DOS window closes too quickly to actually see
>the result.  I'm not even sure if this is a perl or windows/dos problem,
but
>how can I stop this happening.  It doesn't happen with any other dos prompt
>windows that I open, they just say 'finished' in the title bar (or
something
>like that).
>
>Thanks for any help; I'll try to make my posts a little more beneficial to
>others in future.
>
>Tim
>
>




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

Date: Fri, 16 Oct 1998 12:11:01 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Too stupid
Message-Id: <MPG.10913a1d88aa446f989821@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <OZLV1.19821$tF.473@news-reader.bt.net> on Fri, 16 Oct 1998 
19:09:11 +0100, Tim Hicks <tim.hicks@lineone.net> says...
> ... The problem is that the DOS window closes too quickly to actually see
> the result.  I'm not even sure if this is a perl or windows/dos problem, but
> how can I stop this happening.  It doesn't happen with any other dos prompt
> windows that I open, they just say 'finished' in the title bar (or something
> like that).

Two solutions:

Open a DOS window and execute the program from the command line.

End the program with another read from <STDIN>.

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


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

Date: Fri, 16 Oct 1998 19:21:20 GMT
From: Shawn Corey <shawn@magma.ca>
Subject: Re: Too stupid
Message-Id: <36279C7C.94B52065@magma.ca>

This is a multi-part message in MIME format.
--------------1047CE8AB199BC52781F7E33
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi Tim,

Add the following lines to the end of you program.

print "\nPress ENTER to exit: ";
my $tmp = <STDIN>;

This waits for the user to enter a line. The problem you encountered is
a MS-DOS one. There is a way of changing this by fooling with the
Properties of the MS DOS Prompt but I found that if I change it once, it
changes for all my MS DOS Prompts. I must be doing something wrong.
Therefore I add the above code when I want a program to wait. Crude but
effective. BTW xterm does the same thing. Again, there are options to
prevent this but the above code is an universal solution. 

Tim Hicks wrote:
> 
> Here is what I have managed to write so far.  See message below for more
> details.
> 
> #!/usr/bin/perl -w
> print ("Enter the radius of the circle.  ");
> $radius = <STDIN>;
>  chomp ($radius);
> $circumference = ((2 * 3.1415)* $radius);
> print ("$circumference");
> 
> Tim
> 
> Tim Hicks wrote in message ...
> >I apologise for the utter stupidity of my post but it is driving me crazy.
> >I have written a very basic program and have made it run.  The outcome of
> >the program is to print the circumference of a circle.  Therefore, the
> final
> >line in the program is...
> >
> >print ("$circumference");
> >
> >... The problem is that the DOS window closes too quickly to actually see
> >the result.  I'm not even sure if this is a perl or windows/dos problem,
> but
> >how can I stop this happening.  It doesn't happen with any other dos prompt
> >windows that I open, they just say 'finished' in the title bar (or
> something
> >like that).
> >
> >Thanks for any help; I'll try to make my posts a little more beneficial to
> >others in future.
> >
> >Tim
> >
> >

-- 
Shawn Corey

s  @m  .c
 h   a   a
  a   g
   w   m
    n   a

PS: Larry, this one is not tested.
--------------1047CE8AB199BC52781F7E33
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Corey, Shawn
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Shawn Corey
n:              Corey;Shawn
org:            Corey Consultants
adr:            51 Wessex Road;;;Ottawa;Ontario;K2J 1X3;Canada
email;internet: shawn@magma.ca
title:          President
tel;work:       823-4132
tel;home:       823-4132
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard


--------------1047CE8AB199BC52781F7E33--



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

Date: Fri, 16 Oct 1998 14:17:22 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Using a variable in a grep search
Message-Id: <Pine.SUN.3.96.981016141204.5180A-100000@tigre.matrox.com>

On Fri, 16 Oct 1998, The Cheeze Whiz wrote:

    > I'm trying to write a script that performs a grep search of a file and
    > allows users to specify the search term.  The problem I'm facing is that
    > '$' is a regular expression pattern and escaping the $ looks for '$'
    > (rather than parsing the perl variable).

Perl is smart enough to distinguish the end of line line anchor '$' from a
Perl variable. Did you try it? If so, what happened?

    > 
    > For example:
    > 
    >     print "Enter the search term:";
    >     $input = <STDIN>;
    > 
    >     open(MYFILE,"myfile");

Always check the result of your open() ..

    >     @myfile = <MYFILE>;
    >     close MYFILE;

 .. and your close()!

    > 
    > ->  @results = grep (/$input/, @myfile);

This is fine ... what happened when you tried that code?

    > 
    >     print "$results[0]\n";
    > 
    > 
    > What's the trick?  

Maybe you are getting wrong results because you don't chomp() off the
extra carriage return character in $input. After 

$input = <STDIN>;

add:

chomp $input;

    > 
    > Thanks,
    > Michael

Hope this helps,
--
Ala Qumsieh               email: aqumsieh@matrox.com
ASIC Design Engineer      phone: (514) 822-6000 x7581
Matrox Graphics Inc.      (old) webpage :
Montreal, Quebec          http://www.cim.mcgill.ca/~qumsieh



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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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