[23351] in Perl-Users-Digest
Perl-Users Digest, Issue: 5570 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 26 14:07:53 2003
Date: Fri, 26 Sep 2003 11:06:40 -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 Fri, 26 Sep 2003 Volume: 10 Number: 5570
Today's topics:
Re: choose from duplicate hash keys <phddas@yahoo.com>
Re: choose from duplicate hash keys <phddas@yahoo.com>
Re: choose from duplicate hash keys <phddas@yahoo.com>
Re: Compiling perl with GCC <Juha.Laiho@iki.fi>
dim (rab)
Re: dim <jurgenex@hotmail.com>
Re: Evals, quotes and backslashes problem (Bill)
Find what is in array1 and not in array2 (The Poor)
Re: Find what is in array1 and not in array2 <postmaster@castleamber.com.invalid>
hash reference as a hash key (Steve)
Re: Help; Pattern Matching (MJS)
Re: Help; Pattern Matching <noreply@gunnar.cc>
Re: How to go up trace stack in debugger? <jill_krugman@yahoo.com>
Inherit file descriptors from parent process? (James Thornton)
Re: Is there a quick way to check if a scalar contains <xx087@freenet.carleton.ca>
Re: LWP::Simple get() problem <mbudash@sonic.net>
Re: Mapping characters in a string (Alfred von Campe)
New FAQ: How do I compute the difference of two arrays? (The Poor)
Re: New FAQ: How do I compute the difference of two arr <grazz@pobox.com>
Obtain Connection Duration <mikeflan@earthlink.net>
perlcn (fabre)
Re: perlcn <postmaster@castleamber.com.invalid>
Re: Someone abusing moderator priveledge? <kkeller-usenet@wombat.san-francisco.ca.us>
Re: Someone abusing moderator priveledge? <peter@semantico.com>
Re: Someone abusing moderator priveledge? <tom@nosleep.net>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 27 Sep 2003 01:31:51 +1000
From: JohnWalter <phddas@yahoo.com>
Subject: Re: choose from duplicate hash keys
Message-Id: <3F745BE7.9000901@yahoo.com>
Matija Papec wrote:
> On Fri, 26 Sep 2003 18:01:25 +1000, JohnWalter <phddas@yahoo.com>
> wrote:
>
>
>>delete the rest with their rows from the file.
>>the first column is a uniqe data so it can be considerd a key.
>>
>>can some one give me a hint
>>
>>I am thinking this way
>>
>>open DATA, $file or die $!;
>>while (<DATA>) {
>> my ($key, @value) = split;
>> $table{$key}++;
>>}
>>then I am not thinkg right.. what is the value for each key? how can
>>this be done. print a list of duplicate and get to choose which to keep
>>and delete the rest.
>
>
> Post some lines from your $file and show what you want as final
> result.
>
a1
1
2
6
a2
8
7
4
a2
7
8
0
a3
0
0
2
b4
8
99
8
b4
0
0
0
b4
0
0
1
c7
6
5
3
I then need to choose which line of data from any duplicate records I
would like to keep and delete the rest. so
1: a2 8 7 4
2: a2 7 8 0
please enter the line number you want to keep: 2
b4
8
99
8
b4
0
0
0
b4
0
0
1
please enter the line number you want to keep: 1
------------------------------
Date: Sat, 27 Sep 2003 01:47:20 +1000
From: JohnWalter <phddas@yahoo.com>
Subject: Re: choose from duplicate hash keys
Message-Id: <3F745F88.7090702@yahoo.com>
JohnWalter wrote:
> Matija Papec wrote:
>
>> On Fri, 26 Sep 2003 18:01:25 +1000, JohnWalter <phddas@yahoo.com>
>> wrote:
>>
>>
>>> delete the rest with their rows from the file.
>>> the first column is a uniqe data so it can be considerd a key.
>>>
>>> can some one give me a hint
>>>
>>> I am thinking this way
>>>
>>> open DATA, $file or die $!;
>>> while (<DATA>) {
>>> my ($key, @value) = split;
>>> $table{$key}++;
>>> }
>>> then I am not thinkg right.. what is the value for each key? how can
>>> this be done. print a list of duplicate and get to choose which to
>>> keep and delete the rest.
>>
>>
>>
>> Post some lines from your $file and show what you want as final
>> result.
>>
>
>
> a1 1 2 6
> a2 8 7 4
> a2 7 8 0
> a3 0 0 2
> b4 8 99 8
> b4 0 0 0
> b4 0 0 1
> c7 6 5 3
>
> I then need to choose which line of data from any duplicate records I
> would like to keep and delete the rest. so
> 1: a2 8 7 4
> 2: a2 7 8 0
> please enter the line number you want to keep: 2
> b4 8 99 8
> b4 0 0 0
> b4 0 0 1
> please enter the line number you want to keep: 1
>
here is my brain dump
open DATA, $from_file or die $!;
my %duple;
while (<DATA>) {
my ($key, @value) = split;
$duple{$key}++;
}
my @duple_line;
my $lineno = 0;
for my $k ( keys %duple ) {
if ($duple{$k} > 1) {
while (<DATA>) {
my @line = split;
if ($k = shift @line ) {
$duple_line[$lineno] = [ split ];
$lineno++;
}
}
}
}
------------------------------
Date: Sat, 27 Sep 2003 03:00:13 +1000
From: JohnWalter <phddas@yahoo.com>
Subject: Re: choose from duplicate hash keys
Message-Id: <3F74709D.8090807@yahoo.com>
JohnWalter wrote:
> JohnWalter wrote:
>
>> Matija Papec wrote:
>>
>>> On Fri, 26 Sep 2003 18:01:25 +1000, JohnWalter <phddas@yahoo.com>
>>> wrote:
>>>
>>>
>>>> delete the rest with their rows from the file.
>>>> the first column is a uniqe data so it can be considerd a key.
>>>>
>>>> can some one give me a hint
>>>>
>>>> I am thinking this way
>>>>
>>>> open DATA, $file or die $!;
>>>> while (<DATA>) {
>>>> my ($key, @value) = split;
>>>> $table{$key}++;
>>>> }
>>>> then I am not thinkg right.. what is the value for each key? how can
>>>> this be done. print a list of duplicate and get to choose which to
>>>> keep and delete the rest.
>>>
>>>
>>>
>>>
>>> Post some lines from your $file and show what you want as final
>>> result.
>>>
>>
>>
>> a1 1 2 6
>> a2 8 7 4
>> a2 7 8 0
>> a3 0 0 2
>> b4 8 99 8
>> b4 0 0 0
>> b4 0 0 1
>> c7 6 5 3
>>
>> I then need to choose which line of data from any duplicate records I
>> would like to keep and delete the rest. so
>> 1: a2 8 7 4
>> 2: a2 7 8 0
>> please enter the line number you want to keep: 2
>> b4 8 99 8
>> b4 0 0 0
>> b4 0 0 1
>> please enter the line number you want to keep: 1
>>
>
> here is my brain dump
>
> open DATA, $from_file or die $!;
> my %duple;
> while (<DATA>) {
> my ($key, @value) = split;
> $duple{$key}++;
> }
>
> my @duple_line;
> my $lineno = 0;
> for my $k ( keys %duple ) {
> if ($duple{$k} > 1) {
> while (<DATA>) {
> my @line = split;
> if ($k = shift @line ) {
> $duple_line[$lineno] = [ split ];
> $lineno++;
> }
> }
> }
> }
>
*****************here is my best brain dump so far *****************
my (%table, %duple);
open DATA, $from_file or die $!;
while (<DATA>) {
my ($key, @value) = split;
push @{ $table{$key} }, [ @value ];
$duple{$key}++;
}
for my $k (keys %duple) {
if ($duple{$k} > 1) {
for my $i ( 0 .. $#{$table{$k}} ) {
print $i+1, ": ", $k, " ", $table{$k}[$i], "\n"; #prints
ARRAY(0x8300a44) but needed is the actual array values. why not when it
is derefrenced correclty?
}
print "please enter the line number to keep\n";
chomp ( my $keep = <STDIN> );
#delete the rest of the lines from the file.squezzing my brain a
bit harder
}
}
------------------------------
Date: Fri, 26 Sep 2003 17:27:00 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: Compiling perl with GCC
Message-Id: <bl1snv$lc8$1@ichaos.ichaos-int>
Marcus <marcus@automint.co.uk> said:
>Anyway make test went through to the end. At which point I was told that
>I'd failed just one of the tests. I was advised to set LD_LIBRARY_PATH
>to include the build directory and then run ./perl harness.
>
>I did this and was hit with this report:-
>----------------------------------------------------------------------
>Failed test ../lib/Net/t/hostname.t Total 2 Fail 1 Failed 50.00%
>List of Failed 1
>
>41 tests and 410 tests skipped.
>Failed 1 out of 712 test scripts, 99.86% okay. 1/68623 subtests failed,
>100.00% Okay.
>----------------------------------------------------------------------
>
>I found a newsgroup featuring somebody who had exactly this test failed
>at 50% and they said that they fixed it by setting the reverse DNS up.
Ok. Then you should be able to trust that perl in itself is working.
>So what is the simplest way to set up the reverse DNS?
Perl as such does not require reverse DNS - and even though the test
failed, you should be able to install the compilation results.
So, just go on and install - as you've identified that the cause of
problem is not with perl, and doesn't cripple your environment.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
------------------------------
Date: 26 Sep 2003 09:45:07 -0700
From: richardbriggs@att.com (rab)
Subject: dim
Message-Id: <900b7105.0309260845.1f0b7895@posting.google.com>
is this the best way to grep a HUMONGUS file (>3000000 lines) for a
list of matching words within a perlscript?
(the file is too big to load into an array)
------------------------------------------------------
my @greplist=qw( var full error over repeats no_space );
my @all;
foreach (@greplist){
my @finds = `/usr/bin/grep $_ /var/adm/syslog`;
push(@all,@finds);
}
print @all;
------------------------------------------------------
------------------------------
Date: Fri, 26 Sep 2003 16:59:09 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: dim
Message-Id: <xf_cb.11207$Wd7.6576@nwrddc03.gnilink.net>
rab wrote:
> is this the best way to grep a HUMONGUS file (>3000000 lines) for a
> list of matching words within a perlscript?
>
> (the file is too big to load into an array)
>
> ------------------------------------------------------
> my @greplist=qw( var full error over repeats no_space );
> my @all;
>
> foreach (@greplist){
> my @finds = `/usr/bin/grep $_ /var/adm/syslog`;
You are forking an external process (not needed) for each word you are
looking for (not efficient) and scan the file once for every single word.
That means for your example data you are loading and processing the file 6
times!
Obviously for a file that size you want to load and process it only once.
> push(@all,@finds);
> }
>
> print @all;
Untested, only a sketch. Adding error checking is left as an excercise:
my @greplist=qw( var full error over repeats no_space );
my @all;
open F, '/var/adm/syslog';
while (<F>) { #we go through the file only once, line by line
for ($word = @greplist){ #in each line we check for every word
if (/$word/) { # if a word is found in this line then
push @all, $_; #push the line to the result list and
last; #go to the next line
}
}
print @all;
}
------------------------------
Date: 26 Sep 2003 08:49:48 -0700
From: wherrera@lynxview.com (Bill)
Subject: Re: Evals, quotes and backslashes problem
Message-Id: <239ce42f.0309260749.6ff8a473@posting.google.com>
Stefan <stefan@unfunked.org> wrote in message news:<bl1400$j3r$1@newsg3.svr.pol.co.uk>...
> Paul Burton wrote:
> > $a='$b="a_string"';
> > eval($a);
> > print $b;
> I think you want:
>
> $a = '$b="\\\\\\$a_var"';
>
> After the line above, $a contains:
> $b="\\\$a_var"
>
> Then, when this value is eval()ed, $b becomes
> \$a_var
This is an excellent example of why doublequotes " " are often
inferior to single quotes ' ' unless variable substitution is really
needed.
------------------------------
Date: 26 Sep 2003 08:52:53 -0700
From: a@job.mx.2y.net (The Poor)
Subject: Find what is in array1 and not in array2
Message-Id: <30bcc0c9.0309260752.1d1e44b9@posting.google.com>
In FAQ,
+
How do I compute the difference of two arrays? How do I compute the
intersection of two arrays?
Use a hash. Here's code to do both and more. It assumes that each
element is unique in a given array:
@union = @intersection = @difference = ();
%count = ();
foreach $element (@array1, @array2) { $count{$element}++ }
foreach $element (keys %count) {
push @union, $element;
push @{ $count{$element} > 1 ? \@intersection :
\@difference }, $element;
}
Note that this is the *symmetric difference*, that is, all
elements in
either A or in B but not in both. Think of it as an xor operation.
-
But it is not what I need. I need to find what in array1, but not in
array2. Can anyone show me how to do that?
If I just juse array1-union, then should that be the what I need? What
is the running time will be? 2(n+m)?
Currently I am using 2 for loops to compare anything in 1 to anything
in 2, that makes the running time n*m/2
------------------------------
Date: Fri, 26 Sep 2003 18:22:41 +0200
From: John Bokma <postmaster@castleamber.com.invalid>
Subject: Re: Find what is in array1 and not in array2
Message-Id: <1064593489.246515@halkan.kabelfoon.nl>
The Poor wrote:
> But it is not what I need. I need to find what in array1, but not in
> array2. Can anyone show me how to do that?
my %hash;
@hash2{ @array2 } = ();
my @notin2;
foreach my $el (@array1) {
push(@notin2, $el) unless exists $hash2{$el}; # O(1) look up
}
running time is O(max(n,m))
--
Kind regards, virtual home: http://johnbokma.com/ ICQ: 218175426
web site hints: http://johnbokma.com/websitedesign/
John I count my toes ~ one to ten ~ I meditate ~ and feel the Zen
------------------------------
Date: 26 Sep 2003 08:15:41 -0700
From: ineverlookatthis@yahoo.com (Steve)
Subject: hash reference as a hash key
Message-Id: <f0d57f86.0309260624.ddac26a@posting.google.com>
Dear folks
I have a data structure which is an array of hashes of hash
references.
I need to consider each element in turn and retrieve a related set of
values
from a hash of hashes of hashes.
The choppped-down code fragment below should give you the idea.
It seems to work as (I) expected, but what worries is me is that I
realise that I don't actually
understand what I am doing here. When I loop with $each_marker and
$eachDNA the variable I
pull out is a hash ref. I am then using that to provide the key to the
hashes. I could
use some unique component within each pointed-to hash; eg I could
refer
to $pcr_well{$each_marker->{'locus_id'}}{$eachDNA->{'sample_id'}}{plate}
rather than
$pcr_well{$each_marker}{$eachDNA}{plate}. However I would need to be
sure that each will always
point to a unique value and while that is true now, who knows how the
underlying db may change.
Is it safe/sensible to continue to do it like this, I suppose my real
concern is that I don't
have a mental image of what $each_marker and $eachDNA actually *are*
during these loops, will
they suddenly mutate on me ?!
Thanks for any thoughts and advice
foreach my $each_marker (@{$search_result{'markers'}}){
foreach my $eachDNA (@{$search_result{DNA}}){
$pcr_plate_position=$pcr_well{$each_marker}{$eachDNA}{plate};
$pcr_row= $pcr_well{$each_marker}{$eachDNA}{row};
$pcr_col= $pcr_well{$each_marker}{$eachDNA}{col};
print ROBOT qq!$myparams{'pcr_plate_type'}[0]\t
$pcr_plate_position\t$pcr_plate_barcode\t$row_sequence{$pcr_pl_type}[$pcr_row]$pcr_col\t$wash_or_not!;
print ROBOT qq!\t$step: $MM_vol ul $each_marker->{'locus_id'}
master mix into well for DNA $eachDNA->{'DNA'}
$eachDNA->{'Sample_id'}\n!;
}
}
------------------------------
Date: 26 Sep 2003 09:26:15 -0700
From: tabletdesktop@yahoo.com (MJS)
Subject: Re: Help; Pattern Matching
Message-Id: <f0171209.0309260826.35b660c3@posting.google.com>
tabletdesktop@yahoo.com (MJS) wrote in message news:<f0171209.0309252258.5853ea0f@posting.google.com>...
> The following is what I have and I can't figure out how to do it. I
> read faq and I don't get the output what I intent to. I am having
> difficulties with proper indentation and white/blank lines.
>
> User has to enter an integer. Depending on that, the pattern should be
> repeated the number of times the user specified. Everytime the pattern
> is repeated, there should be an increament somewhere in the pattern.
> The output is stored in a file.
>
> For example: the exact pattern with the spaces is
>
> "Can someone help
> me with
>
>
> problem number1 => "
>
> This pattern should be replaced by
> "This is
> solution
>
>
> number 1, <= "
>
> "This is
> solution
>
>
> number 2, <= "
>
> and so on depending on the user input.
> ========================================================
> use strict;
> my $number;
> my $pattern;
> my $replace;
> # data.txt is the file containing the text pattern
> open(OUTPUT,"> result.txt") or die("Couldn't open data.txt :$!");
>
> print "Please enter a positive integer for Address = ";
> chomp( my $number = <STDIN> );
>
> if ($number =~ tr/1-9// != length ($number)) {
> print "You did not enter an interger";
> }
>
> else {
> $pattern=~/Can someone help
> me with
>
>
> problem number1 =>/;
>
> $replace=~/"This is
> solution
>
>
> number /;
> while(<OUTPUT>){
> for (my $n=1; $n<=$number; $n++){
> s/$pattern/$replace."$n". '<='/gsm;
> }
> }
> }
> close(OUTPUT);
> ======================================
Any Help????????
------------------------------
Date: Fri, 26 Sep 2003 19:09:41 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Help; Pattern Matching
Message-Id: <bl1ruj$6vic2$1@ID-184292.news.uni-berlin.de>
MJS wrote:
> The following is what I have and I can't figure out how to do it. I
> read faq and I don't get the output what I intent to. I am having
> difficulties with proper indentation and white/blank lines.
I have a feeling that you're having difficulties with much more than
that... Actually, I was about to reply to your message before you
reposted after less than 10 hours, but I didn't know where to start,
so I didn't.
I think you need to both structure the problem better and learn some
more Perl before you are ready to accomplish what you are trying to
do. As far as I understand, the code you posted isn't even close to
what you say that you want the script to do.
Questions about well defined problems are welcome in this group, at
least as long as they are not FAQs, but requests for help, that in
effect would be equal to doing the whole work, are not.
To summarize, I think you need to do some homework before asking for
help here.
http://learn.perl.org/
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 26 Sep 2003 18:02:01 +0000 (UTC)
From: J Krugman <jill_krugman@yahoo.com>
Subject: Re: How to go up trace stack in debugger?
Message-Id: <bl1uup$ffi$1@reader2.panix.com>
In <dRXcb.26153$TM4.20289@pd7tw2no> peter@PSDT.com (Peter Scott) writes:
>In article <bkv2a0$ga9$1@reader2.panix.com>,
> J Krugman <jill_krugman@yahoo.com> writes:
>>
>>Here's a recurrent situation. I'm running a program in the debugger,
>>the program dies for some reason, and I want to inspect the scope
>>in which the current function was called. In other words, I want
>>to be able to climb up the stack trace and poke around there. How
>>can I do this?
>I got fed up
>with not being able to see lexical variables in the higher levels
>and added the 'y' command in 5.8.0, which does that. You'll need
>the PadWalker module from CPAN.
Thanks! I'll give it a go.
-Jill
------------------------------
Date: 26 Sep 2003 10:08:46 -0700
From: james@unifiedmind.com (James Thornton)
Subject: Inherit file descriptors from parent process?
Message-Id: <cabf0e7b.0309260908.28ecec97@posting.google.com>
How do you inherit the stdin and stdout file descriptors from a parent
process? Specifically, the following function "run_filters" forks and
calls several perl scripts via execvp.
One of the perl scripts needs to execute a virus scanner on the file
pointed to by the parent file descriptor, modifying the file as
needed. The virus scanner will be invoked via a system call where
$file is the file name associated with the file parent file
descriptor:
system $virus_binary $file;
// C program that forks and executes several
// Perl scripts via execvp
int run_filters(command* first, int fdin)
{
command* c;
for(c = first; c; c = c->next) {
pid_t pid;
int status;
int fdout;
fdout = mktmpfile();
if(fdout == -1)
return -QQ_WRITE_ERROR;
pid = fork();
if(pid == -1)
return -QQ_OOM;
if(pid == 0) {
if(close(0) == -1 ||
dup2(fdin, 0) != 0 ||
close(1) == -1 ||
dup2(fdout, 1) != 1)
exit(QQ_WRITE_ERROR);
execvp(c->argv[0], c->argv);
exit(QQ_INTERNAL);
}
if(waitpid(pid, &status, WUNTRACED) == -1)
return -QQ_INTERNAL;
if(!WIFEXITED(status))
return -QQ_INTERNAL;
if(WEXITSTATUS(status))
return -WEXITSTATUS(status);
close(fdin);
if(lseek(fdout, 0, SEEK_SET) != 0)
return -QQ_WRITE_ERROR;
fdin = fdout;
}
return fdin;
}
------------------------------
Date: 26 Sep 2003 16:56:00 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: Is there a quick way to check if a scalar contains non-alpha-numeric characters?
Message-Id: <slrnbn8rtt.5g5.xx087@smeagol.ncf.ca>
David K. Wall <usenet@dwall.fastmail.fm> wrote:
> Glenn Jackman <xx087@freenet.carleton.ca> wrote:
> > reject($username) unless $username =~ /^[A-Za-z\d]{4,10}$/;
> I think you mean /^[A-Za-z0-9]{4,10}$/ or maybe /^[[:alnum:]]{4,10}$/
Ah, the use of the [:alnum:] class would be the best solution, as it is
probably resistant to changes in locale or use of unicode.
--
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca
------------------------------
Date: Fri, 26 Sep 2003 16:34:23 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: LWP::Simple get() problem
Message-Id: <mbudash-ED0EFE.09342326092003@typhoon.sonic.net>
In article <3F744BBF.8A82419B@Sun.COM>,
Hon Guin Lee - Web Producer - SMI Marketing <Hon.Lee@Sun.COM> wrote:
> Hi,
>
> I am having problems with the following code, in which the get() function
> from the LWP::Simple is not
> retrieving any of the contents of the web page from the specified URL
> location on the associated web form.
>
> From the following code, it only outputs "Ok" on the web browser.
>
> The web browser I am currently using is Netscape version 4.79, and using Perl
> version 5.6.1, although the @INC
> points to Perl version 5.0.5 on the local web server which I am placing the
> html, and cgi files on.
>
> The question is that shouldn't print $page place the HTML content of the
> specified URL on the web browser, and
> in my case why doesn't this occur? This also relates all the similar
> functions within the LWP::Simple module
> such as getprint(), getstore(), and head().
>
> When I place the -w switch onto the perl interpreter initial line code, the
> following warnings are shown and
> the perl script doesn't compile and displays a server error on the web
> browser.
>
> ---------------------------------------------------------------------
> Unquoted string "lang" may clash with future reserved word at automation1.cgi
> line 26.
> Content-type: text/html
>
> Use of uninitialized value in concatenation (.) or string at automation1.cgi
> line 25.
> Use of uninitialized value in pattern match (m//) at
> /usr/local/perl5.6/lib/site_perl/5.6.1/LWP/Simple.pm line
> 292.
> Use of uninitialized value in print at automation1.cgi line 47.
>
> ---------------------------------------------------------------------
>
>
> If any one has a solution to this problem, reply back.
>
>
> ---------------------------------------------------------------------
> #!/usr/local/perl5.6/bin/perl
>
> # perl script to get remote
> # urls and strip them and
> # upload them to teamsite
>
> use LWP::Simple qw(!head);
> use CGI qw(:standard); # then only CGI.pm defines a head()
>
> my ($url, $lang, $page);
>
> $query = new CGI;
>
> print "Content-type: text/html\n\n";
>
> process_form();
> get_url($url);
>
> # Passes the data from the server,
> # and takes them onto the PERL script.
>
> sub process_form {
>
> $url = $query->param(url);
> $url = "http://" . $url;
> $lang = $query->param(lang);
>
> }
>
> # Retrieves the contents of the
> # specified URL.
>
> sub get_url {
>
> $page = get ($_);
>
> if ($page = undef) {
> print "Couldn't retrieve $url";
> }
> else {
> print "Ok";
> print $page;
> }
>
> }
> ---------------------------------------------------------------------
try this:
#----------------------------------------------
#!/usr/local/perl5.6/bin/perl
# perl script to get remote
# urls and strip them and
# upload them to teamsite
use strict;
use LWP::Simple qw(!head);
use CGI qw(:standard); # then only CGI.pm defines a head()
# not needed - you used ':standard'
#$query = new CGI;
print header();
my ($url, $lang) = process_form();
get_url($url);
#----------------------------------------------
sub process_form {
#
# Passes the data from the server,
# and returns them to the caller.
#----------------------------------------------
my $url = "http://" . param("url");
my $lang = param("lang");
return ($url, $lang);
}
#----------------------------------------------
sub get_url {
#
# Retrieves and prints the contents of the
# specified URL.
#----------------------------------------------
my $page = get(shift);
unless ($page) {
print "Couldnt retrieve $url";
}
else {
print "Ok\n";
print $page;
}
}
#----------------------------------------------
hth-
--
Michael Budash
------------------------------
Date: 26 Sep 2003 10:28:45 -0700
From: alfred@110.net (Alfred von Campe)
Subject: Re: Mapping characters in a string
Message-Id: <4d599f95.0309260928.3b94c270@posting.google.com>
Uri Guttman <uri@stemsystems.com> wrote:
> then show us your modifications. anything generally interesting? or was
> is just to your taste?
Nothing earth shattering. Just cosmetic things, and I put it all in a subroutine.
Alfred
------------------------------
Date: 26 Sep 2003 09:13:57 -0700
From: a@job.mx.2y.net (The Poor)
Subject: New FAQ: How do I compute the difference of two arrays?
Message-Id: <30bcc0c9.0309260813.31bdb9e@posting.google.com>
Here is my new code changed from the old code in FAQ.
Please add it to the perldoc for the next release of perl.
OLD:
+
How do I compute the difference of two arrays? How do I compute the
intersection of two arrays?
Use a hash. Here's code to do both and more. It assumes that each
element is unique in a given array:
@union = @intersection = @difference = ();
%count = ();
foreach $element (@array1, @array2) { $count{$element}++ }
foreach $element (keys %count) {
push @union, $element;
push @{ $count{$element} > 1 ? \@intersection :
\@difference }, $element;
}
Note that this is the *symmetric difference*, that is, all
elements in
either A or in B but not in both. Think of it as an xor operation.
-
New:
+
How do I compute the difference of two arrays? How do I compute the
intersection of two arrays?
Use a hash. Here's code to do both and more. It assumes that each
element is unique in a given array:
@union = @intersection = @in1notin2 = @in2notin1();
%count = ();
foreach $element (@array1) { $count{$element}++ }
foreach $element (@array2) { $count{$element}-- }
foreach $element (keys %count) {
push @union, $element;
push (@intersection, $element) if $count{$element} == 0;
push (@in1notin2, $element) if $count{$element} == 1;
push (@in2notin1, $element) if $count{$element} == -1;
}
-
2 Questions:
how to fix it when the array is not uniqu?
how to simplfy the last 3 lines using case, ?: or something else?
push @intersection, $element if $count{$element} == 0;
push @in1notin2, $element if $count{$element} == 1;
push @in2notin1, $element if $count{$element} == -1;
http://edealseek.com
------------------------------
Date: Fri, 26 Sep 2003 17:37:16 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: New FAQ: How do I compute the difference of two arrays?
Message-Id: <gP_cb.6283$541.1641@nwrdny02.gnilink.net>
The Poor <a@job.mx.2y.net> wrote:
> Here is my new code changed from the old code in FAQ.
> Please add it to the perldoc for the next release of perl.
This is a discussion group. FAQ patches (preferably in the form
of unified or context diffs) can be mailed to perlfaq-workers at
perl.org or posted from nntp.perl.org.
You should also include some rationale -- what's wrong with the
current answer? How is your proposed solution an improvement?
I'm not sure that it is an improvement, but you'll have to make
a case for it. (And fix the syntax error, etc.)
--
Steve
------------------------------
Date: Fri, 26 Sep 2003 15:38:06 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Obtain Connection Duration
Message-Id: <3F745E03.11FB40AE@earthlink.net>
I'm trying to obtain the DUN connection duration on my
Win2000 system that runs Netscape 4.72 (Mozilla).
I searched Google and CPAN, but could not locate
much, except that others are also looking for this capability.
If I was really smart, I might be able to strip it out of:
http://ei.kefro.st/projects/btrackalyzer/1.11/trackerlyze.pl.html
but I'm not that smart. Can anyone help?
Mike
------------------------------
Date: Fri, 26 Sep 2003 17:38:21 +0100
From: pedro.fabre.NO-SPAM@gen.gu.se (fabre)
Subject: perlcn
Message-Id: <pedro.fabre.NO-SPAM-2609031738210001@192.168.0.5>
Thanks to all,
Now I know where to look information about perl.
But reading http://www.perldoc.com/perl5.8.0/pod.html I saw a module
called perlcn (perldoc perlcn). What is this tutorial for? As I can not
decode it. It is not easy to guess what is going about.
Thanks to all for your help
P
------------------------------
Date: Fri, 26 Sep 2003 18:42:10 +0200
From: John Bokma <postmaster@castleamber.com.invalid>
Subject: Re: perlcn
Message-Id: <1064594658.266131@halkan.kabelfoon.nl>
fabre wrote:
> Thanks to all,
>
>
> Now I know where to look information about perl.
>
> But reading http://www.perldoc.com/perl5.8.0/pod.html I saw a module
> called perlcn (perldoc perlcn). What is this tutorial for? As I can not
> decode it. It is not easy to guess what is going about.
Google for euc-cn resulted in:
"Chinese euc-cn Charset Conversion Component"
So I think it has something to do with "Chinese"
--
Kind regards, virtual home: http://johnbokma.com/ ICQ: 218175426
web site hints: http://johnbokma.com/websitedesign/
John I count my toes ~ one to ten ~ I meditate ~ and feel the Zen
------------------------------
Date: Fri, 26 Sep 2003 08:30:26 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Someone abusing moderator priveledge?
Message-Id: <i2m1lb.1hf.ln@goaway.wombat.san-francisco.ca.us>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message
On 2003-09-26, Tom <tom@nosleep.net> wrote:
> I answered someone's post in comp.lang.perl.moderated and I followed the
> guidlines.
> However, my post was not posted.
> I think one of the local cops in this group might be overstepping his
> boundaries and not posting my posts because of disagreements here.
> I'm certainly going to write to the proper people and find out, because if
> my posts follow the rules and it is purely personal, I'm going to see to it
> that priveledge is revoked.
> I might be wrong, but I'm going to find out.
Perhaps it might have been better to find out before posting unfounded
accusations?
--keith
--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAj90W48ACgkQhVcNCxZ5ID9InwCgmVph9okC41nLSo+btwJhJUC7
bY0AmwQgJu3s8psh2D8If9o0QjbYC/f6
=rq22
-----END PGP SIGNATURE-----
------------------------------
Date: Fri, 26 Sep 2003 16:48:58 +0100
From: Peter Hickman <peter@semantico.com>
Subject: Re: Someone abusing moderator priveledge?
Message-Id: <3f745feb$0$24124$afc38c87@news.easynet.co.uk>
Tom wrote:
> "Peter Hickman" <peter@semantico.com> wrote in message
> news:3f74053e$0$24112$afc38c87@news.easynet.co.uk...
>
>>Tom wrote:
>>
>>>I think one of the local cops in this group might be overstepping his
>>>boundaries and not posting my posts because of disagreements here.
>>
>>Do you honestly think that you are that important that people waste their
>
> time
>
>>keeping track of you?
>>
>>You are delusional.
>>
>
>
> It has nothing to do with that. It has to do with a clueless child being in
> a position they have no business being in.
> There happens to be an overabundance of such individuals in the world,
> otherwise we wouldn't have such fearful leaders currently in charge.
>
>
Let me get this straight:
World leaders are arses therefore a moderator of a newsgroup is picking on
you. Proof positive, case closed.
Who are you really? David Icke?
------------------------------
Date: Fri, 26 Sep 2003 08:58:34 -0700
From: "Tom" <tom@nosleep.net>
Subject: Re: Someone abusing moderator priveledge?
Message-Id: <3f746179$1@nntp0.pdx.net>
"Keith Keller" <kkeller-usenet@wombat.san-francisco.ca.us> wrote in message
news:i2m1lb.1hf.ln@goaway.wombat.san-francisco.ca.us...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
> NotDashEscaped: You need GnuPG to verify this message
>
> On 2003-09-26, Tom <tom@nosleep.net> wrote:
> > I answered someone's post in comp.lang.perl.moderated and I followed the
> > guidlines.
> > However, my post was not posted.
> > I think one of the local cops in this group might be overstepping his
> > boundaries and not posting my posts because of disagreements here.
> > I'm certainly going to write to the proper people and find out, because
if
> > my posts follow the rules and it is purely personal, I'm going to see to
it
> > that priveledge is revoked.
> > I might be wrong, but I'm going to find out.
>
> Perhaps it might have been better to find out before posting unfounded
> accusations?
>
> --keith
>
I did say I wasn't sure, but you are probably right I should have waited.
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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 5570
***************************************