[26884] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8881 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 24 14:05:31 2006

Date: Tue, 24 Jan 2006 11:05:04 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 24 Jan 2006     Volume: 10 Number: 8881

Today's topics:
    Re: cpp-style include for perl? <tadmc@augustmail.com>
    Re: Graph.0.69 Module---how to get a DAG from graph wit <seanatpurdue@hotmail.com>
    Re: make dynamic sized iframe work?  or alt ideas? <scobloke2@infotop.co.uk>
        Window control program help needed  Jan. 24, 2006 <edgrsprj@ix.netcom.com>
    Re: Window control program help needed  Jan. 24, 2006 <1usa@llenroc.ude.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 24 Jan 2006 09:11:20 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: cpp-style include for perl?
Message-Id: <slrndtcgso.2v0.tadmc@magna.augustmail.com>

Joe Smith <joe@inwap.com> wrote:
> Mike Ballard wrote:
> 
>>     @filelist = `/bin/ls -1 abs*`;
> 
> That's not the right way to do it.


What is wrong with it?


Or did you instead mean to say that there is a _better_ way?

(which I would agree with.)


> 	@filelist = glob 'abs*';


The array contents will not be the same as with the original code.


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


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

Date: Tue, 24 Jan 2006 11:32:12 -0500
From: Sean <seanatpurdue@hotmail.com>
Subject: Re: Graph.0.69 Module---how to get a DAG from graph with cycles
Message-Id: <dr5kqc$k3g$1@mailhub227.itcs.purdue.edu>

Hi Jim,
Thanks so much for the prompt help. It is exactly what I wanted, and 
I'll port it to my program.

Best regards,

Jim Gibson wrote:
> In article <dr3c1l$gib$1@mailhub227.itcs.purdue.edu>, Sean
> <seanatpurdue@hotmail.com> wrote:
> 
> 
>>Here I use an example to illustrate the problem I met when using Graph 
>>Theory Module: I have a directed graph looks like the following (see the 
>>figure).
>>Edges in the original directed graph:
>>[main] -> [foo]; [main] -> [bar];
>>[foo]   -> [trouble];
>>[trouble] -> [foo];
>>
>>I want to find all the cycles in the graph. whenever I find a cycle, I 
>>want to break it by deleting an edge starting from a vertex farthest 
>>away from node [main] to get the following graph ---in this case, 
>>deleting [trouble] -> [foo] because [trouble] is the farthest node in 
>>this cycle.
>>So, edges after the desired manipulation are:
>>[main] -> [foo]; [main] -> [bar];
>>[foo]   -> [trouble];
>>-----------------------fiugre of original graph------------
>>     [main]
>>      /    \
>>   [foo]    [bar]
>>    /  /
>>   /  /
>>  [trouble]
>>-----------------------end of the figure-------------------
>>
>>I tried to use @v = $g->connected_component_by_index($i), but it seems
>>to return single nodes (which is deemed as strongly connected component
>>itself), which is not what I want.
>>$g->find_a_cycle does not work either, because it returns same cycle no
>>matter how many times you call it.
>>
>>I am newbie in perl. Can someone give me a suggestion how to utilize
>>the existing APIs in Graph.0.69 to achieve what I want?
>>Here is what I experimented a bit(which failed), and it may give a 
>>better background of my question.
>>
>>====================================================================
>>#mycode.pl
>>       6
>>       7 use Graph;
>>       8 my $gcall = Graph->new;
>>      11
>>      12 while (<>) {
>>      13     chomp;
>>      14     if (/^(.*)\t->\t(.*)\t=>\w*\t->(\d*)/) {
>>      15         $gcall->add_edge($1, $2);
>>      16         print $1, " to ", $2, " with ", $3, "\n";
>>      17         #print $2, "\n";
>>      18     }
>>      19
>>      20 }
>>      21########at this point, the graph has been built#############
>>      46
>>      47 foreach (1..5) {
>>      48   print "SCC $_:",
>>             $gcall->strongly_connected_component_by_index($_), "\n\n";
>>      49   print "cycle $_:",
>>             $gcall->find_a_cycle;
>>      50}
>>        ######### my tries to try to report cycles, FAILED  ####
>>
>>========================================================================
> 
> 
> You have posted 19 lines of an at-least 50-line program, so your posted
> program is not complete. Also, you do not show your data. Here is a way
> to create a graph equivalent to your sample graph without reading
> external data:
> 
> my $gcall = my $g = Graph->new( edges => 
>   [ ['a','b'], ['a','c'], ['b','d'], ['d','b']] );
> 
> Disclaimer: I don't know much about graphs, and I don't know about all
> the graph terminology used by the Graph module. In particular, I don't
> know what "connected" (strongly or weakly) means, so I don't know how
> that concept might be pertinent to your problem.
> 
> It is true that Graph::find_a_cycle() will find a random cycle if one
> exists in your graph, and will only return one. However, if you then
> break that cycle by removing an edge, then you can go on to finding and
> breaking the next one.
> 
> I am not sure how to find the vertex "farthest from node [main]" in
> cases more complex than your example. Here is a sample program that
> uses Graph::APSP_Floyd_Warshall() to find the "all pairs shortest
> paths" and Graph::path_length() to find the shortest path length from
> the root of the graph to any node. If these do not give the results you
> are looking for, then you will have to substitute some other method for
> picking which edge from a cycle of vertices to delete. The program adds
> a 3-vertex cycle to your original sample:
> 
> #!/usr/local/bin/perl
> use strict;
> use warnings;
> use Graph;
> 
> my $g = Graph->new(
>   edges => 
>     [ 
>       ['a','b'],
>       ['a','c'],
>       ['b','d'],
>       ['d','b'],
>       ['c','e'],
>       ['e','f'],
>       ['f','c'],
>     ]
> );
> 
> print "Graph: ", $g->stringify(), "\n";
> my @v = sort $g->vertices();
> print "Vertices: @v\n";
> 
> # find and remove all cycles
> while( my @cyc = $g->find_a_cycle() ) {
>   print "\nFound cycle: @cyc\n";
>   my $apsp = $g->APSP_Floyd_Warshall();
>   my %dist = map { $_ => $apsp->path_length('a',$_) } @cyc;
>   my $far = (sort { $dist{$a} <=> $dist{$b} } keys %dist )[-1];
>   print "Farthest vertex is $far\n";
>   CYC: for my $v ( @cyc ) {
>     next if $v eq $far;
>     next unless $g->has_edge($far,$v);
>     print "Remove edge (${far}->$v)\n";
>     $g->delete_edge($far,$v);
>     print "Graph is now: ", $g->stringify(), "\n";
>     last CYC;
>   }
> }
> ... which gives as output:
> 
> Graph: a-b,a-c,b-d,c-e,d-b,e-f,f-c
> Vertices: a b c d e f
> 
> Found cycle: b d
> Farthest vertex is d
> Remove edge (d->b)
> Graph is now: a-b,a-c,b-d,c-e,e-f,f-c
> 
> Found cycle: e f c
> Farthest vertex is f
> Remove edge (f->c)
> Graph is now: a-b,a-c,b-d,c-e,e-f
> 
> __END__
> 
> Note: this program can be made more efficient, but you should only
> worry about that if your graph is very large.
> 
>  Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
>     ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------        
>                 http://www.usenet.com


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

Date: Tue, 24 Jan 2006 11:07:59 +0000 (UTC)
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: make dynamic sized iframe work?  or alt ideas?
Message-Id: <dr51qc$205$2@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com>

Eric Peterson wrote:
> I'm just an occasional, light-weight programmer/web page builder... IOW: 
>  I don't really know what I'm doing.

Your problem is not to do with Java, Perl or PHP so you crossposted this 
to the wrong newsgroups.

Your problem is in working out what HTML & (possibly) Javascript you 
want your program to emit. Try an HTML oriented newsgroup. One in the 
comp.infosystems.www hierarchy may be appropriate.

> 
> I'm working on a photo gallery page with a rough format of:
>    header and menu
>        content
>        footer
> Where the content is dynamic showing the home page, or one of a couple 
> informational text pages, or a photo gallery.  For the gallery I'd like 
> to have thumbnails displayed in a horizontal strip (filmstrip style) 
> with a scroll bar to run through them.  I'd like clients to be able to 
> click on a picture from the filmstrip to view a larger version.  That is 
> where my problem begins.
> 
> So far I've used an iframe to view the content (the only way I could 
> find to get a horizontal scroll bar for content alone... no scrolling of 
> header/footer).  

You might be able to do this in CSS

> For the thumbnail views in the filmstrip, an iframe 
> height of about 400 pixels works great, but that is too short for 
> showing a larger version of the photo.  But since the client clicks on 
> the photo, within the iframe, I can't seem to change the height of the 
> frame, which is within the parent's <iframe> tag.
> 
> I know nothing about java, but it is probably my best hope??? 

If you know nothing about it, it is unlikely to be your best hope. You 
may be confusing Java with Javascript (two entirely unrelated languages 
IMO).

> A way to 
> force an update of the parent page from a link/click within the child page?
> 

There are dozens of different ways to accomplish this. Since you seem to 
be new to this I suggest you start off with something simple: Use SSI to 
include common header, menu and footer elements. Generate the thumbnail 
pages as static pages from any language you know. I.e. generate them 
whenever the collection of images is added to, then publish the static 
HTML. The individual thumbnails would just link to the bigger pics (e.g. 
<a href="photo_412.html"><img src="thumb_412.jpg" ... ></a>)

Once you have this working move on to dynamically generated pages using 
ASP or PHP. Then to clever interactive stuff using AJAX or whatever.

If it all seems too much, look for a canned solution (free or 
commercial) there must be lots for photo albums.

> Or maybe I could force an update of the parent page with any click 
> somewhere within the iframe? (yet still have the link work for the 
> content in the iframe)
> 
> Other ideas?  Maybe even dump the iframe idea entirely (but then how do 
> I horizontally scroll a portion of the page?
> 
> Thanks!  Specific coding suggestions are more than welcome, since I'm no 
> expert.

Followups set to comp.infosystems.www.authoring.html


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

Date: Tue, 24 Jan 2006 17:29:56 GMT
From: "edgrsprj" <edgrsprj@ix.netcom.com>
Subject: Window control program help needed  Jan. 24, 2006
Message-Id: <outBf.12211$ZA2.6220@newsread1.news.atl.earthlink.net>

       If possible I would like to get Perl to do two things.  The first is
the most important.  The second would be nice, but is not essential.  Not
being a Perl expert I will need exact instructions for what Web site to
visit, and how to download, install, and use the necessary modules.

       If you know how to do either or both of these things then it would be
appreciated if you contacted me by e-mail or posted the information here.

       I am running Windows XP on a regular PC and used
ActivePerl-5.8.3.809-MSWin32-x86.msi to install Perl.  I can upgrade to a
newer version of Perl if necessary.

1.  I would like Perl to send characters etc. to the Windows operating
system as if the instructions were being entered from the keyboard.

       One reason this ability is important is because I have to
repetitively run certain programs which will accept only keyboard entry
information.  And I want Perl to feed them that information.  I am presently
doing that with a keyboard control program which was originally developed
for Windows 3.1 I believe.  It is extremely slow and has only limited
computational and string processing abilities.

2.  If possible I would also like to run Windows so that when a notepad.exe
window is active for example and I enter a character on the keyboard, a Perl
program which is running but is not the visible window will actually read
that character instead of having it sent to the notepad.exe text file.

       One reason for wanting to do that is to have Perl send a group of
characters such as a specific text string to the notepad.exe text file
instead of the character which was typed on the keyboard.





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

Date: Tue, 24 Jan 2006 17:56:01 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Window control program help needed  Jan. 24, 2006
Message-Id: <Xns975583A43D442asu1cornelledu@127.0.0.1>

"edgrsprj" <edgrsprj@ix.netcom.com> wrote in
news:outBf.12211$ZA2.6220@newsread1.news.atl.earthlink.net: 
 
> 1.  I would like Perl to send characters etc. to the Windows operating
> system as if the instructions were being entered from the keyboard.

http://search.cpan.org/search?query=sendkeys

> notepad.exe text file. 

???

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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