[19009] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1204 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 27 11:05:34 2001

Date: Wed, 27 Jun 2001 08:05:11 -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: <993654311-v10-i1204@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 27 Jun 2001     Volume: 10 Number: 1204

Today's topics:
        Dijkstra / Graph / SSSP <john@princenaseem.com>
        Email-from-a-form script <nospam@notformail.com>
    Re: Email-from-a-form script <pne-news-20010627@newton.digitalspace.net>
    Re: Interacting prompts with perl <nospam@newsranger.com>
    Re: Interacting prompts with perl <nospam@newsranger.com>
    Re: New knowledgebase site - looking for authors, artic <pne-news-20010627@newton.digitalspace.net>
    Re: newbie directory question <tony_curtis32@yahoo.com>
        Parse::RecDescent --  Variable-sequence rules? <cjmackie@princeton.edu>
    Re: Parse::RecDescent --  Variable-sequence rules? (Randal L. Schwartz)
    Re: Problem reading large files (dumb question?) <cjmackie@princeton.edu>
    Re: Problem with Archive::Tar <djberge@uswest.com>
    Re: Problems with Crypt Modules (Irene Fung)
    Re: Range operator <mjcarman@home.com>
    Re: Scanning a file in CGI <wyzelli@yahoo.com>
    Re: Scanning a file in CGI (Anno Siegel)
    Re: Scanning a file in CGI <pne-news-20010627@newton.digitalspace.net>
    Re: Scanning a file in CGI (Anno Siegel)
    Re: Scanning a file in CGI <pne-news-20010627@newton.digitalspace.net>
    Re: Search Patterns (Tad McClellan)
    Re: Search Patterns (Bernard El-Hagin)
    Re: sorting a hash <jurgenex@hotmail.com>
    Re: sorting a hash <ren@tivoli.com>
    Re: Starting Browser Windows <Jenda@Krynicky.cz>
    Re: Starting Browser Windows <jurgenex@hotmail.com>
        truetype fonts in XEmacs <o.moser@mobilkom.at>
    Re: Unix filepath completion within perl? <george.stevens@baesystems.com>
    Re: Upgrading a File Lock (What do you think this is, a <flavell@mail.cern.ch>
    Re: Upgrading a File Lock (What do you think this is, a (Anno Siegel)
        XML::DOM error when there is a "&" in the data <sschmid@student.ethz.ch>
    Re: XML::DOM error when there is a "&" in the data <pne-news-20010627@newton.digitalspace.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 27 Jun 2001 15:59:43 +0100
From: "JohnShep" <john@princenaseem.com>
Subject: Dijkstra / Graph / SSSP
Message-Id: <iym_6.298$L41.9347@NewsReader>

I am trying to find connections between people using Graph::BFS using a name
as a vertex and an acquaintance as an edge. Can anyone enlighten me as to
what %param BFS uses and how to process the resultant search set. E.g. I
want the path Dave to John => Dave,Mark,Paul,John

#!/usr/bin/perl -w
use Graph::Directed;
use Graph::BFS;

$G = new Graph::Directed;

$G = $G->add_edge("dave","mark");
$G = $G->add_edge("mark","paul");
$G = $G->add_edge("paul","john");

# Should I use $G = $G->SSSP_Dijkstra(); here ?

$set = Graph::BFS->new($G,%param);


John





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

Date: Wed, 27 Jun 2001 15:53:00 +0200
From: "DetUudslukkelige" <nospam@notformail.com>
Subject: Email-from-a-form script
Message-Id: <9hco9u$4it$1@news.inet.tele.dk>

Dear grup


I have downloaded the SendMail module- and script from
http://www.tneoh.zoneit.com/perl/SendMail
as I want to email me the input from a form via SMTP (the server doen't have
'sendmail' installed)
But I can't find out where in the script to configure my smtp-server and my
email-adress. My web-server is _not_ the SMTP server itself, so I guess
certain "localhost" strings should be changed?

Anybody know about another Mail-from-a-form-via-SMTP script? Or perhaps
anybody could help me configure the script


Thanks in advance.

-Mathias




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

Date: Wed, 27 Jun 2001 16:03:22 +0200
From: Philip Newton <pne-news-20010627@newton.digitalspace.net>
Subject: Re: Email-from-a-form script
Message-Id: <3rpjjtsma2nhf4bee32h66q5u9t35fg2ac@4ax.com>

On Wed, 27 Jun 2001 15:53:00 +0200, "DetUudslukkelige"
<nospam@notformail.com> wrote:

> I have downloaded the SendMail module- and script from
> http://www.tneoh.zoneit.com/perl/SendMail
> as I want to email me the input from a form via SMTP (the server doen't have
> 'sendmail' installed)
> But I can't find out where in the script to configure my smtp-server and my
> email-adress.

If you want support for a specific script, you should best take the
issue up with the author; he will be the best qualified to comment. I
rather doubt that most of the readers of this group are familiar with
the script.

> My web-server is _not_ the SMTP server itself, so I guess certain
> "localhost" strings should be changed?

Maybe, maybe not. Hard to say without knowing the code.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Wed, 27 Jun 2001 14:49:05 GMT
From: Drew Myers <nospam@newsranger.com>
Subject: Re: Interacting prompts with perl
Message-Id: <Bnm_6.650$f4.7314@www.newsranger.com>

>open (TAPES,"|/opt/omni/bin/omnirpt -report used_media  -timeframe 24 24")
>open pipe to the program.
>Then
>
>print TAPES ".....";  
>feeds commands to it.

Ilya, that works great, thank you!  I've got another question though.  What if I
want to capture the output from each of the commands I issue?  For instance,
this doesn't work:

open (SILO,"|/opt/omni/lbin/uma -ioctl /dev/scsi/robot -barcode") || die "Can't
close SILO: $!\n";
print SILO "stat d\n";
my @silostat=<SILO>;

I'm thinking there's probably a simple way to do this that I'm over-looking.

Thanks again.




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

Date: Wed, 27 Jun 2001 14:52:12 GMT
From: Drew Myers <nospam@newsranger.com>
Subject: Re: Interacting prompts with perl
Message-Id: <wqm_6.655$f4.7282@www.newsranger.com>

>open (TAPES,"|/opt/omni/bin/omnirpt -report used_media  -timeframe 24 24")
>open pipe to the program.
>Then
>
>print TAPES ".....";  
>feeds commands to it.

Ilya, that works great, thank you!  I've got another question though.  What if I
want to capture the output from each of the commands I issue?  For instance,
this doesn't work:

open (SILO,"|/opt/omni/lbin/uma -ioctl /dev/scsi/robot -barcode") || die "Can't
close SILO: $!\n";
print SILO "stat d\n";
my @silostat=<SILO>;

I'm thinking there's probably a simple way to do this that I'm over-looking.

Thanks again.




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

Date: Wed, 27 Jun 2001 15:13:34 +0200
From: Philip Newton <pne-news-20010627@newton.digitalspace.net>
Subject: Re: New knowledgebase site - looking for authors, articles or tips about Perl
Message-Id: <iumjjtg1ndht4ci365d0qg5ha4jnm05qfb@4ax.com>

On Wed, 27 Jun 2001 04:50:50 -0700, KBaseonline.com
<info@kbaseonline.com> wrote:

> We are looking for articles, tips or tutorials on the Perl programming
> language.  

Good luck competing against all the other sites trying to offer similar
services. (And if it's free, I wonder how long you'll stay up, what with
the ad revenues tanking in the past couple of years.)

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: 27 Jun 2001 09:02:42 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: newbie directory question
Message-Id: <878zie58cd.fsf@limey.hpcc.uh.edu>

>> On Wed, 27 Jun 2001 05:02:47 -0400,
>> Jason Goodrow <"goodrow"@opencity. com> said:

> Can perl tell the difference between files read from a
> directory?  say opendir - readdir - do something if file
> is a hash ?

A hash is a data structure, not a file.  A file can
contain data which represents (serialises) a hash for one
or more programs (in one or more languages) though.

Could you tell us what you're actually trying to do (the
bigger picture)?  If you zero in on a perceived problem
then the "real" solution may not be apparent.

hth
t
-- 
Somebody light this monkey.  AAAAGGGHHHH!!  Bad monkey!


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

Date: Wed, 27 Jun 2001 10:04:07 -0400
From: "Christopher J. Mackie" <cjmackie@princeton.edu>
Subject: Parse::RecDescent --  Variable-sequence rules?
Message-Id: <9hcp4n$h1e$1@cnn.Princeton.EDU>

I've been through the pod, but there's no explicit discussion of this, and
while it seems like it should be possible, I need a hand figuring out how.
TIA to any P::RD gurus out there!  --Chris
-----------------------------
What's the best way to write a grammar which includes some (optional) rules
that may occur in any order?  Should I even be trying this in
Parse::RecDescent, or is there a better alternative?

I'm trying to parse texts of the following structure:

Head
    Tag1
    Tag2
    Tag3
    ...
    TagN
Body
    ...
Foot
    ...

Problem is, the 'TagX' rules are a bit unpredictable.  Not all of them occur
in every text, and the tag-order is not guaranteed (e.g., Tag4 may come
before Tag2, Tag3 may be missing, etc.).  Total number of tags per text is <
20, and all tags occur at most once in each text.  I need to produce a parse
tree containing the tagged content, suitable for conversion to a standard
format (probably XML).  Any thoughts?




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

Date: 27 Jun 2001 08:03:53 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Parse::RecDescent --  Variable-sequence rules?
Message-Id: <m11yo6q812.fsf@halfdome.holdit.com>

>>>>> "Christopher" == Christopher J Mackie <cjmackie@princeton.edu> writes:

Christopher> I'm trying to parse texts of the following structure:

Christopher> Head
Christopher>     Tag1
Christopher>     Tag2
Christopher>     Tag3
Christopher>     ...
Christopher>     TagN
Christopher> Body
Christopher>     ...
Christopher> Foot
Christopher>     ...

Christopher> Problem is, the 'TagX' rules are a bit unpredictable.
Christopher> Not all of them occur in every text, and the tag-order is
Christopher> not guaranteed (e.g., Tag4 may come before Tag2, Tag3 may
Christopher> be missing, etc.).  Total number of tags per text is <
Christopher> 20, and all tags occur at most once in each text.  I need
Christopher> to produce a parse tree containing the tagged content,
Christopher> suitable for conversion to a standard format (probably
Christopher> XML).  Any thoughts?

Something like this is typical:

    document: head body foot
    head: "Head" tag(s?) { do something with @{$item[2]} for tags }
    tag: tag1
    tag: tag2
    tag: tag3
    ...
    body: "Body" ...

Does that help?

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Wed, 27 Jun 2001 10:12:37 -0400
From: "Christopher J. Mackie" <cjmackie@princeton.edu>
Subject: Re: Problem reading large files (dumb question?)
Message-Id: <9hcpkm$h64$1@cnn.Princeton.EDU>

Richard, John, Mark, Benjamin;  Thanks to all of you for your suggestions.
I recompiled perl with max 64-bit support, and the script ran immediately.
Unfortunately, it was running at a rate that would have taken 388 days to
completion, but after some negotiation with the sysadmin, I got a little
more RAM allocated and did some performance tweaking, so now it's down to a
couple days, which is fine.

Y'all were lifesavers!  Tx again, --Chris

"Christopher J. Mackie" <cjmackie@princeton.edu> wrote in message
news:9h0abu$55t$1@cnn.Princeton.EDU...
> Apologies if this is a CompSci 101 question--I'm self-taught.
>
> I *really* need to read data out of a 14Gb binary file, convert it from
> double to float, and write it into another file.  The perl script I wrote
> works great on smaller files, but every time I try to read() or sysread()
> the big file, I get a core dump (segmentation fault).  ....




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

Date: Wed, 27 Jun 2001 08:13:27 -0500
From: "Mr. Sunray" <djberge@uswest.com>
Subject: Re: Problem with Archive::Tar
Message-Id: <3B39DBF7.C25C1319@uswest.com>

Bart Lateur wrote:

> Mr. Sunray wrote:
>
> >>    if($file =~ /^.*?\.zip$/i){
> >>       system("mv","$file","Archive"); # Move .zip files
> >>    }
>
> >Near as I could tell, this 'system' call above was the culprit, though
> >I'm not sure why.
>
> I think I get it. I think mv returns control to perl, before having
> finished moving the file. So you end up archiving a file that's being
> modified while creating the archive. That way, you get a corrupt
> archive.
> T
> Why are you using an external command for that? If your Archive is on
> the same file system as the original file, perl's "rename" will do just
> fine. Try something like
>
>         rename $file, "Archive/$file";
>
> if $file is a just a filename.
>
> If the file needsbeing moved to another file system, look into the
> Fill::Copy module. That contains a mv function, which falls back to
> rename() if it turns out that the destination is on the same disk as the
> source. You may even stay very close to your original syntax, and just
> do
>
>         mv $file,"Archive";
>
> --
>         Bart.

Thanks for the info!

Mr. Sunray



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

Date: Wed, 27 Jun 2001 13:39:13 GMT
From: iwf@po.cwru.edu (Irene Fung)
Subject: Re: Problems with Crypt Modules
Message-Id: <3b39e12d.1358000521@news.cwru.edu>

On Tue, 26 Jun 2001 21:00:33 GMT, Dan Wilga
<dwilga-MUNGE@mtholyoke.edu> wrote:

>In article <3b38e156.1292506325@news.cwru.edu>, iwf@po.cwru.edu (Irene Fung) 
>wrote:
>
>> I'm running Perl 5.6.1 under BSD/OS 4.2.  I've been trying to use the
>> Crypt::Blowfish module to encrypt a file and then decrypt a file.  At
>> the 224 byte length, the decryption fails.  It will decrypt correctly
>> all the text up to that length and then show gibberish after that.
>
>Most of the Crypt:: modules work on a fixed-size buffer. To work on an 
>arbitrary number of bytes, use Crypt::CBC in conjunction with ::Blowfish.
>

I've got Crypt::CBC installed also and the script breaks the file into
8 byte blocks for encryption and decryption.  

Irene


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

Date: Wed, 27 Jun 2001 08:18:30 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Range operator
Message-Id: <3B39DD26.90D014D1@home.com>

Ronald Fischer wrote:
> 
> The following program is supposed to print a part of standard 
> input, together with its line numbers.
>
> while(<STDIN>)
> {
>         print "$.: $_" if ($from .. $to);
> }
> 
> Strangely, it always prints *all* of standard input, though
> ($from .. $to) is used in a scalar context, and $. has the
> correct value. Can someone explain me, what I did wrong?

Scalar '..' only does an implicit comparison against $. if at least one
of it's operands is a constant. (See the perlop manpage.) Since $from
and $to are both variables, this doesn't happen.

> Of course I could manually check ($. >= $from) && ($. <= $to), 
> but I thought the range operator would be useful here too.

You can use it, you just have to explicitly state the conditional if you
want variable boundaries:

print "$.: $_" if ($. == $from .. $. == $to);

-mjc


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

Date: Wed, 27 Jun 2001 22:49:42 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Scanning a file in CGI
Message-Id: <USk_6.9$PG1.1219@vic.nntp.telstra.net>

"Brian Pontz" <pontz@NO_SPAMchannel1.com> wrote in message
news:3b39a94d.392854789@news.ne.mediaone.net...
> >    while(<I>)           #<== this part does not work
> >     {
> >      ($ref,$area,$doctitle,$docnr,$doclink,$catalog,$keyw)= split(/|/);
>
> Why split every line? You should only split the ones you want
>
> while(<I>) {
> chomp;
> if(/^\d+|PARM|/) {
> ($ref,$area,$doctitle,$docnr,$doclink,$catalog,$keyw)=
> split(/|/);

That split is not doing anything.  See Gnari's reply to understand why.
*hint 'nothing or nothing' which is actually a special case of // which does
something special...

Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';




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

Date: 27 Jun 2001 13:17:39 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Scanning a file in CGI
Message-Id: <9hcmdj$6j5$2@mamenchi.zrz.TU-Berlin.DE>

According to Wyzelli <wyzelli@yahoo.com>:
> "Brian Pontz" <pontz@NO_SPAMchannel1.com> wrote in message

[...]

> > split(/|/);
> 
> That split is not doing anything.  See Gnari's reply to understand why.
> *hint 'nothing or nothing' which is actually a special case of // which does
> something special...

Do you mean that it uses the pattern that last matched successfully?
/|/ is not a special case of *that*.

Anno


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

Date: Wed, 27 Jun 2001 15:24:48 +0200
From: Philip Newton <pne-news-20010627@newton.digitalspace.net>
Subject: Re: Scanning a file in CGI
Message-Id: <6knjjtgg8faeutdftakdj3alj5ih6oj3ta@4ax.com>

On 27 Jun 2001 13:17:39 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:

> According to Wyzelli <wyzelli@yahoo.com>:
> > "Brian Pontz" <pontz@NO_SPAMchannel1.com> wrote in message
> 
> [...]
> 
> > > split(/|/);
> > 
> > That split is not doing anything.  See Gnari's reply to understand why.
> > *hint 'nothing or nothing' which is actually a special case of // which does
> > something special...
> 
> Do you mean that it uses the pattern that last matched successfully?

In split(), // does not mean "the pattern that last matched
successfully".

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: 27 Jun 2001 14:21:20 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Scanning a file in CGI
Message-Id: <9hcq50$b3h$2@mamenchi.zrz.TU-Berlin.DE>

According to Philip Newton  <nospam.newton@gmx.li>:
> On 27 Jun 2001 13:17:39 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
> Siegel) wrote:
> 
> > According to Wyzelli <wyzelli@yahoo.com>:
> > > "Brian Pontz" <pontz@NO_SPAMchannel1.com> wrote in message
> > 
> > [...]
> > 
> > > > split(/|/);
> > > 
> > > That split is not doing anything.  See Gnari's reply to understand why.
> > > *hint 'nothing or nothing' which is actually a special case of // which does
> > > something special...
> > 
> > Do you mean that it uses the pattern that last matched successfully?
> 
> In split(), // does not mean "the pattern that last matched
> successfully".

Oh, right.  Thanks for the correction.

Just to be difficult, how is its behavior special then?[1]  It splits
between any two characters, just like other patterns that (first)
match an empty sting.

Anno

[1] No, you didn't claim it is special.


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

Date: Wed, 27 Jun 2001 16:23:01 +0200
From: Philip Newton <pne-news-20010627@newton.digitalspace.net>
Subject: Re: Scanning a file in CGI
Message-Id: <l0rjjtc799sh8da5p6sh5paroeurg8ojvs@4ax.com>

On 27 Jun 2001 14:21:20 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:

> Just to be difficult, how is its behavior special then?[1]  It splits
> between any two characters, just like other patterns that (first)
> match an empty sting.

I suppose in the same way that any pattern matching the null string is a
little special (and // is extra special for not behaving the same way in
a split and in a pattern match or substitution).

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Wed, 27 Jun 2001 08:38:58 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Search Patterns
Message-Id: <slrn9jjkv2.i95.tadmc@tadmc26.august.net>

Blnukem <blnukem@hotmail.com> wrote:
>
>I'm trying to replace a string  of "filename **.dat" to "filename.txt" I can
>get it to replace "filename **.dat" to ""filename *.txt"  with this:

>but I cant figure out how to replace two of the * in the string
>
>$CATAGORY_DATA {$key} =~ s/ \*\*\.dat/.txt/g;
>
>This don't work 


Yes it do:

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

$_ = 'filename **.dat';
print "$_\n";

s/ \*\*\.dat/.txt/g;   # I like this better:  s/\Q **.dat/.txt/g;
print "$_\n";
-----------------------


>please help


Can't help if we can't duplicate the problem.

Got a short and complete program that "don't work"?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 27 Jun 2001 13:35:50 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Search Patterns
Message-Id: <slrn9jjnup.112.bernard.el-hagin@gdndev25.lido-tech>

On Wed, 27 Jun 2001 12:55:15 GMT, Blnukem <blnukem@hotmail.com> wrote:
>Hi All
>
>I'm trying to replace a string  of "filename **.dat" to "filename.txt" I can
>get it to replace "filename **.dat" to ""filename *.txt"  with this:
>
>$CATAGORY_DATA {$key} =~ s/ \*\.dat/.txt/g;

This looks for a space followed by an asterisk followed by .dat and
changes that to .txt. So if your input string is "filename **.dat"
this regex won't match and your statement that it changes "filename **.dat"
into "filename *.txt" is untrue.

>but I cant figure out how to replace two of the * in the string
>
>$CATAGORY_DATA {$key} =~ s/ \*\*\.dat/.txt/g;
>
>This don't work please help

This works for me:

$_ = 'fielname **.dat';

s/ \*\*\.dat/.txt/;
print;

OUTPUT: filename.txt

Cheers,
Bernard
--
perl -l54e's yyw q q tvmrx "h\ywx ersxliv zivp legoiv"qiy;y #a-zA-Z#d-gu-z#
chefghijklmnopqrstuvwxyzcJab-def-uPwxyzc;s j j s u u s t t s r r s
ppevalpereeteueje'


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

Date: Wed, 27 Jun 2001 07:43:26 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: sorting a hash
Message-Id: <3b39f10f@news.microsoft.com>

"tez" <troyr@vicnet.net.au> wrote in message
news:sbc_6.12345$qJ4.503668@ozemail.com.au...
>             I'm sure ppl have discussed this one here but i can't remember
> the result of the discussion...

Then you may want to check google.

> I'm trying to sort by either 'name' or 'hits'
[...]
> is this possible to achieve via the sort command? ....checked perldoc -f
> sort but didn't get far

Understandable. 'sort' is for lists only. You should have tried perldoc -q
sort, too:
      How do I sort a hash (optionally by value instead of key)?
                Internally, hashes are stored in a way that prevents you
from
                imposing an order on key-value pairs. [...]

Reading the rest of the article is left as an exercise.

> ie...so would the index #'s 1,2,3 be rearranged or the values within those
> indexes be rearranged

From your example it is not quite clear what you are trying to achive. But
as the FAQ states: you cannot sort a hash. You must use a different data
structure, e.g. arrays or tie or DB or ...

jue




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

Date: 27 Jun 2001 09:21:39 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: sorting a hash
Message-Id: <m3r8w6vw98.fsf@dhcp9-173.support.tivoli.com>

On Wed, 27 Jun 2001, troyr@vicnet.net.au wrote:

[snip]
> is this possible to achieve via the sort command? ....checked
> perldoc -f sort but didn't get far
[snip]

"perldoc -q sort" might get you further... :)

-- 
Ren Maddox
ren@tivoli.com


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

Date: Wed, 27 Jun 2001 14:35:58 GMT
From: Jenda Krynicky <Jenda@Krynicky.cz>
Subject: Re: Starting Browser Windows
Message-Id: <1103_993652558@JENDA>

On Wed, 27 Jun 2001 14:34:56 +0200, Philip Newton <pne-news-20010627@newton.digitalspace.net> wrote:
> On 27 Jun 2001 04:45:42 -0700, ggrothendieck@volcanomail.com (Grod)
> wrote:
> 
> > I would like to write a client side Perl program 
> > on Windows 2000 which starts up several Internet
> > Explorer browser windows with URLs that I calculate 
> > internally in my program.  
> > 
> > How can one do this in Perl?
> 
> 1) If Internet Explorer is your default browser, you might be able to
> use something like  system("start $url")  to start it up
> 
> 2) Or you could remote-control MSIE with DDE or OLE automation. Consult
> the documentation for MSIE to find out whether that's possible. (I think
> at least OLE automation is possible, and Perl can do that with
> Win32::OLE, but I don't know the syntax that MSIE wants.)
> 
> Cheers,
> Philip

Actualy
	system('start','iexplore.exe','http://localhost');
should be all you need.

Jenda




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

Date: Wed, 27 Jun 2001 07:44:46 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Starting Browser Windows
Message-Id: <3b39f15e$1@news.microsoft.com>

"Grod" <ggrothendieck@volcanomail.com> wrote in message
news:ffd662ea.0106270345.4c36d3db@posting.google.com...
> I would like to write a client side Perl program
> on Windows 2000 which starts up several Internet
> Explorer browser windows with URLs that I calculate
> internally in my program.

Are you looking for 'system'? Details see perldoc -f system.

jue




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

Date: Wed, 27 Jun 2001 16:22:27 +0200
From: Oliver Moser <o.moser@mobilkom.at>
Subject: truetype fonts in XEmacs
Message-Id: <imqjjtc2c0fm0odhajp98322e09pclk421@4ax.com>

Dear NG,

	I know, the question isn't Perl specific, but I thought
someone of you gurus might know how to use truetype fonts in XEmacs.

There are menu entries for my ttf's in the font menu, but the are grey
so I cannot select one of them. I also tried switching of the "ignore
scaled fonts" options in the options->customize->Emacs->Env->X->Font
Menu , but that didn't help.

thanks in advance

regards,

	Oliver
 ------------------------------
Oliver Moser
mobilkom austria AG & Co. KG
IT://mob.app
Mobil: +43-664-331-2544
mailto:o.moser@mobilkom.at


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

Date: Wed, 27 Jun 2001 15:21:36 +0100
From: George Stevens <george.stevens@baesystems.com>
Subject: Re: Unix filepath completion within perl?
Message-Id: <3B39EBF0.9D43A197@baesystems.com>

Ok, hopefully someone is still reading this thread!

I've sort of got some file completion going using the following program:

use Term::Complete;

my @filenames;
my $file;
my $dir;

opendir(FILELIST, '.');
while( defined ($file = readdir( FILELIST)))
{
   push(@filenames, "$dir/$file");
};
closedir( FILELIST);

my $input = Complete('enter file name > ', @filenames);


This seems to work ok for /firstlevel, when you run it from the root.  However
if you have /firstlevel/secondlevel, it can't find secondlevel, because
@filenames was only filled the once at root level.
So is there a way that I can feedback that the user has typed /firstlevel/s
and now seeks a new list of @filenames?

I hope that I've explained that ok.

George



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

Date: Wed, 27 Jun 2001 15:00:03 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Upgrading a File Lock (What do you think this is, a Holiday Inn?)
Message-Id: <Pine.LNX.4.30.0106271452020.12055-100000@lxplus003.cern.ch>

On 27 Jun 2001, Anno Siegel wrote:

> When I tried this (on one platform) I found that the semantics of
> "lock upgrading" is actually to release the current lock (if present)
> and then to apply for another.
 ...
> The drawback is that the code *looks* like it never gives up the
> lock, but actually does.  So, if you "upgrade" a shared lock to an
> exclusive one, there is no guarantee the file will be unchanged.

indeed...

> > There is, of course, a possible deadlock condition if two processes both
> > want to upgrade their read locks at the same time.  As others have
> > pointed out you can avoid this with an auxillary semaphore.
>
> The deadlock doesn't happen when the "upgrade" implicitly releases
> the prior lock.

OK, but if that happens then, as you already commented, the procedure
fails to fulfil its intended purpose.

I haven't studied this in nearly as much practical detail, but from a
theoretical view and based on the reported results from the earlier
thread, there does seem to be a genuine problem.

I think I'd go with the semaphore file idea, but one has to do the
logic quite carefully.

The procedure is simpler if you have only a single updating (i.e read,
compute, then write) process even though there are potentially many
consumer (read-only) processes.



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

Date: 27 Jun 2001 14:08:38 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Upgrading a File Lock (What do you think this is, a Holiday Inn?)
Message-Id: <9hcpd6$b3h$1@mamenchi.zrz.TU-Berlin.DE>

According to Alan J. Flavell <flavell@mail.cern.ch>:
> On 27 Jun 2001, Anno Siegel wrote:
> 
> > When I tried this (on one platform) I found that the semantics of
> > "lock upgrading" is actually to release the current lock (if present)
> > and then to apply for another.
> ...
> > The drawback is that the code *looks* like it never gives up the
> > lock, but actually does.  So, if you "upgrade" a shared lock to an
> > exclusive one, there is no guarantee the file will be unchanged.
> 
> indeed...
> 
> > > There is, of course, a possible deadlock condition if two processes both
> > > want to upgrade their read locks at the same time.  As others have
> > > pointed out you can avoid this with an auxillary semaphore.
> >
> > The deadlock doesn't happen when the "upgrade" implicitly releases
> > the prior lock.
> 
> OK, but if that happens then, as you already commented, the procedure
> fails to fulfil its intended purpose.
> 
> I haven't studied this in nearly as much practical detail, but from a
> theoretical view and based on the reported results from the earlier
> thread, there does seem to be a genuine problem.
 
The concept of upgrading a shared lock to an exclusive one (while
guaranteeing the file isn't changed in between) will necessarily
open an opportunity for deadlock.  You simply can't guarantee the
behavior to two processes at the same time.

> I think I'd go with the semaphore file idea, but one has to do the
> logic quite carefully.

 ...or you have the mythical "protect" lock that has been mentioned,
which seems to be meant for exactly this case.  It would behave
like a shared lock, but only one of them is issued at any time.
This would be used during the read-only phase of a process, and it
*can* be upgraded to exclusive because no other process has one.

A semaphore can probably be used to enforce a similar behavior.

> The procedure is simpler if you have only a single updating (i.e read,
> compute, then write) process even though there are potentially many
> consumer (read-only) processes.

It seems to me (and it is easy to go wrong here) that a singular
update process wouldn't even have to bother with a read lock.
It reads the file (no-one else is going to change it), and simply
gets a write lock for writing.  Other readers, of course, still
must lock the file appropriately.

Anno


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

Date: Wed, 27 Jun 2001 16:30:00 +0200
From: "Silvan Schmid" <sschmid@student.ethz.ch>
Subject: XML::DOM error when there is a "&" in the data
Message-Id: <3b39ee3a$1@pfaff.ethz.ch>

Hi,

I am parsing a XML-string with the XML::DOM module. Now my data includes
some "&" (example: &pi;).
The parser breaks. In the error log file it says, that an undefined enitity
was found. I need to use this "&"-symbols.
How can I go on using them and the parser will accept them?

Gruss
Silvan

________________________________
Silvan Schmid
Dufourstrasse 97
8008 Zürich

Tel: 01 381 7095
CellPhone: 076 316 86 76

http://n.ethz.ch/student/sschmid
________________________________




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

Date: Wed, 27 Jun 2001 16:48:25 +0200
From: Philip Newton <pne-news-20010627@newton.digitalspace.net>
Subject: Re: XML::DOM error when there is a "&" in the data
Message-Id: <7hsjjt4v7l2te5egd0vbgcif71stlagbg6@4ax.com>

On Wed, 27 Jun 2001 16:30:00 +0200, "Silvan Schmid"
<sschmid@student.ethz.ch> wrote:

> How can I go on using them and the parser will accept them?

Emit entity definitions before using them?

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

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


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