[29702] in Perl-Users-Digest
Perl-Users Digest, Issue: 946 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 17 21:09:43 2007
Date: Wed, 17 Oct 2007 18:09:10 -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 Wed, 17 Oct 2007 Volume: 11 Number: 946
Today's topics:
Change date on-the-fly <ldolan@thinkinghatbigpond.net.au>
Re: Change date on-the-fly <elvis-85473@notatla.org.uk>
Re: Change date on-the-fly <noreply@gunnar.cc>
Re: Creating Images cylurian@gmail.com
Re: Design Contest by NASA - Earthquake resistant build <tadmc@seesig.invalid>
dynamically creating labentry widgets with a subroutine <ben.rogers@gmail.com>
Re: Inline regex <nobull67@gmail.com>
Re: Inline regex <nobull67@gmail.com>
Re: jabba the tuh <zaxfuuq@invalid.net>
Re: jabba the tuh <zaxfuuq@invalid.net>
please help optimize sub QoS@domain.invalid
Re: printing a subject line <zaxfuuq@invalid.net>
Re: printing a subject line <cwilbur@chromatico.net>
Re: printing a subject line <bik.mido@tiscalinet.it>
Re: printing a subject line <zaxfuuq@invalid.net>
Re: printing a subject line <zaxfuuq@invalid.net>
Proper echoing of HTTP headers from LWP call ? <wheeledBob@yahoo.com>
Re: SCP putting file problem <elvis-85473@notatla.org.uk>
Re: Strong Blog CGI in Perl <emschwar@pobox.com>
Re: Using (?{}) code blocks and $^R (David Combs)
Re: variable bewilderingly becomes undefined <nobull67@gmail.com>
Re: variable bewilderingly becomes undefined <nobull67@gmail.com>
Re: variable bewilderingly becomes undefined <nobull67@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 17 Oct 2007 22:42:27 GMT
From: "Peter Jamieson" <ldolan@thinkinghatbigpond.net.au>
Subject: Change date on-the-fly
Message-Id: <ndwRi.681$CN4.143@news-server.bigpond.net.au>
Hi all,
I collect data from a web site at irregular intervals using a script
part of which is below. In the code snippet shown I manually
insert date values for $from_date and $to_date, save and close the
script then run it from the command line.
I would like to avoid the manual step of entering the $from_date and
$to_date
values, instead have the code determine them for me based on a couple of
rules:
1. The $to_date is always "yesterday" ie the day before the current date
2. The $from_date is always the day after the previous $to_date, that is
the $to_date used when the script was previously run....the idea being
as time passes to cover all dates.
For example if $from_date = '2007/10/13' and $to_date = '2007/10/15'
and the script was run then if I want to run the script today, 2007/10/18
I need the script to set $from_date = '2007/10/16' and $to_date =
'2007/10/17'
I *think* I need to store the most recently completed date range within the
script
somehow and then update it after each run or before each new but cannot see
how.
Hope this makes sense!....any suggestions appreciated...cheers, Peter
#!/usr/bin/perl -w
use strict;
use warnings;
use HTTP::Cookies;
use LWP;
use Time::Local;
use Win32::ODBC;
my($db) = new Win32::ODBC('expenses');
# YYYY/MM/DD format
my $from_date = '2007/10/13';
my $to_date = '2007/10/15';
my ($from_year, $from_mon, $from_day) = split('/', $from_date);
my ($to_year, $to_mon, $to_day) = split('/', $to_date);
my $from_datetime = timelocal(0,0,0,$from_day,$from_mon-1,$from_year);
my $to_datetime = timelocal(0,0,0,$to_day,$to_mon-1,$to_year);
# snipped rest of Perl script to collect data for the stipulated date
range......
------------------------------
Date: 17 Oct 2007 23:51:43 GMT
From: all mail refused <elvis-85473@notatla.org.uk>
Subject: Re: Change date on-the-fly
Message-Id: <slrnfhd7nk.lh8.elvis-85473@notatla.org.uk>
On 2007-10-17, Peter Jamieson <ldolan@thinkinghatbigpond.net.au> wrote:
> I would like to avoid the manual step of entering the $from_date and
> $to_date
> values, instead have the code determine them for me based on a couple of
> rules:
>
> 1. The $to_date is always "yesterday" ie the day before the current date
> 2. The $from_date is always the day after the previous $to_date, that is
> the $to_date used when the script was previously run....the idea being
> as time passes to cover all dates.
Use $^T as the time (in seconds) the script started executing.
Subtract 86400 to get yesterday.
Use gmtime() or localtime() if necessary to convert time-in-seconds to
human-readable values.
Store in some file (other than the script itself) a record of what times were
used during the previous execution.
--
Elvis Notargiacomo master AT barefaced DOT cheek
http://www.notatla.org.uk/goen/
------------------------------
Date: Thu, 18 Oct 2007 02:53:06 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Change date on-the-fly
Message-Id: <5nnp43FjalljU1@mid.individual.net>
all mail refused wrote:
> Use $^T as the time (in seconds) the script started executing.
A warning: When running under mod_perl, $^T contains the time when the
web server was started rather than when the script started executing.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 17 Oct 2007 13:18:02 -0700
From: cylurian@gmail.com
Subject: Re: Creating Images
Message-Id: <1192652282.697572.307690@z24g2000prh.googlegroups.com>
It's not for a webapp. I just have some perl code that creates math
problems, but the formatting always kills me. I have heard of LaTex
before for formating. Didn't know you can connect both together. I
will check your link. Thx.
On Oct 17, 11:33 am, Mirco Wahab <wa...@chemie.uni-halle.de> wrote:
> cylur...@gmail.com wrote:
> > I'm trying to print out math equations like, 1/x + 2/3x = 4 in html
> > via perl. The problem is the denominator and numerator look funny.
> > Not only fractions, but square roots. I want to know if there was an
> > easy tutorial on how to create images via perl. Maybe I might be able
> > to create a nicely formated equations by creating an image.
>
> Is this as part of a web app? If so (and you control
> the server), you coul'd go for the maximum impact
> and use a wrapper into Latex, like LaTeXRender.pm:http://www.tangentspace.net/cz/archives/2005/04/latexrender-perl-port
>
> Some time ago I wrote a mod_perl2 output filter that
> grabs [LaTex] $E = mc^2$ [/LaTex] pseudotags from the
> outgoing html stream, takes the content in between and
> sends this to the (heavily modified for my purposes:)
> LaTExRender.pm, which responds with a on-server link to
> a generated (and cached) image of the equation (or a
> complete TeX block); this <img> link is then inserted
> at the positon of the pseudotag.
>
> This works fine, e.g. here on a test accounthttp://phys.chemie.uni-halle.de/latex/sample.html
> (it works, but nobody uses it)
>
> Maybe thats the way to go?
>
> Regards
>
> M.
------------------------------
Date: Thu, 18 Oct 2007 01:00:48 GMT
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Design Contest by NASA - Earthquake resistant building
Message-Id: <slrnfhbrd1.ulv.tadmc@tadmc30.sbcglobal.net>
aanandkumaarvk@cooltoad.com <aanandkumaarvk@cooltoad.com> wrote:
> I am take part in a contest
What part does Perl play in this contest?
> The winning entry will be decided on various parameters, one of which
> is the number of views by other people. So, visit this link at least
> once.
I see that you are employing the same tactics used by pornographers
and con artists (spamming).
Aren't you worried that you will thus be painted with the same brush?
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Wed, 17 Oct 2007 21:37:34 -0000
From: "ben.rogers@gmail.com" <ben.rogers@gmail.com>
Subject: dynamically creating labentry widgets with a subroutine and getting right textvariable out
Message-Id: <1192657054.299044.192020@v29g2000prd.googlegroups.com>
Howdy,
I have a few LabEntry widgets that do similar things so I thought I
would create them with a sub and pass params to it. As you can see, I
pass filetypes4bin to the sub and it displays the list of file types
ok. However, when the user edits the entry field --say to add a few
more filetypes to look for--the textvariable is not updated.
1: How do I get the user modified textvariable out of the sub.
2: How do I keep the params I pass from breaking validatecommand.
$_[1] use to work for checking user input, but now of course it's
getting the value of the label param.
thanks,
ben
$filetypes4bin = "gif|jpg|bmp";
createLabEntryForFileTypes($dircleanPanelToolsSub1, "Pipe-separated
list of file types:", $filetypes4bin);
# Parent, title, textvariable.
sub createLabEntryForFileTypes{
my $parentwidget = $_[0];
my $label = $_[1];
my $filetypes = $_[2];
$parentwidget -> LabEntry(
-label => $label,
-labelPack => [ "-side" => "left" ],
-textvariable => $filetypes,
-width => 50,
-background => 'white',
-validate => 'key',
-validatecommand => sub { $_[1] =~ /\w/i },
-invalidcommand => sub { $mw -> bell })
->pack(-side => 'bottom', -pady => 6);
&stdMsg ("Selected filetypes: $filetypes");
return $filetypes;
}
# aardvark!
------------------------------
Date: Wed, 17 Oct 2007 21:43:33 -0000
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: Inline regex
Message-Id: <1192657413.875498.289480@i38g2000prf.googlegroups.com>
On Oct 17, 12:05 pm, Abigail <abig...@abigail.be> wrote:
> _
> Michele Dondi (bik.m...@tiscalinet.it) wrote on VCLIX September MCMXCIII
> in <URL:news:lchah3l08lpr7c5urm8587qregtumsm6su@4ax.com>:
> <> On 16 Oct 2007 22:14:33 GMT, Abigail <abig...@abigail.be> wrote:
> <>
> <> >That's two lines!
> <> >
> <> > my ($desc) = map {local $_ = $_; s/\s+$//; $_} $line [7];
> <>
> <> I often use C<local $_> myself, but I'm somewhat wary about it since
> <> clpmisc informed me that it can be buggy with tied stuff, althoug I
> <> doubt that $line [7] will contain any.
>
> If $line [7] is tied, then you wouldn't know whether s/\s+$// actually
> removes trailing white space.
> General questions are usually not answerable if you have to account for
> all possibilities of tiedness and overloading.
> IMO, it's up to the implementor of the tie or overload methods to figure
> out how "normal things" should be handled - the user of the normal things
> shouldn't have to wonder whether something is tied or overloaded. (That
> would defeat the purpose of tie and overload).
All that is true but not not the point Michele was making.
local($_) does something different if @line is tied array from what it
does if @line is not tied. There is _nothing_ that the implementor of
the class tied(@line) can do about this.
http://groups.google.com/group/comp.lang.perl.misc/browse_frm/thread/85eb2aa2c9688c56/4ade11e9618f7b14
------------------------------
Date: Wed, 17 Oct 2007 21:46:15 -0000
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: Inline regex
Message-Id: <1192657575.112291.235520@v29g2000prd.googlegroups.com>
On Oct 17, 12:49 am, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> Michele Dondi wrote:
> > On 16 Oct 2007 22:14:33 GMT, Abigail <abig...@abigail.be> wrote:
>
> >> my ($desc) = map {local $_ = $_; s/\s+$//; $_} $line [7];
>
> Isn't that why it's better written
>
> my ($desc) = map { local *_ = \$_; s/\s+$//; $_ } $line[7];
> -----------------------------^----^
No 'cos that still modifies $line[7]
------------------------------
Date: Wed, 17 Oct 2007 18:22:39 -0700
From: "Wade Ward" <zaxfuuq@invalid.net>
Subject: Re: jabba the tuh
Message-Id: <PpCdnWEZGprUOovanZ2dnUVZ_o2vnZ2d@comcast.com>
"Michele Dondi" <bik.mido@tiscalinet.it> wrote in message
news:1mdah3lrvd71sgvojh0jp613hbc8b9h4k6@4ax.com...
> On Tue, 16 Oct 2007 17:27:59 GMT, "Jürgen Exner"
> <jurgenex@hotmail.com> wrote:
>
>>No, not confusing at all. After all ppl is clearly the abbreviation for
>>Private Pilot License. Although I have no idea what a PPL has possibly to
>>do
>>with this NG.
>>
>>Oh, and I believe in some baby talk it stands for 'people', too. Although
>
> Yeah, kidiots use it in that acceptation.
[form.]
--
wade ward
"Nicht verzagen, Bruder Grinde fragen."
------------------------------
Date: Wed, 17 Oct 2007 18:29:42 -0700
From: "Wade Ward" <zaxfuuq@invalid.net>
Subject: Re: jabba the tuh
Message-Id: <pJGdnRe5-_5tNYvanZ2dnUVZ_vOlnZ2d@comcast.com>
"Dr.Ruud" <rvtol+news@isolution.nl> wrote in message
news:fe3goi.1fo.1@news.isolution.nl...
> <insert a link to Rafael-being-in-our-Perl>
Finally got this:
#!/usr/bin/perl
use strict;
use warnings;
use Net::NNTP ();
use constant NUMBER_OF_ARTICLES => 1;
use constant GROUP_NAME => 'comp.lang.perl.misc';
use constant SERVER_NAME => 'newsgroups.comcast.net';
use constant NNTP_DEBUG => 0;
my $nntp = Net::NNTP->new(SERVER_NAME, 'Debug' => NNTP_DEBUG) or die;
my $USER = '';
my $PASS = '';
$nntp->authinfo($USER,$PASS) or die $!;
my($article_count, $first_article, $last_article) =
$nntp->group(GROUP_NAME) or die;
# Which XOVER fields contain Subject: and From:?
my $count = 0;
my %xover_fmt = map( ($_, $count++), @{ $nntp->overview_fmt or die} );
die unless exists $xover_fmt{'Subject:'};
my $subject_offset = $xover_fmt{'Subject:'};
my $from_offset = $xover_fmt{'From:'};
my(@xover, $start_article);
RETRIEVE: while ($#xover+1 < NUMBER_OF_ARTICLES and $last_article >=
$first_article) {
# How many articles do we need? Stop retrieving if we have enough
my $articles_required = NUMBER_OF_ARTICLES - ($#xover+1) or last
RETRIEVE;
# Fetch overview information for the articles
$start_article = $last_article - ($articles_required-1);
$start_article = $start_article > $first_article ? $start_article :
$first_article;
my $xover_query = $start_article == $last_article ?
$start_article :
[$start_article, $last_article];
my $xover_ref = $nntp->xover($xover_query) or die;
# Store headers for the articles we've retrieved
foreach (sort {$b <=> $a} keys %$xover_ref) {
push @xover, $xover_ref->{$_};
}
} continue {
# Move the pointer forward to fetch previous articles
$last_article = $start_article - 1;
}
# Disconnect from the NNTP server
$nntp->quit;
my $s4 = join("\n", map ($_->[$subject_offset],@xover)),"\n";
print STDOUT " s4 is $s4\n";
my @words = split " ", $s4;
print STDOUT " first word is $words[1]";
print STDOUT " third word is $words[3]";
$words[3] = reverse $words[3];
print STDOUT " third word is $words[3]\n";
#big finish
print STDOUT " $words[1] $words[2]";
print STDOUT " $words[3] \n";
__END__
Output is:
s4 is Re: jabba the tuh
first word is jabba third word is tuh third word is hut
jabba the hut
^^^^^^^
|
|
success
Thx all for help.
One question:
what is this warning telling me:
Useless use of a constant in void context at jabba1.pl line 57.
line 57 is:
my $s4 = join("\n", map ($_->[$subject_offset],@xover)),"\n";
--
wade ward
"Nicht verzagen, Bruder Grinde fragen."
------------------------------
Date: Thu, 18 Oct 2007 00:55:15 GMT
From: QoS@domain.invalid
Subject: please help optimize sub
Message-Id: <T9yRi.15082$fm1.8984@trnddc01>
Hello,
Are there ways to have this execute faster using hashes or map functions?
Any ideas on optimizing the following subroutine would be greatly appreciated.
Thanks
========================================================================
sub optimizeMePlease
{
my $input = $_[0];
my $return;
my @array = (
1.6931595338935, 5.07947860168049, 8.46579766946749,
11.8521167372545, 15.2384358050415, 18.6247548728285,
22.0110739406155, 25.3973930084025, 28.7837120761895,
32.1700311439765, 35.5563502117635, 38.9426692795505,
42.3289883473375, 45.7153074151245, 49.1016264829115,
52.4879455506985, 55.8742646184855, 59.2605836862725,
62.6469027540595, 66.0332218218465, 69.4195408896335,
72.8058599574205, 76.1921790252075, 79.5784980929945,
82.9648171607815, 86.3511362285685, 89.7374552963554,
93.1237743641424, 96.5100934319294, 100,
);
if ($input <= $array[0]) {
$return = 29;
}
else {
my $from = 1;
foreach my $to (10, 20, 29) {
if ($input <= $array[$to]) {
foreach my $index ($from..$to) {
if ($input <= $array[$index]) {
$return = $index;
last;
}
}
last;
}
$from += 10;
}
}
unless ($return) {
warn "Invalid input value: [$input]\nUsing default!$!";
$return = 29;
}
return ($return);
}
------------------------------
Date: Wed, 17 Oct 2007 15:01:24 -0700
From: "Wade Ward" <zaxfuuq@invalid.net>
Subject: Re: printing a subject line
Message-Id: <vaKdnZcR59yD5YvanZ2dnUVZ_tSknZ2d@comcast.com>
"Charlton Wilbur" <cwilbur@chromatico.net> wrote in message
news:87tzopkdte.fsf@mithril.chromatico.net...
>>>>>> "WW" == Wade Ward <zaxfuuq@invalid.net> writes:
>
> WW> This script has tested ok on its ability to grab a usenet
> WW> message. Now I want to do soemthing with the subject, and I
> WW> don't see where I go wrong. I think I get the subject into my
> WW> $string with: my $string1 = $_->[$subject_offset]; Perl.exe
> WW> says $string1 is unitialized in the ultimate print statement.
> WW> What gives?
>
> I recommend running it under the debugger to find out. In particular,
> you will be able to determine precisely whether you get the subject
> into $string1 (which probably ought to be called, you know, $subject).
Thanks for your reply and what a fantastic tool! That tutorial brought me
about 75% there on this problem. With the script as:
#!/usr/bin/perl
use strict;
use warnings;
use Net::NNTP ();
use constant NUMBER_OF_ARTICLES => 1;
use constant GROUP_NAME => 'comp.lang.perl.misc';
use constant SERVER_NAME => 'newsgroups.comcast.net';
use constant NNTP_DEBUG => 0;
my $nntp = Net::NNTP->new(SERVER_NAME, 'Debug' => NNTP_DEBUG) or die;
my $USER = '';
my $PASS = '';
$nntp->authinfo($USER,$PASS) or die $!;
my($article_count, $first_article, $last_article) = $nntp->group(GROUP_NAME)
or die;
# Which XOVER fields contain Subject: and From:?
my $count = 0;
my %xover_fmt = map( ($_, $count++), @{ $nntp->overview_fmt or die} );
die unless exists $xover_fmt{'Subject:'};
my $subject_offset = $xover_fmt{'Subject:'};
my $from_offset = $xover_fmt{'From:'};
my(@xover, $start_article);
RETRIEVE: while ($#xover+1 < NUMBER_OF_ARTICLES and $last_article >=
$first_article) {
# How many articles do we need? Stop retrieving if we have enough
my $articles_required = NUMBER_OF_ARTICLES - ($#xover+1) or last
RETRIEVE;
# Fetch overview information for the articles
$start_article = $last_article - ($articles_required-1);
$start_article = $start_article > $first_article ? $start_article :
$first_article;
my $xover_query = $start_article == $last_article ?
$start_article :
[$start_article, $last_article];
my $xover_ref = $nntp->xover($xover_query) or die;
# Store headers for the articles we've retrieved
foreach (sort {$b <=> $a} keys %$xover_ref) {
push @xover, $xover_ref->{$_};
}
} continue {
# Move the pointer forward to fetch previous articles
$last_article = $start_article - 1;
}
# Disconnect from the NNTP server
$nntp->quit;
my $subject = $_->[$subject_offset];
print join("\n", map ($_->[$subject_offset].' from '.$_->[$from_offset],
@xover)),"\n";
print $subject ;
__END__
, how do I use the debugger to see the value of $subject?
http://www.zaxfuuq.net/perl10.htm
--
wade ward
"Nicht verzagen, Bruder Grinde fragen."
------------------------------
Date: 17 Oct 2007 17:20:16 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: printing a subject line
Message-Id: <87zlyhigkv.fsf@mithril.chromatico.net>
>>>>> "WW" == Wade Ward <zaxfuuq@invalid.net> writes:
WW> Thanks for your reply and what a fantastic tool! That
WW> tutorial brought me about 75% there on this problem. With the
WW> script as: [snip]
WW> , how do I use the debugger to see the value of $subject?
My pager indicates that the section of perldoc perldebtut that covers
the use of the debugger is approximately 20% into the document.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Thu, 18 Oct 2007 01:09:11 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: printing a subject line
Message-Id: <la5dh3t7qnrv56d4rl9to2mmuvrngphrqd@4ax.com>
On Wed, 17 Oct 2007 15:01:24 -0700, "Wade Ward" <zaxfuuq@invalid.net>
wrote:
># Disconnect from the NNTP server
>$nntp->quit;
>
>my $subject = $_->[$subject_offset];
Due to severe lack of time, I didn't read the whole code, but that
looks suspiscious: what is $_ at that point?!? Why should it contain
an arrayref? Suspect: didn't you by any chance think you're in a
C<for> loop or other construct creating an alias to $_, when in fact
you're not?
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Wed, 17 Oct 2007 17:25:11 -0700
From: "Wade Ward" <zaxfuuq@invalid.net>
Subject: Re: printing a subject line
Message-Id: <PbmdnVcvhoFPBIvanZ2dnUVZ_uOmnZ2d@comcast.com>
"Michele Dondi" <bik.mido@tiscalinet.it> wrote in message
news:la5dh3t7qnrv56d4rl9to2mmuvrngphrqd@4ax.com...
> On Wed, 17 Oct 2007 15:01:24 -0700, "Wade Ward" <zaxfuuq@invalid.net>
> wrote:
>
>># Disconnect from the NNTP server
>>$nntp->quit;
>>
>>my $subject = $_->[$subject_offset];
>
> Due to severe lack of time, I didn't read the whole code, but that
> looks suspiscious: what is $_ at that point?!? Why should it contain
> an arrayref? Suspect: didn't you by any chance think you're in a
> C<for> loop or other construct creating an alias to $_, when in fact
> you're not?
On the one hand, a background in C is good for learning perl, OTOH, not so
much.
I kept on whittling down the output until I got what I wanted. The debugger
was a huge help. When I got nothing for
my $subject =$_->[$subject_offset]
, when I typed p $subject1 in the debugger, then I was in hot pursuit of a
soln.
The end of the script now looks like:
my $subject1 = "tja\n";
my $s2 = join("\n", map ($_->[$subject_offset].'f
'.$_->[$from_offset],@xover)),"\n";
my $s3 = join("\n", map ($_->[$subject_offset].'f ',@xover)),"\n";
my $s4 = join("\n", map ($_->[$subject_offset],@xover)),"\n";
print join("\n", map ($_->[$subject_offset].' from '.$_->[$from_offset],
@xover)),"\n";
print $subject1;
print STDOUT " s2 is $s2\n";
print STDOUT " s3 is $s3\n";
print STDOUT " s4 is $s4\n";
__END__
, and the output is:
Re: printing a subject line from Michele Dondi <bik.mido@tiscalinet.it>
tja
s2 is Re: printing a subject linef Michele Dondi <bik.mido@tiscalinet.it>
s3 is Re: printing a subject linef
s4 is Re: printing a subject line
^^^^
|
|
success
Thx Charlton & Michele for help. A couple questions:
Q1) What is map doing here:
my $s2 = join("\n", map ($_->[$subject_offset].'f
'.$_->[$from_offset],@xover)),"\n";
Q2) What is the first newline doing in the join here:
my $s4 = join("\n", map ($_->[$subject_offset],@xover)),"\n";
--
wade ward
"Nicht verzagen, Bruder Grinde fragen."
------------------------------
Date: Wed, 17 Oct 2007 17:40:40 -0700
From: "Wade Ward" <zaxfuuq@invalid.net>
Subject: Re: printing a subject line
Message-Id: <G5udnVQd3JHvAIvanZ2dnUVZ_rOqnZ2d@comcast.com>
"Michele Dondi" <bik.mido@tiscalinet.it> wrote in message
news:la5dh3t7qnrv56d4rl9to2mmuvrngphrqd@4ax.com...
> On Wed, 17 Oct 2007 15:01:24 -0700, "Wade Ward" <zaxfuuq@invalid.net>
> Due to severe lack of time, I didn't read the whole code, but that
> looks suspiscious: what is $_ at that point?!? Why should it contain
> an arrayref? Suspect: didn't you by any chance think you're in a
> C<for> loop or other construct creating an alias to $_, when in fact
> you're not?
Oh, and since you mention C and presumably know more Italian than I, can you
help me translate this:
Wade Ward ha scritto:
> [repost]
> [snipped from elsewhere]
>
>
>>> I can't see how to cast an integer to a pointer.
>>>
>
>
>> You can't. Fortran doesn't do that - not even with the C interop stuff.
>> Of course,you can always play around with TRANSFER, but recall that the
>> standard says that the resulting values are undefined when you type
>> cheat with TRANSFER. And you can do it in C.
>>
>
> You can't do it portably in C, either. I believe you can memcpy() in
> to an (unsigned char *) and back again. If sizeof(int) >= sizeof(void*)
> you might be able to do the cast, but the use of the value of the
> int is non-portable. Those writing large model x86 code, and
> who try to do such casts, know all about this one.
>
>
>>> cptr = C_PTR(p+1)
>>>
>
>
>> I suppose you are trying to use a structure constructor here. You can't
>> do that with C_PTR as it has (intentionally) private components. The
>> whole point of private components is to keep you from fiddling with the
>> innards. You can't write a structure constructor for a private component
>> - you don't even know what the components are. Now maybe you know what a
>> C pointer better look like inside, but accordingh to the Fortran
>> compiler, you don't know.
>>
>
> From K&R2 (close, but not exactly, the C89 standard) A6.6:
>
> "Certain other conversions involving pointers and integers are
> permitted, but have implementation defined aspects. They must
> be specified by an explicit type-conversion operator, or cast."
>
Ovvero, per esempio, se
void* pippo;
long pluto;
Puoi assegnare pluto a pippo, ma con un recast di pluto:
pippo=(void*)pluto;
> "A pointer may be converted to an integral type large enough to
> hold it; the required size is implementation-dependent. The
> mapping function is also implementation dependent."
>
Ovvero, puoi assegnare il valore di un pointer ad una variabile
pluto=(long)pippo;
ma la variabile deve potere contenere il valore del pointer: se il
pointer e' un 32bit, occore
usare un tipo da 32 bit almeno... questo dipende dall' architettura del
processore.
Su un processore a 16bit, con 16bit di indirizzamento, un pointer e' un
16bit e basta un int.
Su processore a 32bit con 32bit di indirizzo ci vuole un tipo da 32bit
(di solito ma non
necessariamente, un long: basterebbe un int ma su alcuni 32bit, gli int
possono essere a 16bit..)
> "An object of integral type may be explicitly converted to a
> pointer. The mapping always carries a sufficiently wide integer
> converted from a pointer back to the same pointer, but is
> otherwise implementation-dependent."
>
>
Vedi sopra; Puoi assegnare pluto a pippo, ma con un recast e pluto deve
avere la stessa dimensione
fisica di pippo (se pippo e' 32bit, pluto deve essere almeno da 32bit,
salvo casi particolari ;-) )
pippo=(void*)pluto;
>
Può qualcuno che conosca questo soggetto commentare il suddetto?
A questo uno potrebbe chiedersi il perche' di tutte queste cose....
In realta' lo scambio interi/pointers ha solo alcune applicazioni
abbastanza particolari e non dovrebbe essere abusato.
Quella che mi viene in mente e' la gestione di hardware, con mappe
di indirizzi espresse in valori interi che poi vengono assegnate
a puntatori...
Ad ogni modo, queste operazioni sono molto legare al tipo di architettura
della CPU, alla dimensione dei tipi e quindi *poco* portabili, per cui.....
wade@zaxfuuq.net .
--
wade ward
"Nicht verzagen, Bruder Grinde fragen."
------------------------------
Date: Thu, 18 Oct 2007 00:51:48 GMT
From: still me <wheeledBob@yahoo.com>
Subject: Proper echoing of HTTP headers from LWP call ?
Message-Id: <v0bdh3114s3u3gdsc1fadh72ualpem69un@4ax.com>
I am pulling a web page (form) from a remote source, then echoing them
back to the caller. I use LWP for the call and then just print back
the headers as a string. I am having some issues with the headers back
in the calling browser (like the content type header not being
recognized. I am wondering if there is a perl subtlety I am missing
here that makes my approach incorrect:
my $browser = LWP::UserAgent->new;
$browser->agent("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1;
SV1; .NET CLR 1.1.4322)");
my $url = 'https://www.example.com/someform.htm';
my $response = $browser->post( $url,[ %postParams ]);
my $allHeaders = $response->headers->as_string;
print $allHeaders;
print $response->content;
Thanks,
------------------------------
Date: 17 Oct 2007 23:54:45 GMT
From: all mail refused <elvis-85473@notatla.org.uk>
Subject: Re: SCP putting file problem
Message-Id: <slrnfhd7t5.lh8.elvis-85473@notatla.org.uk>
On 2007-10-17, Paul <rev_1318@hotmail.com> wrote:
>> and copy "id_dsa" to (on the server side) ".ssh/authorized_keys" .
>
> You mean id_dsa.pub :)
>
> I wouldn't like it if anyone had my private key...
Right.
--
Elvis Notargiacomo master AT barefaced DOT cheek
http://www.notatla.org.uk/goen/
------------------------------
Date: Wed, 17 Oct 2007 14:30:29 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Strong Blog CGI in Perl
Message-Id: <874pgpmql6.fsf@pobox.com>
Izidoor <izidoor@invalid.com> writes:
> Also, why not, LiveJournal, but, really, I don't see where their
> LiveJournal Server is downloadable from their site :
> http://www.livejournal.com/site/. Do you have URL ?
I don't mean to be critical here, but about 5 seconds with google
(searching for "livejournal server") gives these top two links:
http://www.livejournal.com/doc/server/index.html
http://www.livejournal.com/code/
It's a bit silly to complain you can't find the code when you don't
even make that basic effort.
-=Eric
------------------------------
Date: Thu, 18 Oct 2007 00:32:10 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: Using (?{}) code blocks and $^R
Message-Id: <ff69ia$hi1$1@reader1.panix.com>
Man, am I out of date (or maybe just blind to the doc!).
Really briefly, just a quick overview, what are these two
things, and where do they seem to be useful?
Also, in what version did they or each first appear?
THANKS!
David
------------------------------
Date: Wed, 17 Oct 2007 21:12:41 -0000
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: variable bewilderingly becomes undefined
Message-Id: <1192655561.496763.324730@v23g2000prn.googlegroups.com>
On Oct 17, 3:26 pm, Taylor Venable <tay...@metasyntax.net> wrote:
> a "max" function,
> defined as:
>
> sub max($) {
Any reason you don't use the standard List::Utils::max()?
------------------------------
Date: Wed, 17 Oct 2007 21:21:13 -0000
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: variable bewilderingly becomes undefined
Message-Id: <1192656073.006632.305930@k35g2000prh.googlegroups.com>
On Oct 17, 2:54 pm, Taylor Venable <tay...@metasyntax.net> wrote:
> So it seems that $timeMax is suddenly undef'd while inside the loop.
What reason do you have to suspect it was ever defined?
Please see the posting guidelines for this group.
------------------------------
Date: Wed, 17 Oct 2007 21:26:30 -0000
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: variable bewilderingly becomes undefined
Message-Id: <1192656390.424828.64160@v23g2000prn.googlegroups.com>
On Oct 17, 3:26 pm, Taylor Venable <tay...@metasyntax.net> wrote:
> That is one of the things that confounds me: it is local to the subroutine
> in which this all occurs (declared with "my"), it is only assigned once,
> and it is not a reference. The value is the result of a "max" function,
> defined as:
>
> sub max($) {
> my $list = shift;
> my $max = $$list[0];
> foreach my $elt (@$list) {
> $max = $elt if ($elt > $max);
> }
> return $max;
>
> }
>
> The definition of timeMax is:
>
> my $timeMax = max(\@timing); # where @timing contains the timing data
>
> So I don't think this should be making timeMax a refernce, should it?
What do references have to do with the price of fish?
$timeMax is undef. This will happen if @timing is empty (or indeed if
one element of @timing is undef and all the rest are negative, or...).
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 946
**************************************