[22736] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4957 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 8 09:05:57 2003

Date: Thu, 8 May 2003 06: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)

Perl-Users Digest           Thu, 8 May 2003     Volume: 10 Number: 4957

Today's topics:
    Re: @Array - making it null <tassilo.parseval@rwth-aachen.de>
    Re: @Array - making it null <bart.lateur@pandora.be>
    Re: Can't write a LOG file, please help <mbudash@sonic.net>
    Re: Design Opinions - Dealing with Constants <ubl@schaffhausen.de>
        Embedding perl on a flash chip <cfowler@outpostsentinel.com>
    Re: Help: Need nifty idea for efficiently linking objec (Anno Siegel)
    Re: Help: Need nifty idea for efficiently linking objec <g4rry_short@zw4llet.com>
        How can I pack an IP address into four binary bytes ? <wallabyedward@hunterlink.net.au>
    Re: How can I pack an IP address into four binary bytes (Anno Siegel)
    Re: How do you create a biniary file in Perl. <nmihai_2000@yahoo.com>
    Re: How do you create a biniary file in Perl. <nmihai_2000@yahoo.com>
    Re: How do you create a biniary file in Perl. <nmihai_2000@yahoo.com>
    Re: How do you create a biniary file in Perl. <bart.lateur@pandora.be>
        Ina a binary file is a space padded text file converted <wallabyedward@hunterlink.net.au>
        No ouput from Net::SSH:Win32Perl / Net::SSH::Perl (Anand Ramamurthy)
    Re: OT: Alternative to Xwin? <cfowler@outpostsentinel.com>
    Re: Perl code to dump palm datebook? (Helgi Briem)
    Re: perl compiler for win32 platform? <simon.andrews@bbsrc.ac.uk>
    Re: Perl Directories (Helgi Briem)
    Re: print <<"ending_print_tag"; <cingram@pjocsNOSPAMORHAM.demon.co.uk>
    Re: print <<"ending_print_tag"; <me@webmasterdave.co.uk>
    Re: Question about File test operators (Villy Kruse)
        Sorting book list <gopalan@cs.sc.edu>
    Re: Sorting book list <mbudash@sonic.net>
    Re: Sorting book list (Tad McClellan)
    Re: web page contents into a perl script <nospam@spamfreeland.com>
    Re: web page contents into a perl script <ubl@schaffhausen.de>
    Re: web page contents into a perl script (stew dean)
    Re: web page contents into a perl script (Helgi Briem)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 8 May 2003 05:44:50 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: @Array - making it null
Message-Id: <b9cqsi$508$1@nets3.rz.RWTH-Aachen.DE>

Also sprach TruthXayer:

> Brian McCauley wrote:
>> 
>> TruthXayer <TruthXayer@yahoo.com> writes:

>> > I normally use it with printf. Is there a better way or
>> > undef is OK here?
>> >
>> >       printf ("%30s%5s%30s", $var1,undef,$var2);
>> 
>> A better way to represent a null string would be ''.  Doesn't thow
>> warnings either!
> 
> The printf doesn't throw warning either! What warnings are
> you talking about
> or am I missing something?

Yes, you are missing warnings or the -w switch:

ethan@ethan:~$ perl -w
printf ("%30s%5s%30s", "foo", undef, "bar");
__END__
Use of uninitialized value in printf at - line 1.
                           foo                                bar

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Thu, 08 May 2003 07:07:56 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: @Array - making it null
Message-Id: <hh0kbvsrkbpcldnr8pgt6lderqf2knvt85@4ax.com>

Helgi Briem wrote:

>my ($name,$length,$position,$quality) = split;
>
>undef $length;
>undef $quality;
>print "name $position";
>
>Mainly to emphasise to later maintainers exactly
>what is contained in $length and $quality if they ever
>need those.  The undefs avoid "variable used only
>once" warnings.

That is not necessary. That kind of warning only occurs for globals, not
for lexicals.

-- 
	Bart.


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

Date: Thu, 08 May 2003 05:24:35 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Can't write a LOG file, please help
Message-Id: <mbudash-B0B085.22243607052003@typhoon.sonic.net>

In article <61f4ab48.0305072002.768f86a4@posting.google.com>,
 gino_vives@yahoo.com (Gino Vives) wrote:

> > the fact that you print to LOG, but the text appears on your screen 
> > indicates that your LOG filehandle wasn't opened properly.
> 
> If I don't print to LOG I get the messege on my screen...
> I mean, if all my print lines are like:
> 
> print "What ever text I want\n";
> 
> When I run:
> 
> <-  TEXT ON THE SCREEN  ->
> 
> gino@mycomuter~: ./myprograme
> What ever text I want
> 
> 
> <- End of screen  ->
> 
> Then if I run:
> 
> <-  TEXT ON THE SCREEN  ->
> 
> gino@mycomuter~: ./myprograme >> logfile  (or > logfile)
> 
> <- End of screen  ->
> 
> 
> I get nothing in logfile.... that's the problem...
> Now, if I change the code and use //open (LOG , ">> logfile)// and
> //print LOG "the text"// the logfile still empty... :'(
> 
> Please help...

let's see some actual code, and be sure to use this type of open:

open (LOG, ">>logfile") or die ("Can't open logfile for appending: $!");

if the open's the problem, you'll be told why...

hth-

-- 
Michael Budash


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

Date: Thu, 08 May 2003 11:11:33 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Design Opinions - Dealing with Constants
Message-Id: <b9da53$8db$1@news.dtag.de>

Eric Schwartz wrote:
> TruthXayer <TruthXayer@yahoo.com> writes:
> 
>>Here's yet another perlish way to do it....
> 
> 
> Not quite.  The perlish way to do it is:

this might be perlish:

use Vars::From "config.pl";

use Vars::From would then evaluate config.pl in a unique namespace and 
import all symbols to the current one.

malte



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

Date: Thu, 08 May 2003 08:54:59 -0400
From: Christopher Fowler <cfowler@outpostsentinel.com>
Subject: Embedding perl on a flash chip
Message-Id: <1052398483.841906@minime.linuxiceberg.com>

Hello,

I'm looking at placing perl 5.8.0 in our embedded device.
When I compile stable.tgz, it results in a distibution that is
roughly42m is size.  Too big for us.  We really do not need all
those modules.  Currently I'm looking at doing
CGI, regualr expressiona, and some IO.  If I can get perl down
to a small enough size with only support for those features, I'll
be in heaven.  Can anyone give me some pointers?

Thanks,
Chris


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

Date: 8 May 2003 08:59:44 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Help: Need nifty idea for efficiently linking objects together and making comparisons,,,
Message-Id: <b9d6a0$p6f$1@mamenchi.zrz.TU-Berlin.DE>

entropy123 <email_entropy123@yahoo.com> wrote in comp.lang.perl.misc:
> Hey all,
> 
> I'm working on molecules and am trying to come up with a connectivity
> routine.
> 
> For example, starting with the knowledge of the bonds each atom has I
> need to figure out if there is a ring structure. So, for a six carbon
> molecule is it something like C-C-C-C-C-C or a ring structure.
> 
> My idea is to take the bonding information and - starting with an
> individual atom - create an array. If the array ever has the starting
> atom as an element then I know I have a ring..
> 
> Does perl have any routines which might make this an easier job? :)
> All those if/then statements make my head spin....

Finding cycles is a typical job for a graph algorithm.  I'd look
for something on CPAN.

Anno


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

Date: Thu, 08 May 2003 11:58:12 +0000
From: Garry Short <g4rry_short@zw4llet.com>
Subject: Re: Help: Need nifty idea for efficiently linking objects together and making comparisons,,,
Message-Id: <b9dj9q$n4d$1$8302bc10@news.demon.co.uk>

entropy123 wrote:

> Hey all,
> 
> I'm working on molecules and am trying to come up with a connectivity
> routine.
> 
> For example, starting with the knowledge of the bonds each atom has I
> need to figure out if there is a ring structure. So, for a six carbon
> molecule is it something like C-C-C-C-C-C or a ring structure.
> 
> My idea is to take the bonding information and - starting with an
> individual atom - create an array. If the array ever has the starting
> atom as an element then I know I have a ring..
> 
> Does perl have any routines which might make this an easier job? :)
> All those if/then statements make my head spin....
> 
> Thanks!
> entropy

Checking for your ring element should be fairly easy ...

#!/usr/bin/perl -w

sub CheckForRing {
  # Returns 1 (TRUE) if a ring is found, or 
  # 0 (FALSE) otherwise.
  my @array = @_;       # Grab the array we've been passed.
  my $start = shift(@array);    # Grab the first atom
  my $return = 0;
  foreach my $entry (@array) {  # Process the rest of the array
    if ($entry eq $start) {     # Found a match!
      $return = 1;              # Set $return to true.
      last;                     # Exit the loop
    }
  }
  return $return;
}

my @molecule = qw(C O H H C);   # Define a molecule for example purposes.
if (&CheckForRing(@molecule) {
  # This molecule contains a ring!
} else {
  # This molecule doesn't
}
    

I haven't tested this, but it should work.

Regards,

Garry




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

Date: Thu, 8 May 2003 09:59:41 +1000
From: "Anthony" <wallabyedward@hunterlink.net.au>
Subject: How can I pack an IP address into four binary bytes ?
Message-Id: <b9dgpd$hg0u9$1@ID-82947.news.dfncis.de>

For example if  my IP address is

234.243.09.3

how do I verify the number < 255 and  then write it to  a file as a four
binary bytes ?

Thanks,
Anthony




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

Date: 8 May 2003 12:16:05 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How can I pack an IP address into four binary bytes ?
Message-Id: <b9dhq5$3qf$1@mamenchi.zrz.TU-Berlin.DE>

Anthony <wallabyedward@hunterlink.net.au> wrote in comp.lang.perl.misc:
> For example if  my IP address is
> 
> 234.243.09.3
> 
> how do I verify the number < 255 and  then write it to  a file as a four
> binary bytes ?

Use inet_aton() from the Socket module.  It returns the packed address
in four bytes if all components are in range, undef otherwise.

Anno


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

Date: Thu, 08 May 2003 06:54:35 GMT
From: "Mihai N." <nmihai_2000@yahoo.com>
Subject: Re: How do you create a biniary file in Perl.
Message-Id: <Xns9374F34C9ED4FMihaiN@216.148.227.77>

> Hmm. I would expect \r to be reliable, yet perlport claims that it's a
> LF on Mac. Is there anyone with a Mac able to confirm or refute this?
I can check tomorow at the office.
Are there any specific tests you can think ok?
Otherwise I will just try to print
"\n" "\r" "\012", both with binmode and without.

Mihai


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

Date: Thu, 08 May 2003 06:54:57 GMT
From: "Mihai N." <nmihai_2000@yahoo.com>
Subject: Re: How do you create a biniary file in Perl.
Message-Id: <Xns9374F33009C33MihaiN@63.240.76.16>

> Hmm. I would expect \r to be reliable, yet perlport claims that it's a
> LF on Mac. Is there anyone with a Mac able to confirm or refute this?
I can check tomorow at the office.
Are there any specific tests you can think ok?
Otherwise I will just try to print
"\n" "\r" "\012", both with binmode and without.

Mihai


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

Date: Thu, 08 May 2003 06:58:19 GMT
From: "Mihai N." <nmihai_2000@yahoo.com>
Subject: Re: How do you create a biniary file in Perl.
Message-Id: <Xns9374F3EE7F5D5MihaiN@216.148.227.77>

> The proof of the pudding would be in the eating. I don't have a Windows
> system with Perl installed at hand, but
> if ("\n" eq "\012") { print "equal\n"; } else { print "not equal\n"; }
> would show it.
Tested. Answer: "equal"

Mihai


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

Date: Thu, 08 May 2003 07:22:12 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: How do you create a biniary file in Perl.
Message-Id: <u31kbvo0o69t3fcnkkb669opnc4d6mctu0@4ax.com>

Eric J. Roode wrote:

>How can perl possibly tell the difference?
>
>my $nl1 = "\012";
>my $nl2 = "\n";
>
>print A "whee! $nl1";
>print A "woo-hoo! $nl2";
>
>binmode B;
>print B "whee! $nl1";
>print B "woo-hoo!" $nl2";

There is no difference. Not on Windows, anyway. On Windows, just like on
Unix, "\n" is a symbolic representation of "\012".

It's the *handle* that converts this "\012", *each* instance of it, into
"\015\012", without binmode(). With binmode(), which changes the
behaviour of the handle, this conversion is prevented.

In the same way, when reading from a non-binmode()d handle, "\015\012"
is converted to "\012". Bare "\015" and "\012" are not touched. Again,
binmode() tells the handle not to do this.

-- 
	Bart.


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

Date: Thu, 8 May 2003 11:05:36 +1000
From: "Anthony" <wallabyedward@hunterlink.net.au>
Subject: Ina a binary file is a space padded text file converted to nulls ?
Message-Id: <b9dkku$hvd4p$1@ID-82947.news.dfncis.de>

just say I had a twelve character hostname field and I'm converting it and
other data to a binary file, if the text filed hostname is padded witrh
spaces is this converted to nulls when converting it to binary. If not how
do you do it ??

Thanks
Anthony




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

Date: 7 May 2003 21:35:57 -0700
From: anand_ramamurthy@yahoo.com (Anand Ramamurthy)
Subject: No ouput from Net::SSH:Win32Perl / Net::SSH::Perl
Message-Id: <761041e6.0305072035.6a9c7c48@posting.google.com>

I am using PERL versions: v5.6.1 & v5.8.0 on Windows machines.

I am trying to use Net::SSH::Win32Perl to access a HP-UX m/c
from a MS Win2K box.

I realize by using Net::SSH::Win32Perl, I can use only SSH2
protocols.

After installing all dependencies, I was able to install all the
required modules.

Here's the test script I am trying:
----------------------------------- Begin --------------------------
use Net::SSH::W32Perl;

my $host="11.22.33.44";
my $user="login";
my $passwd="passwd";

my ($ssh, $out, $err, $exit); 

my %args;
$args{debug} = 1;
$args{protocol} = 2;

$ssh = new Net::SSH::W32Perl($host, %args);
$ssh->login($user, $passwd);

($out, $err, $exit) = $ssh->cmd("uname -a");

print "OUT: [$out]\n";
print "ERR: [$err]\n";
print "EXIT: [$exit]\n";
-----------------------------------  End  --------------------------

The output on the screen:
----------------------------------- Begin --------------------------
C:\SSH>perl xx.pl
anandr: Reading configuration data /.ssh/config
anandr: Reading configuration data /etc/ssh_config
anandr: Connecting to 11.22.33.44, port 22.
anandr: Socket created, turning on blocking...
anandr: Remote protocol version 2.0, remote software version OpenSSH_3.5p1
anandr: Net::SSH::Perl Version 1.23, protocol version 2.0.
anandr: No compat match: OpenSSH_3.5p1.
anandr: Connection established.
anandr: Sent key-exchange init (KEXINIT), wait response.
anandr: Algorithms, c->s: 3des-cbc hmac-sha1 none
anandr: Algorithms, s->c: 3des-cbc hmac-sha1 none
anandr: Entering Diffie-Hellman Group 1 key exchange.
anandr: Sent DH public key, waiting for reply.
anandr: Received host key, type 'ssh-dss'.
anandr: Host '11.22.33.44' is known and matches the host key.
anandr: Computing shared secret key.
anandr: Verifying server signature.
anandr: Waiting for NEWKEYS message.
anandr: Enabling incoming encryption/MAC/compression.
anandr: Send NEWKEYS, enable outgoing encryption/MAC/compression.
anandr: Sending request for user-authentication service.
anandr: Service accepted: ssh-userauth.
anandr: Trying empty user-authentication request.
anandr: Authentication methods that can continue: publickey,password,keyboard-in
teractive.
anandr: Next method to try is publickey.
anandr: Next method to try is password.
anandr: Trying password authentication.
anandr: Login completed, opening dummy shell channel.
anandr: channel 0: new [client-session]
anandr: Requesting channel_open for channel 0.
anandr: channel 0: open confirm rwindow 0 rmax 32768
anandr: Got channel open confirmation, requesting shell.
anandr: Requesting service shell on channel 0.
anandr: channel 1: new [client-session]
anandr: Requesting channel_open for channel 1.
anandr: Entering interactive session.
anandr: Sending command: uname -a
anandr: Requesting service exec on channel 1.
anandr: channel 1: open confirm rwindow 0 rmax 32768
-----------------------------------  End  --------------------------

It just hangs here forever. No output.

Any idea what may be wrong?
Appreciate any/all help.

Regards,

-anand
anand_ramamurthy@yahoo.com


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

Date: Thu, 08 May 2003 08:52:31 -0400
From: Christopher Fowler <cfowler@outpostsentinel.com>
Subject: Re: OT: Alternative to Xwin?
Message-Id: <1052398335.950766@minime.linuxiceberg.com>

entropy123 wrote:

> Hey all,
> 
> I'd like to work more from home and can VPN/SSH work. However, no
> matter what I can't seem to get Xwin working behind my firewall/router
> combo. Is there an alternative comparable app to Xwin? Hopefully
> free....
> 
> Thanks,
> entropy

I'm not wure if you mean Xwin-32.  But, Xwin-32 is the way to go.  They
are releasing a new module that uses the putty api to tunnel inside
of SSH.  I've seen demos and it works quite well.

Chris



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

Date: Thu, 08 May 2003 11:38:00 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Perl code to dump palm datebook?
Message-Id: <3eba40cf.2407398736@news.cis.dfn.de>

On Wed, 7 May 2003 20:32:10 +0000 (UTC), joe@jolomo.net
wrote:

>Does anyone have some perl code that will take the datebook.dat
>file from the palm hot-sync and output the entries in a log format
>something like:
>
>  2002 Dec 29 Sun 10:15 DFW -> ATL delta 1119
>  2003 Jan  9 Thu 14:00 Doctor appt
>  2003 Jan  9 Thu 16:00 Drinks @ Trader Vics
>  2003 Jan 12 Sun 13:00 Movie: It Happened One Night
>
>ie only print lines for times when there is data. If not from
>the datebook.dat maybe some other version of palm data (which?)
>
>I've looked at pilot-link & the PDB module, but they don't
>seem to do it.

What does the databook.dat file look like?

What have you tried?

I suggest the concerted use of the Perl 
functions open, die, while*, split, print and close.

The documentation for these functions can be
looked up on your local hard drive with:

perldoc -f open
perldoc -f die
perldoc perlsyn
perldoc -f split
perldoc -f print
perldoc -f close

If the date is not in a format you like, I suggest
the module Date::Manip.

*Yes, I know while isn't a function,hence look it
up in the Perl Syntax chapter, not in the Function
chapter.
-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


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

Date: Thu, 08 May 2003 08:35:59 +0100
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: perl compiler for win32 platform?
Message-Id: <3EBA08DF.9060009@bbsrc.ac.uk>



ZZT wrote:
> Hello Simon,
> 
>> OK, quick summary from the PAR list is that they aren't exactly sure 
>> what's going on either!  Their best guess is that you have MSVC++ 
>> installed (Yes?),
> 
> correct
> 
>> and that both nmake and cl are in your path (Yes?), 
> 
> no they wasn't in my path

That's strange, because in your last post the error you got during make 
suggested that cl had been found, and that internal compiler errors were 
causing the make to stop.  Since you hadn't run the vsvars32.bat file 
(or had you?) then the makefile shouldn't have known where to find the 
compiler.

> I download and used the nmake suggested from the makefile.pl-construct

 ..and installed it in a location in your path ahead of the one which 
came with vc++?


>> There are two potential fixes to this:
>>
>> 1) If you want to compile PAR yourself using your local compiler then 
>> run the vcvars32.bat file which comes with the PAR distribution before 
>> doing perl Makefile.PL etc.  This should find all the appropriate 
>> library paths for your local compiler and things should proceed from 
>> there.
> 
> this part is now running fine, but...

Well that's some progress at least! :-)


> the whole script-creation-stuff has unfort. problems with spaces in 
> path-names. I manually fixed a lot of them by editing the created files 

Hmm.  Sounds like a problem.  Is there any chance you could post your 
original Makefile (before you edited it) to par@perl.org, along with a 
brief summary of what you'd done to that point so the module maintainers 
can look through it to see what's gone wrong.


> but in step "NMAKE TEST" I got:
 >
> t/0-signature.......'C:\Program' is not recognized as an internal or 
> external command, operable program or batch file.

If the make completed then you may find that you have a working version 
of PAR, and that it's just the test packages which are messed up.  You 
could try a make install anyway and test it on your own files, but this 
may also fail if the makefile is screwed.

I'm surprised this hasn't come up as an issue before, but maybe most 
people take the default perl location of c:\perl?

TTFN

Simon.



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

Date: Thu, 08 May 2003 11:33:57 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Perl Directories
Message-Id: <3eba3ef8.2406927188@news.cis.dfn.de>

On 7 May 2003 12:34:42 -0700, mnabbas@hotmail.com
(SuperStar) wrote:

>Im a newbie at perl, I stumbled onto a problem with directories that I
>thought maybe is a problem with my program. Im trying to write a
>program which transverses a directory according to my input. 

I suspect you mean "traverses".

>When I try to check for validity it complains that the directory is not
>there.

How?  What are you checking.  Show us some code, man.

I suggest you use the core module $File::Find;

-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


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

Date: Thu, 8 May 2003 09:51:35 +0100
From: "Clyde Ingram" <cingram@pjocsNOSPAMORHAM.demon.co.uk>
Subject: Re: print <<"ending_print_tag";
Message-Id: <b9d5ps$b6j$1$8300dec7@news.demon.co.uk>

"David Taylor" <me@webmasterdave.co.uk> wrote in message
news:3EB93482.9000602@webmasterdave.co.uk...
> Heya...
>
> . . . bare with me...

Whoa there!  I don't think so.  I'm a happily married man AND this is a
public forum.
Tsk, tsk.              ;-}





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

Date: Thu, 08 May 2003 13:49:54 +0100
From: David Taylor <me@webmasterdave.co.uk>
Subject: Re: print <<"ending_print_tag";
Message-Id: <3EBA5272.50108@webmasterdave.co.uk>

Clyde Ingram wrote:
> "David Taylor" <me@webmasterdave.co.uk> wrote in message
> news:3EB93482.9000602@webmasterdave.co.uk...
> 
>>Heya...
>>
>>. . . bare with me...
> 
> 
> Whoa there!  I don't think so.  I'm a happily married man AND this is a
> public forum.
> Tsk, tsk.              ;-}
> 
> 
> 
Ookaaaayyyyy.... you know I didn't mean that :-p





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

Date: 08 May 2003 07:50:25 GMT
From: vek@station02.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Question about File test operators
Message-Id: <slrnbbk321.atl.vek@station02.ohout.pharmapartners.nl>

On Wed, 07 May 2003 11:15:15 -0700,
    TruthXayer <TruthXayer@yahoo.com> wrote:


>
>So put in parentheses to say what you really mean.  (You
>could could be comparing String "-M" to be lt 1 as well). Be
>clear in your code.


Using the lt operator to compare two numeric valus isn't exactly clear
coding.  As we all know, the lt operator is for comparing string values,
which in this case probably sould give the same result, but never the less.



Villy


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

Date: Thu, 8 May 2003 00:07:27 -0500
From: Gopi Sundaram <gopalan@cs.sc.edu>
Subject: Sorting book list
Message-Id: <Pine.GSO.4.55.0305072351070.5146@rigel>

I'm tring to sort my list of books. I store the list as an array of
hashes.

The sort order is the surname of the first author. If the book is part
of a series, I want the books in the series to be in order. Not all
books are in a series.

The two fields in the hash I am interested in therefore, are 'series'
and 'author'.

The 'series' field looks like this for books:

"Arabian Nights 1"
"MVS 2"
"Arabian Nights 2"
"MVS 1"

The 'author' field contains a comma-separated list of authors.

If the "Arabian Nights" series was by Zipes, and the MVS series by
Jackman, The sorted list would be

MVS 1
MVS 2
Arabian Nights 1
Arabian Nights 2

Right now, what I do is, I check to see if the books are in a series. If
they aren't in any series, or if they belong to different series, then
the comparison is by author. If they belong to the same series, then the
sorting is by series ordinal. The code for this is below my signature.

This algorithm is flawed, because the members of a series need not
be compared to establish the sort order, so they can appear out of
order.

So how would I sort this list as described above?

-- 
Gopi Sundaram

sub by_series_author() {
    # Default to Alpha sort
    my $numeric = 0;

    # If part of a series
    if (defined $a->{'series'} && defined $b->{'series'}) {
        # Check to make sure it's the same series
        my $first = $a->{'series'};
        $first =~ s/ \d+$//;

        my $second = $b->{'series'};
        $second =~ s/ \d+$//;

        # If same series, then numeric sort by series ordinal
        $numeric = 1 if $first eq $second;
    }

    if ($numeric) {
        # Numeric sort.

        # Strip out series name
        my $first = $a->{'series'};
        $first =~ s/.+ (\d+)$/$1/;

        my $second = $b->{'series'};
        $second =~ s/.+ (\d+)$/$1/;

        # Compare series ordinal
        return ($first <=> $second);
    }
    else {
        # Alphabetical sort

        # Get first author's name
        my @first = split /, /, $a->{'author'};

        # Get author's surname
        @first = (split / /, $first[0]);
        my $first = $first[-1];

        my @second = split /, /, $b->{'author'};
        @second = (split / /, $second[0]);
        my $second = $second[-1];

        # Compare surnames
        return ($first cmp $second);
    }
}


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

Date: Thu, 08 May 2003 05:28:28 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Sorting book list
Message-Id: <mbudash-91D2D5.22282907052003@typhoon.sonic.net>

In article <Pine.GSO.4.55.0305072351070.5146@rigel>,
 Gopi Sundaram <gopalan@cs.sc.edu> wrote:

> I'm tring to sort my list of books. I store the list as an array of
> hashes.

nope. most likely you have an array of hashrefs. let's see some real 
data!

> The sort order is the surname of the first author. If the book is part
> of a series, I want the books in the series to be in order. Not all
> books are in a series.
> 
> The two fields in the hash I am interested in therefore, are 'series'
> and 'author'.
> 
> The 'series' field looks like this for books:
> 
> "Arabian Nights 1"
> "MVS 2"
> "Arabian Nights 2"
> "MVS 1"
> 
> The 'author' field contains a comma-separated list of authors.
> 
> If the "Arabian Nights" series was by Zipes, and the MVS series by
> Jackman, The sorted list would be
> 
> MVS 1
> MVS 2
> Arabian Nights 1
> Arabian Nights 2
> 
[snip code for now]

show us the data, or we can't really help.

-- 
Michael Budash


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

Date: Thu, 8 May 2003 07:23:15 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Sorting book list
Message-Id: <slrnbbkj1j.a4r.tadmc@magna.augustmail.com>

Gopi Sundaram <gopalan@cs.sc.edu> wrote:

> The code for this is below my signature.


Please do not do that.


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


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

Date: Thu, 8 May 2003 15:30:54 +0800
From: "Ahab" <nospam@spamfreeland.com>
Subject: Re: web page contents into a perl script
Message-Id: <3eba07a1$1@usenet.per.paradox.net.au>

Thanks.

-- 
Ahab

"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnbbjgok.8ek.tadmc@magna.augustmail.com...
> Ahab <nospam@spamfreeland.com> wrote:
>
> > What guidelines ? For this Newsgroup ?
>
>
> They are posted here twice each week:
>
>    http://mail.augustmail.com/~tadmc/clpmisc.shtml
>
>
>
> [context snipped because it was quoted following the sig-dash!]
>
>
> -- 
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas




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

Date: Thu, 08 May 2003 09:42:29 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: web page contents into a perl script
Message-Id: <b9d4u3$8v4$1@news.dtag.de>

Ahab wrote:
> Thanks.


Did you read them?



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

Date: 8 May 2003 03:25:17 -0700
From: stewart@webslave.dircon.co.uk (stew dean)
Subject: Re: web page contents into a perl script
Message-Id: <2b68957a.0305080225.673b5074@posting.google.com>

"Ahab" <nospam@spamfreeland.com> wrote in message news:<3eb8d9e5$1@usenet.per.paradox.net.au>...
> Hi all,
> 
> How would you read  the contents of a web page into a perl script ?
> 
> Once I can get it as $_ , I can then do further stuff with it.
> 
> 
> For instance:
> 
> http:\\www.example.com\  has a index.html. I want to read the contents of
> that html page into a perl script just as I could read the contents of text
> file in as $_.
> 
> Any help would be appreciated.

First can I say how very unhelpful some of the people posting here can
be. How about providing the answer then providing sources where more
information can be provided.

Okay now onto how I do it....

at the start use

    use LWP::Simple; 

and then in the code..

   my $url="http://www.example.com/index.html";
   my $content = get $url;
   die "Couldn't get $url" unless defined $content;

$content is your page that you can now do what ever you want to.

print $content; and you'll see the page you're pointing at.

Cheers

Stew Dean
www.thesheen.net


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

Date: Thu, 08 May 2003 11:39:03 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: web page contents into a perl script
Message-Id: <3eba41c1.2407640133@news.cis.dfn.de>

On Thu, 08 May 2003 09:42:29 +0200, Malte Ubl
<ubl@schaffhausen.de> wrote:

>Ahab wrote:
>> Thanks.
>
>Did you read them?
>
Obviously not.  He's still top-posting.

-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


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

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


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