[19606] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1801 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 24 06:05:27 2001

Date: Mon, 24 Sep 2001 03:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1001325908-v10-i1801@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 24 Sep 2001     Volume: 10 Number: 1801

Today's topics:
    Re: [ASK]Perl and Windows <hkdennis2k@yahoo.com.hk>
        alternatives to ps command (perl misk)
        faster execution (venus)
    Re: faster execution <Thomas@Baetzler.de>
    Re: faster execution <Rainer.Klier@erl.sbs.de>
    Re: Help with reading web page from socket. (Martien Verbruggen)
        how to match things like this (Dav Lam)
    Re: how to match things like this <please@no.spam>
    Re: how to match things like this <wyzelli@yahoo.com>
    Re: how to match things like this <Rainer.Klier@erl.sbs.de>
    Re: Regular Expression Problem <bart.lateur@skynet.be>
        setting error return values (perl misk)
    Re: setting error return values <Thomas@Baetzler.de>
    Re: Simple Random Problem (BUCK NAKED1)
    Re: Simple Random Problem <swessels@usgn.net>
    Re: Simple Random Problem <wyzelli@yahoo.com>
    Re: Simple Random Problem (Logan Shaw)
    Re: Simple Random Problem <wyzelli@yahoo.com>
    Re: Sorting Hashes nobull@mail.com
    Re: This has got to be a bug <bart.lateur@skynet.be>
    Re: Using URLs as hash keys <bart.lateur@skynet.be>
    Re: Using URLs as hash keys <Thomas@Baetzler.de>
    Re: Using URLs as hash keys (Martien Verbruggen)
        What good is the hyphen for named parameters? <bart.lateur@skynet.be>
    Re: Why are tabs converted to spaces? <bart.lateur@skynet.be>
    Re: win32 stat in directory with 4682 files <bart.lateur@skynet.be>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 24 Sep 2001 16:38:56 +0800
From: "Dennis" <hkdennis2k@yahoo.com.hk>
Subject: Re: [ASK]Perl and Windows
Message-Id: <9omr3r$59r4@rain.i-cable.com>

Thanks,






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

Date: 24 Sep 2001 03:01:03 -0700
From: perlmisk@yahoo.co.uk (perl misk)
Subject: alternatives to ps command
Message-Id: <7fe42fcd.0109240201.7a6f98c2@posting.google.com>

as i understand it, it is considered "bad practice" to use shell or
system commands.

I am trying to get a process listing, but cannot find an alternative
to `ps -fu`.  This isn't so much a problem until:

# grab the output from the ps command
my $ps = `ps -fu$user`;

# convert our scalar $ps into an array, break on \n
my @aps = split /\n/, $ps;

# loop each real processes
foreach my $iaps (@aps) {
 
    # these are the only elements we require
    my ($stime, $time, $cmd);               

    # loop each possible process type
    foreach my $p (@processes) {

        # match the elements we require
        if ($iaps =~
m/^\s+\w+\s+\d+\s+\d+\s+\d+\s+([\d:]+)\s.+\s([\d:]+)\s(.+)$/) {

            # save the values we have matched from above regex
            $cmd   = $3; $stime = $1; $time  = $2;

        }

    }

}

This all works fine, for all processes created in the pas 24hrs, eg:
andrewm  12585  1130  0 09:19 pts/5    00:00:00 telnet lion

but fails on older processes, eg:
andrewm   4195  1098  0 Sep 21 pts/1    00:00:00 telnet lion

apart from creating a hugely complicated regex that will catch all
occurences, what else can I do?

Regards

Andy


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

Date: 24 Sep 2001 01:16:27 -0700
From: train2venus@hotmail.com (venus)
Subject: faster execution
Message-Id: <bce84cea.0109240016.6638f273@posting.google.com>

Hi all,

I wrote a perl script but I'm not sure if there's a better way of
doing it.
The script runs very slow because the input file (txt file) I'm
reading from is very big. The script reads the input text file and if
it finds any location that equals to the list in array, it will
replace it with location code.
Here's a part of the script:

 ...
 ....

	%LOCATION = (
	'Gaborone,,BC',			"GBE",
	'Cairo,,EG',			"CAI",
	'Nairobi,,KN',			"NBO",
	'Dar es Salaam,,TN',		"DAR",
	'Kampala,,UG',			"KLA",
	'Cape Town,,ZA',			"CPT",
	'Johannesburg,,ZA',			"JNB",
	'Pretoria,,ZA',			"PRY",
	'Harare,,ZW',			"HRE",
	'Windhoek,,NM',			"ERS",
	
	'London,,UK',			"LON",
	'Vienna,,OS',			"VIE",
	'Brussels,,BX',			"BRU",
	'Copenhagen,,DN',			"CPH",
	'Berlin,,DL',			"BER",
	'Frankfurt,,DL',			"FRA",
	'Athens,,GR',			"ATH",
	'Tallinn,,EO',			"TLL",
	'Dublin,,IE',			"DUB",
	'Madrid,,SP',			"MAD",
	 );
	
	
	while (<INPUT_FILE>) {
    	chomp;
    	( $city, $state, $country, @data ) = split(/,/); 
   	 $location = "$city,$state,$country";
   	 if ( defined @data[0] && ! defined $StartDD ) {
		$StartDD = @data[0];
  	  }
  	   $day3 = $data[8];   $max3 = $data[9];       $min3 = $data[10];  
   $wx3 = $CONDITION{$data[11]};
   	 
   	 foreach $location_name (%LOCATION ) {
        	$location_code = $LOCATION{$location_name};
        
		if ($location_name eq $location ) {
		
		printf FILE "$location_code\,"; 
			printf FILE "%4s", "$min3\,";
			printf FILE "%4s", "$max3\,";
			printf FILE "%1s", "$wx3\n";
			
		}      
	
	}
	close(INPUT_FILE);
	close(FILE);
	}

Thanks in advance.
Regards,
Venus


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

Date: Mon, 24 Sep 2001 11:00:57 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: faster execution
Message-Id: <3dttqt4gm4leokkep17m2dibllab32b8is@4ax.com>

On 24 Sep 2001 01:16:27 -0700, train2venus@hotmail.com (venus) wrote:
>I wrote a perl script but I'm not sure if there's a better way of
>doing it.
[...]
>	%LOCATION = (
>	'Gaborone,,BC',			"GBE",
[...]
>	 );
[...]
>   	 foreach $location_name (%LOCATION ) {
>        	$location_code = $LOCATION{$location_name};
>        
>		if ($location_name eq $location ) {
[...]

You don't need that loop - all you have to do is to see wether you
have an element with key $location in %LOCATION:

if( exists $LOCATION{$location} ){
[...]

HTH,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


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

Date: Mon, 24 Sep 2001 10:24:09 -0100
From: Rainer Klier <Rainer.Klier@erl.sbs.de>
Subject: Re: faster execution
Message-Id: <3BAF17D9.DB8A01B@erl.sbs.de>

Hi,

venus wrote:
> 
[...]
> reading from is very big. The script reads the input text file and if
> it finds any location that equals to the list in array, it will
> replace it with location code.
[...]
>          $location = "$city,$state,$country";
[...]
 
>          foreach $location_name (%LOCATION ) {
>                 $location_code = $LOCATION{$location_name};
[...]
>         }

Shouldn't this do it instead of the foreach loop:

$location_code = $LOCATION{$location};
if(defined($location_code)) {
  printf FILE "$location_code\,";
  printf FILE "%4s", "$min3\,";
  printf FILE "%4s", "$max3\,";
  printf FILE "%1s", "$wx3\n";
}

Regards, Rainer


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

Date: Mon, 24 Sep 2001 19:51:52 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Help with reading web page from socket.
Message-Id: <slrn9qu0ho.8ai.mgjv@martien.heliotrope.home>

[Please in the future, put your reply _after_ the suitably trimmed text
you reply to. It is the commonly accepted quoting style on this
newsgroup, and Usenet in general] 


On Sun, 23 Sep 2001 11:09:04 -0400,
	Brian Carlson <bcarlso4@bellsouth.net> wrote:
> laura fairhead wrote:
> 
>> On Sun, 23 Sep 2001 07:08:04 -0400, Brian Carlson <bcarlso4@bellsouth.net> wrote:
>>
>> >Here's what im doing....
>> >
>> >print $socket "GET /mlb/scoreboard HTTP:/1.0\n\n";
>>
>> telnet msn.espn.go.com 80
>>
>> GET /mlb/scoreboard HTTP/1.0
>>
>> #                       ^no colon
> 
> That was it.  Just another example the flavors of web standards.  This
> worked just fine on a couple other servers, but not on espn.

Quote from RFC 1945 (HTTP 1.0)

    HTTP-Version   = "HTTP" "/" 1*DIGIT "." 1*DIGIT

Quote from RFC 2068 (HTTP 1.1)

       HTTP-Version   = "HTTP" "/" 1*DIGIT "." 1*DIGIT

Maybe the problem wasn't that there were multiple web standards and you
happened to be using one of the less used ones, but maybe you just
simply violated _the_ HTTP standards...

Martien
-- 
Martien Verbruggen              | Since light travels faster than
Interactive Media Division      | sound, isn't that why some people
Commercial Dynamics Pty. Ltd.   | appear bright until you hear them
NSW, Australia                  | speak?


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

Date: 24 Sep 2001 00:50:45 -0700
From: crud@hongkong.com (Dav Lam)
Subject: how to match things like this
Message-Id: <fc25f4f2.0109232350.2da53505@posting.google.com>

i wondering how to match a string that not include another substring,
because it's not a char class but a string, i can't use something like
[^], but what can i do?hope there is somebody help me out of this.

Thanks in advance.


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

Date: Mon, 24 Sep 2001 07:56:40 GMT
From: Andrew Cady <please@no.spam>
Subject: Re: how to match things like this
Message-Id: <87sndd81mt.fsf@homer.cghm>

crud@hongkong.com (Dav Lam) writes:

> i wondering how to match a string that not include another
> substring, because it's not a char class but a string, i can't use
> something like [^], but what can i do?hope there is somebody help me
> out of this.

One way:

/(?!another substring).*/


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

Date: Mon, 24 Sep 2001 17:49:29 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: how to match things like this
Message-Id: <LUBr7.1$2W3.348@wa.nnrp.telstra.net>

"Dav Lam" <crud@hongkong.com> wrote in message
news:fc25f4f2.0109232350.2da53505@posting.google.com...
> i wondering how to match a string that not include another substring,
> because it's not a char class but a string, i can't use something like
> [^], but what can i do?hope there is somebody help me out of this.
>

Try negating the binding operator and checking for the string you don't want
like:

if ($string !~ m/$stringidontwant/){
    # That string is not in $string
}

Wyzelli
--
@x='074117115116032097110111116104101114032080101114108032104097099107101114
'=~/(...)/g;
print chr for @x;




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

Date: Mon, 24 Sep 2001 10:32:43 -0100
From: Rainer Klier <Rainer.Klier@erl.sbs.de>
Subject: Re: how to match things like this
Message-Id: <3BAF19DB.48CD339E@erl.sbs.de>

Andrew Cady wrote:
> 
> crud@hongkong.com (Dav Lam) writes:
> 
> > i wondering how to match a string that not include another
> > substring, because it's not a char class but a string, i can't use
> > something like [^], but what can i do?hope there is somebody help me
> > out of this.
> 
> One way:
> 
> /(?!another substring).*/

Another way: index($string,$substring) == -1  
Should be much faster than regex.

Rainer


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

Date: Mon, 24 Sep 2001 08:42:34 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Regular Expression Problem
Message-Id: <6fstqtg8lcfpngmvovtigd882uvmn82irn@4ax.com>

Scott wrote:

>(please forgive the Java style code...i am using a library)
>
>myString = " ....multi-lines of text i don't need...\n"
>myString += "#DATA"     // this flags my data section
>myString += "..multi-lines of data i DO need....\n"
>myString += "#0"        // this flags the end of my data.

use .= not += .  Perhaps now it will work?

-- 
	Bart.


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

Date: 24 Sep 2001 01:58:35 -0700
From: perlmisk@yahoo.co.uk (perl misk)
Subject: setting error return values
Message-Id: <7fe42fcd.0109240058.6090f9e1@posting.google.com>

when writing perl modules, how do you set return values and how do you
set $! to be a meaningful message?


START SCRIPT
my $ret;
unless ($ret = &pm::foo($bar) == 0) {
    print "Run-time error with &ret::foo($bar): $ret $!\n";
}
END SCRIPT

START PACKAGE
package pm;

sub foo {
    return 3;
}
END PACKAGE

just prints:
Run-time error with &ret::foo($bar): 

so am I right in thinking that "exit;" inside of a PM would exit the
entire program and not just that module? if so how does this differ
from die;?

Many thanks and regards

Andy


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

Date: Mon, 24 Sep 2001 11:20:53 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: setting error return values
Message-Id: <d6utqtca6f0r0sm1ilq1flhujnhqpbte0m@4ax.com>

On 24 Sep 2001 01:58:35 -0700, perlmisk@yahoo.co.uk (perl misk) wrote:
>when writing perl modules, how do you set return values and how do you
>set $! to be a meaningful message?

Try "perldoc perlvar".

$! interfaces with the standard C library errno variable and the
associated strerror messages, so you can't just have it return your
custom error message.

For what I think you're trying to do, you should probably use eval,
die and $@. See section "Error Indicators" in "perldoc perlvar".

HTH,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


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

Date: Mon, 24 Sep 2001 02:00:35 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Simple Random Problem
Message-Id: <26465-3BAEDA13-103@storefull-244.iap.bryant.webtv.net>

Thanks. I know I didn't need a hash for that; but I'd never written an
associative array, and needed the practice. I had written it previously
as an array(below); and it worked great. I wonder why the  array script
below didn't need a +1 added to int? or maybe it did???

#!/usr/bin/perl -wT 
use CGI::Carp qw(fatalsToBrowser); 
use strict; 
print "Content-type: text/html\n\n"; 
print "<HTML><HEAD><TITLE>Random Text Script</TITLE> 
</HEAD><BODY>"; 
my @text = ( 
"<font color=blue size=1>Random Text 1</font>", 
"<font color= red size=2>Random Text 2</font>", 
"<font color=brown size=4><strong>Random Text 3</strong></font>", "<font
color= black size=6><em>Random 4</em></font>", 
"<font color=green size=2>Random Text 5</font>"); 
my $rand = int(rand(@text)); 
my $random_text = $text[$rand]; 
print "$random_text<BR>"; 
print "</BODY></HTML>"; 

Best to all!
--Dennis



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

Date: Mon, 24 Sep 2001 07:26:12 GMT
From: "Scott Wessels" <swessels@usgn.net>
Subject: Re: Simple Random Problem
Message-Id: <oeBr7.51756$aZ6.13023639@news1.rdc1.az.home.com>


> Thanks. I know I didn't need a hash for that; but I'd never written an
> associative array, and needed the practice. I had written it previously
> as an array(below); and it worked great. I wonder why the  array script
> below didn't need a +1 added to int? or maybe it did???

it didn't because in scalar context @array returns the number of elements in
the array + 1

> my $rand = int(rand(@text));

so you inadvertently did the right thing.

Regards,
Scott Wessels






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

Date: Mon, 24 Sep 2001 17:06:58 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Simple Random Problem
Message-Id: <UgBr7.49$kM3.709@wa.nnrp.telstra.net>

"BUCK NAKED1" <dennis100@webtv.net> wrote in message
news:26465-3BAEDA13-103@storefull-244.iap.bryant.webtv.net...
> Thanks. I know I didn't need a hash for that; but I'd never written an
> associative array, and needed the practice. I had written it previously
> as an array(below); and it worked great. I wonder why the  array script
> below didn't need a +1 added to int? or maybe it did???
>
> #!/usr/bin/perl -wT
> use CGI::Carp qw(fatalsToBrowser);
> use strict;
> print "Content-type: text/html\n\n";
> print "<HTML><HEAD><TITLE>Random Text Script</TITLE>
> </HEAD><BODY>";
> my @text = (
> "<font color=blue size=1>Random Text 1</font>",
> "<font color= red size=2>Random Text 2</font>",
> "<font color=brown size=4><strong>Random Text 3</strong></font>", "<font
> color= black size=6><em>Random 4</em></font>",
> "<font color=green size=2>Random Text 5</font>");
> my $rand = int(rand(@text));
> my $random_text = $text[$rand];
> print "$random_text<BR>";
> print "</BODY></HTML>";

The difference is that an array is indexed from 0 (0 .. 2) whilst your hash
(Assoc Array) was indexed by keys from 1 (1 .. 3).  You could have made the
keys to your hash 0, 1, 2 and that would also solve the problem.

Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;




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

Date: 24 Sep 2001 02:39:06 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Simple Random Problem
Message-Id: <9omnuq$nfg$1@charity.cs.utexas.edu>

In article <oeBr7.51756$aZ6.13023639@news1.rdc1.az.home.com>,
Scott Wessels <swessels@usgn.net> wrote:
>
>> Thanks. I know I didn't need a hash for that; but I'd never written an
>> associative array, and needed the practice. I had written it previously
>> as an array(below); and it worked great. I wonder why the  array script
>> below didn't need a +1 added to int? or maybe it did???
>
>it didn't because in scalar context @array returns the number of elements in
>the array + 1

Well, it returns the number of elements, which is normally one greater
than the index of the last thing in the array.

  - Logan
-- 
"Everybody
 Loves to see              
 Justice done
 On somebody else"     ( Bruce Cockburn, "Justice", 1981 )


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

Date: Mon, 24 Sep 2001 17:17:57 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Simple Random Problem
Message-Id: <brBr7.51$kM3.877@wa.nnrp.telstra.net>

"Scott Wessels" <swessels@usgn.net> wrote in message
news:oeBr7.51756$aZ6.13023639@news1.rdc1.az.home.com...
>
> > Thanks. I know I didn't need a hash for that; but I'd never written an
> > associative array, and needed the practice. I had written it previously
> > as an array(below); and it worked great. I wonder why the  array script
> > below didn't need a +1 added to int? or maybe it did???
>
> it didn't because in scalar context @array returns the number of elements
in
> the array + 1

You mean the index of the last element in the array + 1 which == the number
of elements in the array.

Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
$d='$_$a$s$b$w';$e='$_$a$s$b';sub d{$h=shift;$h=~s/\$(\w+)/${$1}/g;return$h}
sub
e{return(shift!=1)?'s':''}for(reverse(1..100)){$s=e($_);$f=d($d);$g=d($e);
$c.="$f\n$g\n$t\n";$_--;$s=e($_);$e=d($d);$c.="$e\n\n";}print"$c*hic*";




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

Date: 24 Sep 2001 08:19:46 +0100
From: nobull@mail.com
Subject: Re: Sorting Hashes
Message-Id: <u94rptdjzs.fsf@wcl-l.bham.ac.uk>

"Michael J. Vincent" <mjvincent@lucent.com> writes:

> Subject: Sorting Hashes

FAQ: "How do I sort a hash (optionally by value instead of key)?"

You are supposed to check the FAQ _before_ you post.

>     	An example:
> 
>     	$hash{172.16.5.1} = 5

You probably need quotes in there.  Without them 172.16.5.1 is interpreted as
chr(172).chr(16).chr(5).chr(1) and I strongly suspect that's not what
you wanted.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Mon, 24 Sep 2001 08:04:57 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: This has got to be a bug
Message-Id: <88qtqt87laorc1c3f30s6pebu79te3l7dc@4ax.com>

David Combs wrote:

>One small question: just how often (seems like "never") is that
>documentation *updated*?
>
>For instance, from time to time an item from the faq gets
>"autoposted" here, to cplmisc.  People comment on it,
>note errors in it, show better ways of saying things,
>show better examples, etc, etc.
>
>QUESTION: *when*, if ever, do those fixes get incorporated
>*into* that comes-with-perl documentation?

All the time. When you get a more recent version of perl, you get
updated docs.

-- 
	Bart.


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

Date: Mon, 24 Sep 2001 08:57:13 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Using URLs as hash keys
Message-Id: <26ttqt48726jt9qiiepo35eishrjb2ufid@4ax.com>

aL wrote:

>Does anyone know of any in-built limit to the size of keys?

Memory restrictions will limit how many hash entries, and what maximum
length, will be practical. But there's no real fixed limit, I think, at
least not under several megabytes (32 bit length).

-- 
	Bart.


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

Date: Mon, 24 Sep 2001 11:10:32 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Using URLs as hash keys
Message-Id: <5kttqt01nsmrbv9qibshgaq4r8d0lumo5u@4ax.com>

On Mon, 24 Sep 2001 17:00:13 +1000, "aL" <nobody@nowhere.com> wrote:
>Does anyone know of any in-built limit to the size of keys?

They're "limited" to the size of ordinary Perl scalar values - and
that limit depends on your architecture. Chances are good that you'll
be running out of memory before you hit that limit :-)

You shouldn't have any problems at all with comparatively puny scalars
such as URLs with CGI parameters.

HTH,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


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

Date: Mon, 24 Sep 2001 19:41:51 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Using URLs as hash keys
Message-Id: <slrn9qtvuv.8ai.mgjv@martien.heliotrope.home>

On Mon, 24 Sep 2001 17:00:13 +1000,
	aL <nobody@nowhere.com> wrote:
>> Should work. Hash keys are just strings.
> 
> Thanks for your help.
> 
> Does anyone know of any in-built limit to the size of keys?

I don't think you really need to worry about that :)

It's probably system dependent, and will most likely depend on the
largest number of bytes malloc can return. On most systems, this is
limited by the amount of memory your application has available.

A URL is very unlikely to be long enough to break that limit.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Hi, Dave here, what's the root
Commercial Dynamics Pty. Ltd.   | password?
NSW, Australia                  | 


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

Date: Mon, 24 Sep 2001 07:42:16 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: What good is the hyphen for named parameters?
Message-Id: <uootqtsbd6ibddn9mp76st2ff2bl5i269q@4ax.com>

I don't see the point for using hyphens for "named parameters" for
subroutines. Although it doesn't prevent bareword quoting on the left
side of a "=>", it doesn't appear to add anything else. So what are they
good for?

	use Data::Dumper;
	$_ = 64;
	print Dumper -chr => 33;
-->
	$VAR1 = '-chr';
	$VAR2 = 33;

	print Dumper -chr , 33
-->
	Argument "@" isn't numeric in negation (-) at test.pl line 4.
	$VAR1 = '0';
	$VAR2 = 33;

-- 
	Bart.


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

Date: Mon, 24 Sep 2001 08:41:19 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Why are tabs converted to spaces?
Message-Id: <g4stqtg4kvonb5ok6omeqj93028n76gq69@4ax.com>

Philip Wasson wrote:

>I am trying to separate fields in a guestbook by a tab but a space is written
>instead.  Here is the code clip:
>
>   open (GUEST,">$guestbookreal") || die "Can't Open $guestbookreal: $!\n";
>
>         print GUEST "$FORM{'firstname'}\t";
>         print GUEST "$FORM{'lastname'}\t";
>
>Any ideas?  Thanks for taking the time to look at this.

Jeezes.

First of all, you needn't put all of the stuff on separatae lines. You
can do

         print GUEST "$FORM{'firstname'}\t$FORM{'lastname'}\n";

or even

         local($\, $,) = ("\n", "\t");
         print GUEST @FORM{'firstname', 'lastname'};

which is how I like to write tab delimited files... but I'm digressing.

So you print "\t" and the file gets a " ". That's something I've never
heard before. Would binmode(GUEST) do any good? A binmoded file handle
should always literally get the bytes you print to it. No conversion
whatsoever allowed.

If that doesn't help, something else must be going on. I.e. you're not
doing what you think you're doing.

-- 
	Bart.


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

Date: Mon, 24 Sep 2001 08:10:28 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: win32 stat in directory with 4682 files
Message-Id: <qcqtqt07a42avavbpr2kgs68b6m739g7n2@4ax.com>

Benjamin Goldberg wrote:

>Are you using File::Find?  If so, remember that just before your wanted
>sub is called, a stat() was just done... so there will be a valid stat
>structure stored in the _ filehandle.  Call stat(_) instead of
>stat($File::Find::name), and you should get significantly faster
>results.

Nope. File::Find is just as slow. In fact, there isn't much difference
in code between the implementation of File::Find and what the OP does.

And once stat() is called on a file, the data is in a cache that perl
can reach, and next time you call stat() on it, it will be read from
that cache.

In fact, running the same program twice on the same directories will
likely give a speed-up of up to 50 times (!) the second time it runs.

-- 
	Bart.


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 1801
***************************************


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