[19819] in Perl-Users-Digest
Perl-Users Digest, Issue: 2014 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 26 03:05:48 2001
Date: Fri, 26 Oct 2001 00:05:10 -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: <1004079909-v10-i2014@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 26 Oct 2001 Volume: 10 Number: 2014
Today's topics:
Re: Automated html index ? (David Efflandt)
Can perl fill-in a web form without submitting it? (Qunfeng Dong)
Re: Can perl fill-in a web form without submitting it? <spam@thecouch.homeip.net>
Re: Can perl fill-in a web form without submitting it? <me@REMOVETHIStoao.net>
Re: CPAN.pm complaining all the time (trwww)
Re: Dumping Perl Hashes <persicom@acedsl.com>
Re: Dumping Perl Hashes (trwww)
Re: extract file extention from file name <bernard.el-hagin@lido-tech.net>
Re: extract file extention from file name <mgjv@tradingpost.com.au>
Re: handling numbers with leading zeros <krahnj@acm.org>
Re: https and writing files <tedapke@apkesoftware.com>
IIS and Perl - Why the corruption? (Gordon McCreight)
Re: IIS and Perl - Why the corruption? <wyzelli@yahoo.com>
Re: Memory management (Logan Shaw)
Re: Memory management <goldbb2@earthlink.net>
Re: modification times on Windows files <rtrahan@monmouth.com>
Re: New user question <Laocoon@eudoramail.com>
Re: New user question <spam@thecouch.homeip.net>
Re: NEWBIE: double sort on a string <krahnj@acm.org>
Re: NEWBIE: multiple column sort routine <persicom@acedsl.com>
Re: one-liner solution sought (Logan Shaw)
Re: Ordering pairs of links [a bit long] <jeff@vpservices.com>
Re: Regex to swap HTML tags (Logan Shaw)
Re: Stripping Duplicates From Arrays <persicom@acedsl.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 26 Oct 2001 02:50:17 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Automated html index ?
Message-Id: <slrn9thjr9.78i.efflandt@typhoon.xnet.com>
On Thu, 25 Oct 2001 10:10:07 -0500, Leary <Leary@foad.org> wrote:
> Is it feasible to use perl to create an index of html docs in a given dir? I
> need to include info from the title field and an updated field within each
> html doc in the index.
See pub/dirindex.txt in either bottom URL in my sig. I use that as
index.cgi (included in DirectoryIndex list) to list files in those
directories because they have Indexing disabled there. Other replies
should help you add the code to parse the pages for the title.
To get the modification time just do a $mtime = (stat($file))[9]; on each
file and crank $mtime into localtime(), gmtime() or strftime in the POSIX
module. For example scalar gmtime($mtime) would give you a typical Unix
like date in GMT.
--
David Efflandt - All spam is ignored - http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: 26 Oct 2001 03:59:11 GMT
From: qfdong@iastate.edu (Qunfeng Dong)
Subject: Can perl fill-in a web form without submitting it?
Message-Id: <9ran2f$j8i$1@news.iastate.edu>
Hi there,
How can perl be used to automatically fill in a web form??
Say there is a web site with form for users to input, can a perl script
be used to fill in that form (without submitting it?) Thanks!
Qunfeng Dong
--
Qunfeng Dong
qfdong@iastate.edu
------------------------------
Date: Fri, 26 Oct 2001 00:56:38 -0400
From: "Mina Naguib" <spam@thecouch.homeip.net>
Subject: Re: Can perl fill-in a web form without submitting it?
Message-Id: <u16C7.10132$cE2.738281@weber.videotron.net>
"Qunfeng Dong" <qfdong@iastate.edu> wrote in message
news:9ran2f$j8i$1@news.iastate.edu...
> Hi there,
>
> How can perl be used to automatically fill in a web form??
>
> Say there is a web site with form for users to input, can a perl script
> be used to fill in that form (without submitting it?) Thanks!
A web form is usually shown through a web browser.
Do you mean perl can act as a web browser ?
Or do you mean perl used to write a cgi that will generate a form with
pre-defined values ?
Or do you mean perl used as a plug-in to an existing web browser that will
auto-fill form fields in the browser ?
>
> Qunfeng Dong
> --
> Qunfeng Dong
> qfdong@iastate.edu
------------------------------
Date: Fri, 26 Oct 2001 05:01:11 GMT
From: "Graham W. Boyes - TOAO.net" <me@REMOVETHIStoao.net>
Subject: Re: Can perl fill-in a web form without submitting it?
Message-Id: <r66C7.120052$ob.2680972@news1.rdc1.bc.home.com>
Something like this maybe?
###################################################
#!/usr/bin/perl
print "Content-type:text/html
<HTML><HEAD><TITLE>Test Form</TITLE></HEAD>
<BODY>
<FORM method=whatever action=whatever>
<INPUT type=text name=textinput value="Here Is Where You Put Your
Value Or $variable">
<TEXTAREA rows=10 cols=10 name=bigtextinput>Or, If You Have A
Textarea, Do It Like This! $Or_Have_A_Variable_In_Here</TEXTAREA>
</FORM>
</BODY></HTML>
";
###################################################
Good luck
Graham W. Boyes
--
Health warning: diet soft drinks, Equal sweetener and NutraSweet
contain the artificial sweetener Aspartame WHICH CAN CAUSE CANCER,
DIABETES, OBESITY, EYE DISEASE, PARKINSON'S AND MORE. Read more here:
http://www.dorway.com/
"Qunfeng Dong" <qfdong@iastate.edu> wrote in message
news:9ran2f$j8i$1@news.iastate.edu...
> Hi there,
>
> How can perl be used to automatically fill in a web form??
------------------------------
Date: 25 Oct 2001 21:00:29 -0700
From: toddrw69@excite.com (trwww)
Subject: Re: CPAN.pm complaining all the time
Message-Id: <d81ecffa.0110252000.29f8a266@posting.google.com>
perl -MCPAN -e 'force install Net::FTP' ...?
Lou Moran <lmoran@wtsg.com> wrote in message news:<2k3gttc10oaf9ilice5s0lu6ubjg43132e@4ax.com>...
> On Wed, 24 Oct 2001 19:28:14 BST, spam@freeuk.com (Stephen Patterson)
> wrote wonderful things about sparkplugs:
>
> SNIP
> >>> but it always complains about
> >>> Net::FTP but won't let me install Net::FTP!
> >
> >Have you tried just 'install Net::FTP'?
>
> doesn't work. It's no big deal I guess
------------------------------
Date: Thu, 25 Oct 2001 21:55:53 -0400
From: "Matthew O. Persico" <persicom@acedsl.com>
Subject: Re: Dumping Perl Hashes
Message-Id: <3BD8C2A9.3070307@acedsl.com>
Garry Williams wrote:
> On 25 Oct 2001 04:23:20 -0700, Stephen Jayna <sjayna@catchword.com> wrote:
>
>>I currently working on a project that requires me to dump large hash's
>>to a file and then read them back in again and restore them to the
>>same structure.
>>
>
> You should look at Storable.
>
>
Or Data::Dumper
--
Matthew O. Persico
New York City - United We Stand
------------------------------
Date: 25 Oct 2001 21:02:58 -0700
From: toddrw69@excite.com (trwww)
Subject: Re: Dumping Perl Hashes
Message-Id: <d81ecffa.0110252002.15a0e4a0@posting.google.com>
sjayna@catchword.com (Stephen Jayna) wrote in message news:<9683035a.0110250323.5e361abd@posting.google.com>...
snip
> Normally this wouldn't matter though I have to distribute this to our
> 40+ servers running Perl 5.005.... Data::DumpXML claims it needs Perl
> 5.6+
id use a SOAP object
------------------------------
Date: 26 Oct 2001 05:59:58 GMT
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: extract file extention from file name
Message-Id: <slrn9thuic.3nk.bernard.el-hagin@gdndev25.lido-tech>
On Fri, 26 Oct 2001 00:54:07 +0100, jimbo <jimbo@soundimages.co.uk> wrote:
> "Bernard El-Hagin" <bernard.el-hagin@lido-tech.net> wrote
>
>> Blah, blah, blah. And what the hell is /\./ if not a regex?
>
> There is a fundamental difference between expressiing an algorithm using
> a regex and expressing an algorithm using a builtin function.
You said, and I quote:
"You don't need a regex, if you don't want one."
Then you happily proceeded to give a solution which indeed needed one.
Gotta love the irony.
Cheers,
Bernard
------------------------------
Date: Fri, 26 Oct 2001 06:32:40 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: extract file extention from file name
Message-Id: <slrn9ti0sa.2uf.mgjv@verbruggen.comdyn.com.au>
[Superseded original article, added one more test for benchmark]
On Fri, 19 Oct 2001 20:02:22 +0100,
jimbo <jimbo@soundimages.co.uk> wrote:
> "peter" <peter_icaza@REMOVE2REPLYuhc.com> wrote
>
>> long.file.name.1
>
> You don't need a regex, if you don't want one. How about this:
>
> my $name = '1.name.file.long';
>
> # I changed it because the single digit '1' looked lonely all by
> itself printed later
>
> my $ext = [reverse split /\./, $name];
> print $ext->[0] if scalar @$ext > 1;
And if you want one that doesn't use a regex at all:
my $ext = substr $_, 1 + rindex $_, ".";
And just to justify that:
#!/usr/local/bin/perl -w
use strict;
use Benchmark qw(cmpthese);
our $f = "long.file.name.ext";
cmpthese(-5, {
substr => sub { substr $f, 1 + rindex $f, "." },
split1 => sub { (reverse split /\./m, $f)[0] },
split2 => sub { (split /\./m, $f)[-1] },
regex1 => sub { ($f =~ m/\.([^.]+)$/)[0] },
regex2 => sub { ($f =~ m/.*\.([^.]+)$/)[0] },
});
Slightly edited output on this system (v5.6.1, i586-linux):
Benchmark: running regex1, regex2, split1, split2, substr,
each for at least 5 CPU seconds...
regex1: 7 wallclock secs ( 5.35 usr + 0.00 sys = 5.35 CPU)
@ 61253.83/s (n=327708)
regex2: 7 wallclock secs ( 5.22 usr + 0.01 sys = 5.23 CPU)
@ 104658.51/s (n=547364)
split1: 6 wallclock secs ( 5.04 usr + 0.00 sys = 5.04 CPU)
@ 66272.02/s (n=334011)
split2: 6 wallclock secs ( 5.42 usr + 0.00 sys = 5.42 CPU)
@ 60429.34/s (n=327527)
substr: 6 wallclock secs ( 5.01 usr + 0.00 sys = 5.01 CPU)
@ 614812.18/s (n=3080209)
Rate split2 regex1 split1 regex2 substr
split2 60429/s -- -1% -9% -42% -90%
regex1 61254/s 1% -- -8% -41% -90%
split1 66272/s 10% 8% -- -37% -89%
regex2 104659/s 73% 71% 58% -- -83%
substr 614812/s 917% 904% 828% 487% --
Interesting, hmm?
Martien
--
Martien Verbruggen |
| Useful Statistic: 75% of the people
Trading Post Australia Pty Ltd | make up 3/4 of the population.
|
------------------------------
Date: Fri, 26 Oct 2001 03:53:04 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: handling numbers with leading zeros
Message-Id: <3BD8DEA8.FA052552@acm.org>
Zachary Kent wrote:
>
> Our website collects Social Security Numbers and I have had problems with
> Perl assuming that leading zeros are not needed and throws them out. How do
> I tell Purl(sic)[1] to treat a variable as a string when it contains only numbers?
One word - context - if you use a scalar in a numerical context it's a
number, in a string context it's a string.
[1] I assume you mean Perl :-)
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 26 Oct 2001 06:13:19 GMT
From: "Ted Apke" <tedapke@apkesoftware.com>
Subject: Re: https and writing files
Message-Id: <3a7C7.22796$IR4.12821565@news1.denver1.co.home.com>
Sorry. I wish there were more details to share. The open fails. Here is a
sample script.
require 'ctime.pl';
if (!open(DEBUGLOG, '>>DebugLog.html'))
{
$DEBUG_LOG = 0;
} else {
print DEBUGLOG "===================================<br>\n";
print DEBUGLOG "ManRegister.pl Started at ", &ctime($^T), "<br>\n";
}
This portion of my script works fine when the cgi is accessed via http. If
https is used, the open fails, and no debug log is created/written to.
There are multiple (3) file writes in the script. All fail.
Ideas?
Ted
"Mina Naguib" <spam@thecouch.homeip.net> wrote in message
news:BQWB7.3519$cE2.162075@weber.videotron.net...
>
> "Ted Apke" <tedapke@apkesoftware.com> wrote in message
> news:5EVB7.20414$IR4.11759583@news1.denver1.co.home.com...
> > I'm having a problem writing to a file when the perl CGI script is
> accessed
> > via a secure connection. The script works fine when the connection is
via
> > http, but when run from https it fails. I'm not 100% sure of the host
> > environment but I'd say it is Solaris.
> >
> > I've done a number of searches, including Google groups, and found
nothing
> > similar. I'd appreciate any suggestions.
>
> I also got into my car a few days ago but it didn't take me to work. Can
you
> tell me why ?
>
> Seriously, you provide no details at all. Help us out here. What exactly
is
> the error message, if any.. ?
>
> >
> > Thanks in advance.
> >
> > Ted Apke
> >
> >
> >
>
>
------------------------------
Date: 25 Oct 2001 18:45:49 -0700
From: gordon@mccreight.com (Gordon McCreight)
Subject: IIS and Perl - Why the corruption?
Message-Id: <4bd8a536.0110251745.1c7f0aa0@posting.google.com>
Hi All,
I've go the latest ActiveState Perl distribution running on a
Windows 2000 server. I am having issues with the results I'm getting
when executing perl scripts as CGIs from the browser. Specifically,
characters are getting corrupted. I wrote a test script. First it
writes the correct html header information, <html><body>, then 10,000
zeros, then the end of the page. It writes these all into a single
$output variable. Then I print the variable to both a file and to
stdout.
The results in the file are perfect, but occasionally there is
corruption on the version that is printed to the web browser. If I do
a "view source" on the corrupted version, it will look somthing like
this snip... it should only be zeros.
00000000000000000y6w4ck000000000000000000000
About 80% of the time everything works flawlessly... it's that 20%
that's driving me nuts.
Can anyone explain to me why the file that gets written to disk has no
errors, but the one that gets returned to the browser has errors? Is
this a result of the interaction between perl and IIS? I have to
admit that I don't understand the nature of the beast.
Thanks - Gordon
------------------------------
Date: Fri, 26 Oct 2001 11:49:23 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: IIS and Perl - Why the corruption?
Message-Id: <AB3C7.27$5E3.429@wa.nnrp.telstra.net>
"Gordon McCreight" <gordon@mccreight.com> wrote in message
news:4bd8a536.0110251745.1c7f0aa0@posting.google.com...
> Hi All,
> I've go the latest ActiveState Perl distribution running on a
> Windows 2000 server. I am having issues with the results I'm getting
> when executing perl scripts as CGIs from the browser. Specifically,
> characters are getting corrupted. I wrote a test script. First it
> writes the correct html header information, <html><body>, then 10,000
> zeros, then the end of the page. It writes these all into a single
> $output variable. Then I print the variable to both a file and to
> stdout.
>
> The results in the file are perfect, but occasionally there is
> corruption on the version that is printed to the web browser. If I do
> a "view source" on the corrupted version, it will look somthing like
> this snip... it should only be zeros.
>
> 00000000000000000y6w4ck000000000000000000000
>
> About 80% of the time everything works flawlessly... it's that 20%
> that's driving me nuts.
>
> Can anyone explain to me why the file that gets written to disk has no
> errors, but the one that gets returned to the browser has errors? Is
> this a result of the interaction between perl and IIS? I have to
> admit that I don't understand the nature of the beast.
Have you unbuffered the output?
Try putting
$| = 1;
At the top of your script.
Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";
------------------------------
Date: 25 Oct 2001 21:35:19 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Memory management
Message-Id: <9rai57$o1q$1@charity.cs.utexas.edu>
In article <m3pu7bqs7x.fsf@mumonkan.sunstarsys.com>,
Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
>logan@cs.utexas.edu (Logan Shaw) writes:
>> {
>> # create a variable with a huge value
>> my $x = "random junk" x 1_000_000;
>> }
>Care to wager on that? The memory allocated to $x is not freed when
>the block exits, and it is never "reclaimed" by perl for any other
>purpose.
That's surprising. In most normal languages, variables stop existing
once they go out of scope. (I know that has very little relevance
because Perl is not a normal language.)
So what are the conditions under which a lexical doesn't go away when
it's not in scope? Is it only when it's initialized to a constant
expression?
- Logan
--
"In order to be prepared to hope in what does not deceive,
we must first lose hope in everything that deceives."
Georges Bernanos
------------------------------
Date: Fri, 26 Oct 2001 02:54:53 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Memory management
Message-Id: <3BD908BD.6545F9BB@earthlink.net>
Joe Schaefer wrote:
>
> logan@cs.utexas.edu (Logan Shaw) writes:
>
> [...]
>
> > For example, in this code Perl will reclaim the storage for $x after
> > it leaves the block:
> >
> > {
> > # create a variable with a huge value
> > my $x = "random junk" x 1_000_000;
> > }
>
> Care to wager on that? The memory allocated to $x is not freed when
> the block exits, and it is never "reclaimed" by perl for any other
> purpose. And because of constant folding, which is documented in
> perlop, the same is true for the RHS of the "=" operator as well. The
> only way to prevent the RHS here from devouring RAM is to wrap it in
> an eval q{} statement.
Are you sure? I can understand about the RHS of the =, but ISTM that
the copy which is stored into $x should be freed [or at least reused]
the next time something allocates memory. I can certainly understand $x
itself [the part in the pad] being retained for speed, but imho, the
contents of $x ought to be thrown away unless $x itself [or a reference
to it, or a reference to the pad] sticks around.
Of course, with the 'imho' and the 'ought to' there, it's entirely
possible that perl doesn't do this.
--
Klein bottle for rent - inquire within.
------------------------------
Date: Thu, 25 Oct 2001 21:51:14 -0700
From: Richard Trahan <rtrahan@monmouth.com>
Subject: Re: modification times on Windows files
Message-Id: <3BD8EBC2.33909386@monmouth.com>
Bernard El-Hagin wrote:
>
> On Thu, 25 Oct 2001 07:03:13 -0700, Richard Trahan <rtrahan@monmouth.com>
> wrote:
> perldoc -f utime
>
Thanks (to the other responder as well).
I don't know how I missed this; possibly because of a note in perlport
that says "may not behave as expected" for Win32. I hate that
sort of thing. Before I got your response I wrote a (gasp) Java
program that has the desired behavior, and it works well in make
files, but of course I'll switch back to Perl.
------------------------------
Date: Fri, 26 Oct 2001 06:17:42 +0200
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: New user question
Message-Id: <Xns9146400EF1AF7Laocooneudoramailcom@62.153.159.134>
Perl can do that.. though i don't know if its worth learning if that is
_all_ you want to do.
------------------------------
Date: Fri, 26 Oct 2001 01:09:41 -0400
From: "Mina Naguib" <spam@thecouch.homeip.net>
Subject: Re: New user question
Message-Id: <Jd6C7.10356$cE2.746606@weber.videotron.net>
"Robt. Miller" <robtmil@ptd.net> wrote in message
news:Pine.LNX.4.21.0110251652250.24152-100000@localhost...
> I'm in the middle of converting my OS/2 system to Linux and the only
> thing I haven't figured out how to do is recreate a program I wrote in
> REXX and I'm not sure if Perl is the way to go since I know nothing about
> it. All I want to do is play random .wav files from a directory at random
> times. Will Perl do this?
>
#!/usr/bin/perl
use strict;
my $directory = "/home/mina/music";
my $player = "/bin/wavplay";
my $maxwait = 3600;
my @T;
my $filename;
my $temp;
fork && exit;
while (1) {
sleep(rand($maxwait));
opendir(DH, $directory) || die "Error opendir() $directory: $!\n";
while ($filename = readdir(DH)) {
if ($filename =~ /\.wav$/i) {
push (@T, $filename);
}
}
closedir(DH);
$filename = $T[rand(@T)] || next;
$filename = "$directory/$filename";
$temp = fork();
if ($temp == 0) {
exec("$player $filename");
exit;
}
elsif (!defined $temp) {
die "Error forking: $!\n";
}
}
#############################
#
# The above was written in 2.5 minutes with clearness in mind, and has not
been tested even for syntax.
# Now go learn perl.
------------------------------
Date: Fri, 26 Oct 2001 02:56:36 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: NEWBIE: double sort on a string
Message-Id: <3BD8D16B.E77B8E35@acm.org>
Andrew Cady wrote:
>
> "Jippie@yahoo.com" <jippie@yahoo.com> writes:
>
> > What I'm trying to do is to sort of on two columns.
> > The the first column is an argument and the second in always column 1.
> >
> > This is what I have done but my logic is wrong.
> > I thought it would be just an extra check if both are the same then check if
> > column 1 are the same.
> >
> > sub by_string
> > {
> > @parts_a=split(/[|]/,$a);
> > @parts_b=split(/[|]/,$b);
> >
> > $retval = (lc($parts_a[$sortfield])) cmp (lc($parts_b[$sortfield]));
> > if( $retval == 0 && $sortfield !=1 ) # they are the same
> > {
> > # then sort by title next. Always nice to have the title in order
> > $retval = (lc($parts_a[1])) cmp (lc($parts_b[1]));
> > }
> > }
>
> [snip]
>
> The final step is to extract the values from the anonymous array you
> created in the first step:
>
> @sorted_array = map { $_->[2] }
> sort { $a->[0] cmp $b->[0] || $a->[1] cmp $b->[1] }
> map { [ (split '|', lc)[0,1], $_ ] } @array_to_sort;
^^^^^^^^^
> Tada. It's faster, yet still easier to write, easier to understand,
> and idiomatic.
^^^^^^^^^
split /\|/, ... would have been idiomatic.
According to the OPs spec it should be written as:
@sorted_array = map { $_->[2] }
sort { $a->[0] cmp $b->[0] || $a->[1] cmp $b->[1] }
map { [ (split /\|/, lc)[$sortfield,1], $_ ] }
@array_to_sort;
:-)
John
--
use Perl;
program
fulfillment
------------------------------
Date: Thu, 25 Oct 2001 22:01:02 -0400
From: "Matthew O. Persico" <persicom@acedsl.com>
Subject: Re: NEWBIE: multiple column sort routine
Message-Id: <3BD8C3DE.3030508@acedsl.com>
Jippie@yahoo.com wrote:
> Hi,
>
> sorry but this didn't help, maybe I didn't explain well enough
> I have a five column table.
> index, title, owner, type & size.
> Each column can be sorted on, this I can do.
> It's just after I sorted on the column I then want a second sort after that
> to put the title in order.
>
> can you help??
>
> This is what I have done but my logic is wrong.
> I thought it would be just an extra check if both are the same then check if
> title are the same.
> sortfield is the argument given.
>
>
> sub by_string
> {
> @parts_a=split(/[|]/,$a);
> @parts_b=split(/[|]/,$b);
>
> $retval = (lc($parts_a[$sortfield])) cmp (lc($parts_b[$sortfield]));
> if( $retval == 0 && $sortfield !=1 ) # they are the same
> {
> # then sort by title next. Always nice to have the title in order
> $retval = (lc($parts_a[1])) cmp (lc($parts_b[1]));
> }
> }
>
> jippie
>
How does $sortfield get into this routine? I don't think it can come in
as an argument. And even if it could, you haven't pulled it off the
argument list, i.e, you haven't done this:
sub by_string {
my ($sortfield) = @_;
# etc.
Try adding a print as the first line:
print "When a is '$a' and b is '$b', sortfield is '$sortfield'\n";
Five bucks says $sortfield is undef, which prints as an empty string.
--
Matthew O. Persico
New York City - United We Stand
------------------------------
Date: 25 Oct 2001 21:30:44 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: one-liner solution sought
Message-Id: <9rahsk$nur$1@charity.cs.utexas.edu>
In article <x7pu7b1id0.fsf@home.sysarch.com>,
Uri Guttman <uri@sysarch.com> wrote:
>>>>>> "LS" == Logan Shaw <logan@cs.utexas.edu> writes:
> LS> $ perldoc -q pad
> LS> No documentation for perl FAQ keyword `pad' found
>works fine for me on 5.005_03 and 5.6.1
Heh, well, it must've been fixed between 5.005_02 and 5.005_03,
because the version I tried it on was 5.005_02. :-)
>and 'pad' is in the title of an faq.
Well sure -- how would it find it otherwise?
(Am I the only one who does things like "perldoc -q . | grep -i foo"?)
- Logan
--
"In order to be prepared to hope in what does not deceive,
we must first lose hope in everything that deceives."
Georges Bernanos
------------------------------
Date: Thu, 25 Oct 2001 21:29:37 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Ordering pairs of links [a bit long]
Message-Id: <3BD8E6B1.95C952BE@vpservices.com>
Bart Lateur wrote:
>
> Jeff Zucker wrote:
>
> >I have lists of pairs of linked items like this (link represented by a
> >colon)
> >
> > qw( a:b c:d a:d e:f );
> >
> >...And I want to
> >end up with an ordered list such that every item (except the first) has
> >a link to at least one of the items on its left. Which in this case
> >would be: abdc (the d comes before the c because it is linked to one of
> >a b while c is not).
>
> Aha. I think you should look into the Graph module on CPAN.
Thanks alot, Bart, that's a heck of a cool module.
I rewrote my code using it's TransitiveClosure method to (I think) do
the same thing as my previous attempt. I'm not sure though exactly how
it compares with my previous attempt so I'd still like some opinions on
my code. Meanwhile I'll go poke around in Graph's internals and
Abigail's TransitiveClosure module (now that I suspect that that's the
name of what I am trying to do) and see if I get any ideas.
--
Jeff
------------------------------
Date: 25 Oct 2001 21:37:53 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Regex to swap HTML tags
Message-Id: <9raia1$o30$1@charity.cs.utexas.edu>
In article <tc1C7.194$l57.1469@NewsReader>,
jimbo <jimbo@soundimages.co.uk> wrote:
>"Logan Shaw" <logan@cs.utexas.edu> wrote
>
>> If so, just do this:
>>
>> $foo =~ s/<b><li>/<li><b>/;
>> $foo =~ s/<i><li>/<li><i>/;
>
>This is broke. It is perfectly legal HTML to have
>
> <b
> >
> <li
> >
>
>and so on.
That's legal HTML, but the original poster explicitly said that "the
first tag only has three characters". So, I assumed they were editing
not arbitrary HTML, but HTML that they have some control over (or at
least know something about).
- Logan
--
"In order to be prepared to hope in what does not deceive,
we must first lose hope in everything that deceives."
Georges Bernanos
------------------------------
Date: Thu, 25 Oct 2001 22:08:28 -0400
From: "Matthew O. Persico" <persicom@acedsl.com>
Subject: Re: Stripping Duplicates From Arrays
Message-Id: <3BD8C59C.7010701@acedsl.com>
Joe Giordano wrote:
> I tried this but I got errors in my syntax on the line %temp = map ( { $_ =>
> 1 } @TMP); saying next 2 tokens.
>
> I am new at perl and actually going to class next week. But here is what I
> have
>
> after opening and reading the file:
>
> @TMP = split (/:/);
> %temp = map ( { $_ => 1 } @TMP);
> @TMP2=keys %temp;
>
> any help you could provide would be great.
>
> Thanks,
>
> Joe
>
> "Tom Renfro" <trenfro@i-55.com> wrote in message
> news:9r9e70$cag$1@news.datasync.com...
>
>>Joe,
>>
>>One possibility is using map() to put the array elements into a hash as
>>keys. This will eliminate duplication easily. For example,
>>
>>my @array = (1,2,4,65,2,1,4,2,1);
>>my %temp = map ( { $_ => 1 } @array );
Should be
my %temp = map {$_ => 1} @array;
>>my @uniquevalues = keys %temp;
>>
>>The intermediate line is required for the keys() function to see the
>>
> mapped
>
>>hash as a hash and not as list. I can't say if this is the most efficient
>>method or not.
>>
>>Hope this helps,
>>
>>-Tom
>>
>>"Joe Giordano" <joeg@optonline.net> wrote in message
>>news:PaWB7.6375$C7.2592557@news02.optonline.net...
>>
>>>I currently have a script that looks @ a dat file; each line of the dat
>>>
>>file
>>
>>>is split on a colon seperating the line into columns. Each column is
>>>
> then
>
>>>put into an array. I want to take out or ignore the duplicate variables
>>>
> in
>
>>>the array. I then use each variable in the first array in a loop (So
>>>unfortunatley each time the script uses the same variable I get the same
>>>results. What is the best way to achieve this.
>>>
>>>Thanks,
>>>
>>>Joe
>>>
>>>
>>>
>>
>
>
--
Matthew O. Persico
New York City - United We Stand
------------------------------
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 2014
***************************************