[22404] in Perl-Users-Digest
Perl-Users Digest, Issue: 4625 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 26 03:06:50 2003
Date: Wed, 26 Feb 2003 00:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 26 Feb 2003 Volume: 10 Number: 4625
Today's topics:
Re: Can't set or access array element in struct <tore@aursand.no>
Re: compiling perlcc generated c code with gcc (Sisyphus)
Re: date::calc (Charles DeRykus)
Re: editting photos on the fly <sdyck@engr.uvic.ca.spam>
Re: editting photos on the fly <abigail@abigail.nl>
Re: FAQ proposal: Why can't I compare two strings using (Philip Lees)
Feedback request: photobrowser <asu1@c-o-r-n-e-l-l.edu>
Re: Feedback request: photobrowser <tassilo.parseval@post.rwth-aachen.de>
Help - Inserting '?' at empty places in a string of tab (David Tian)
Re: Help - Inserting '?' at empty places in a string of (Tad McClellan)
How to access proxy server for Perl Soap client (Sade Bhat Kalasabail)
NET::FTP cut my file ? <madbat28@hotmail.com>
Re: NET::FTP cut my file ? <tassilo.parseval@post.rwth-aachen.de>
Re: newbie regexp question <tore@aursand.no>
Re: Passing 2D arrays? <uri@stemsystems.com>
Re: Perl -- CGI and background process <goldbb2@earthlink.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 26 Feb 2003 03:14:09 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Can't set or access array element in struct
Message-Id: <pan.2003.02.26.02.09.35.901414@aursand.no>
On Tue, 25 Feb 2003 16:26:45 -0800, Carlton Brown wrote:
> I'm trying to prove to myself that Class::Struct works by creating the
> simplest possible working program using sample code directly from Page
> 336 of the Camel book.
Class::Struct might be nice, but have you looked at Class::MakeMethods? I
haven't used any of them, but the latter seems a lot more powerful.
Oh, well.
> print "His aliases are: ", join(", ", @{mage->aliases}), ".\n";
Should be '@{$mage->aliases}'.
^
--
Tore Aursand - tore@aursand.no - http://www.aursand.no/
------------------------------
Date: 25 Feb 2003 23:07:33 -0800
From: kalinabears@hdc.com.au (Sisyphus)
Subject: Re: compiling perlcc generated c code with gcc
Message-Id: <e615828f.0302252307.edb4620@posting.google.com>
stig <nospam_stigerikson@yahoo.se> wrote in message
>
>
>
> hi and thanks for the reply.
> just tried it, both with perl 5.6.1 and 5.8.0.
> first perlcc -c
> then gcc, both as described and with a Makefile with the switches included.
> and also by directly specifying the paths in the c-file on the
> include-lines.
>
> same result though.
>
> gcc reports:
> myprogram.o: In function `perl_init_aaaa':
> myprogram.c:3278: undefined reference to `Perl_Gthr_key_ptr'
> myprogram.c:3278: undefined reference to `Perl_Isv_undemake'
>
> and many more lines with messages like that.
>
Yes - looks like this is something different to what I'm finding. If I
don't link to libperl56.a I get a mass of undefined references, but
the two that you have specifically mentioned are *not* to be found in
that "mass".
>
> anyway, dont bother all to much, ill survive somehow.
No fears on that score. I don't think perlcc offers anything of
practical value.
But it can be fun to play with every now and then :-)
Cheers,
Rob
------------------------------
Date: Wed, 26 Feb 2003 04:20:18 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: date::calc
Message-Id: <HAwEpu.n2t@news.boeing.com>
In article <ghhf5vk039ah0cuvfohcej8q6ljld8a9p6@4ax.com>,
w i l l <will@com.yahoo> wrote:
>Is there a way of using date::calc or some other module to get the
>time format 20030215 (YYYYMMDD) into Feb 15 2003 ?
>
perl -MDate::Manip -le 'print UnixDate("20030215","%b %e %Y")'
--
Charles DeRykus
------------------------------
Date: Tue, 25 Feb 2003 19:20:04 -0800
From: Steve <sdyck@engr.uvic.ca.spam>
Subject: Re: editting photos on the fly
Message-Id: <3E5C3264.4FFE92FE@engr.uvic.ca.spam>
I didn't mean to offend anyone, I just didn't know where to start
looking. I googled for about a half hour before posting to several
other newsgroups that brought me here.
> What makes you think this group is the appropriate place to ask?
> Why don't you just mail the people from www.kicken.com?
They are just a host for the script, video clips and the like. I doubt
they would know how it worked.
> ;; the link was www.kicken.com. I'll warn you though. Your name will
> ;; appear on a sign that says "I love <your name>" which is in front of a
> ;; topless girl. be sure you are of legal age before going to the site.
>
> As opposed to having an 'illegal age'?
In North America, you have to be 18 (Canada) and 21 (most of the USA) to
access adult material. Is adult material accessible by all in the
Netherlands?
Steve
> Abigail
> --
> # Count the number of lines; code doesn't match \w. Linux specific.
> ()=<>;$!=$=;($:,$,,$;,$")=$!=~/.(.)..(.)(.)..(.)/;
> $;++;$*++;$;++;$*++;$;++;`$:$,$;$" $. >&$*`;
------------------------------
Date: 26 Feb 2003 07:56:04 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: editting photos on the fly
Message-Id: <slrnb5osok.5hg.abigail@alexandra.abigail.nl>
Steve (sdyck@engr.uvic.ca.spam) wrote on MMMCDLXVI September MCMXCIII in
<URL:news:3E5C3264.4FFE92FE@engr.uvic.ca.spam>:
<>
<> > ;; the link was www.kicken.com. I'll warn you though. Your name will
<> > ;; appear on a sign that says "I love <your name>" which is in front of a
<> > ;; topless girl. be sure you are of legal age before going to the site.
<> >
<> > As opposed to having an 'illegal age'?
<>
<> In North America, you have to be 18 (Canada) and 21 (most of the USA) to
<> access adult material. Is adult material accessible by all in the
<> Netherlands?
You certainly won't get send to prison if you see a picture of a topless
person while you're 15 years old.
What's the punishment for seeing a picture of a topless person while
you're younger than 21 in the USA?
Abigail
--
:$:=~s:$":Just$&another$&:;$:=~s:
:Perl$"Hacker$&:;chop$:;print$:#:
------------------------------
Date: Wed, 26 Feb 2003 07:52:07 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: FAQ proposal: Why can't I compare two strings using == ?
Message-Id: <3e5c7133.63440812@news.grnet.gr>
On Tue, 25 Feb 2003 11:52:32 +0100, "Tore Aursand" <tore@aursand.no>
wrote:
>On Tue, 25 Feb 2003 09:34:38 +0000, Philip Lees wrote:
>>> Unfortuately I can't think of a way to phrase the question.
>
>> How about: 'Why don't my equality tests work right?'
>
>I agree that this question should be answered in the FAQ, but I don't see
>this question as _one_ question.
You're right, of course, but as a long time lurker it seems to me that
when the question comes up here it almost _always_ refers to something
equivalent to:
if ( $foo = $bar ){
or
if ( $foo == $bar ){
not producing the expected result.
>The FAQ should rather try to answer something like "why don't my use of an
>operator work as expected" and then refer to 'perldoc perlop' and the use
>of 'use diagnostics'.
>
>However, this might be of no use to new users, as they don't know that
>they 'an operator' is what they're looking for an answer about. Or?
That was my thinking, too. Mind you, since nobody reads the FAQ before
posting maybe we're wasting our time.
Phil
--
Ignore coming events if you wish to send me e-mail
------------------------------
Date: 26 Feb 2003 05:39:14 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Feedback request: photobrowser
Message-Id: <Xns932E6A69562asu1cornelledu@132.236.56.8>
Hello:
I spent some time over the last few days, incorporating comments I
received on an earlier version of this script, and looking for more code
to steal :). Thanks to everyone who commented.
I now have a version of this script which works the way I would like on
my system: It displays links (with optional thumbnails) to all jpeg files
in a specified location in a table format (where the number of images per
row is determined by the template), along with an optional description of
each photo. Given my inexperience with Perl, I would appreciate comments
on how to improve the script, especially regarding security holes. I
would eventually like to use this script on my personal web pages, and I
would hate to cause trouble for my hosting service.
By the way, I am not sure the included code below is getting too long for
posting here. Should I just post a URL in the future?
=== BEGIN: photobrowser.pl
#!C:/Perl/bin/perl.exe -Tw
# photobrowser
# Display links (optionally with thumbnails and descriptions)
# to images in a directory
$|++;
use strict;
use diagnostics;
use CGI qw(:standard);
use HTML::Template;
use FileHandle;
use Config::Properties;
my $query = CGI::new();
my $location = $query->param("location");
$location = '' if !$location;
# See if location contains any relative paths
bail_out($location, 'Invalid location specified in request.')
if $location =~ /(\.\.)/;
# Configuration Variables
my %config = (
wwwroot => '',
script_location => '/cgi-bin/photobrowser.pl',
htdocs_path => 'C:/Program Files/Apache Group/Apache2/htdocs',
template_path => 'C:/Program Files/Apache Group/Apache2/templates',
template_file => 'photobrowser.tmpl.html',
thumb_dir => 'thumb',
descriptions => 'album',
default_description => '© 2003 A. Sinan Unur',
);
my $photo_path = "$config{htdocs_path}/${location}";
my $template = HTML::Template->new(
filename => "$config{template_path}/$config{template_file}");
# Provide some information during development
$template->param(HTDOCS => $config{htdocs_path});
$template->param(LOCATION => $location);
$template->param(PHOTO_PATH => $photo_path);
$template->param(DESC_FILE => "$photo_path/$config{descriptions}");
# get the list of images
opendir(PHOTO_DIR, $photo_path) || bail_out($photo_path);
my @files = grep { !/^\.+/ && /\.jpe?g$/i } readdir(PHOTO_DIR);
closedir PHOTO_DIR;
# get photo descriptions if possible
my $descriptions = Config::Properties->new();
my $desc_fh = new FileHandle("< $photo_path/$config{descriptions}");
if(defined $desc_fh) {
$descriptions->load($desc_fh);
undef $desc_fh;
}
my $title = $descriptions->getProperty('title');
$template->param(TITLE => ($title ? $title : $location));
# Use the technique described by Chris Davies at
# http://bluedot.net/mail/archive/read.php?f=9&i=2353&t=2345
# to deduce the number of photos to display per row
my $photos_per_row
= scalar grep { /^URL\d+$/i } $template->query (loop => 'PHOTO_LIST');
my @loop_data;
do {
my $counter = 0;
my $iter_data = {};
foreach my $file (@files) {
$iter_data->{'FILE'.($photos_per_row ? $counter : '')} = $file;
$iter_data->{'URL'.($photos_per_row ? $counter : '')}
= "$config{wwwroot}/$location/$file";
$iter_data->{'THUMB'.($photos_per_row ? $counter : '')}
= -e "$photo_path/$config{thumb_dir}/$file"
? "$config{wwwroot}/$location/$config{thumb_dir}/$file" : "";
my $desc = $descriptions->getProperty(lc($file));
$iter_data->{'DESC'.($photos_per_row ? $counter : '')}
= $desc ? $desc : $config{default_description};
$counter = ($counter + 1) % ($photos_per_row || 1);
if(!$counter) {
push(@loop_data, $iter_data);
$iter_data = {};
}
}
push(@loop_data, $iter_data) if scalar keys %$iter_data;
};
$template->param(PHOTO_LIST => \@loop_data);
print header, $template->output;
### SUBROUTINES
sub bail_out {
my $file = shift;
my $message = shift;
print header, $message;
die "$file: $!"; # goes to the webserver log
}
1;
__END__
=== END: photobrowser.pl
=== BEGIN: photobrowser.tmpl.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<title>Photo Browser - <TMPL_VAR TITLE></title>
</head>
<body>
<!-- provide some info during development -->
<p>HTDOCS: <TMPL_VAR HTDOCS></p>
<p>LOCATION: <TMPL_VAR LOCATION></p>
<p>PHOTO_PATH: <TMPL_VAR PHOTO_PATH></p>
<p>DESCRIPTIONS: <TMPL_VAR DESC_FILE></p>
<h1 align="center"><TMPL_VAR TITLE></h1>
<center>
<TMPL_IF PHOTO_LIST>
<table border="0" bgcolor="#ccccff" cellspacing="1" cellpadding="4">
<TMPL_LOOP PHOTO_LIST>
<tr valign="top">
<td align="center" bgcolor="white" width="140"><!-- PHOTO 0
--><a href="<TMPL_VAR URL0>"><!--
--><TMPL_IF THUMB0><!--
--><img border="0" src="<TMPL_VAR THUMB0>"
alt="<TMPL_IF DESC0><TMPL_VAR DESC0><TMPL_ELSE><TMPL_VAR
FILE0></TMPL_IF>"><!--
--><TMPL_ELSE><TMPL_VAR FILE0></TMPL_IF><!--
--></a>
<br>
<small><TMPL_IF DESC0><TMPL_VAR DESC0><TMPL_ELSE><TMPL_VAR FILE0>
</TMPL_IF></small>
</td>
<td align="center" bgcolor="white" width="140"><!-- PHOTO 1
--><a href="<TMPL_VAR URL1>"><!--
--><TMPL_IF THUMB1><!--
--><img border="0" src="<TMPL_VAR THUMB1>"
alt="<TMPL_IF DESC1><TMPL_VAR DESC1><TMPL_ELSE><TMPL_VAR
FILE1></TMPL_IF>"><!--
--><TMPL_ELSE><TMPL_VAR FILE1></TMPL_IF><!--
--></a>
<br>
<small><TMPL_IF DESC1><TMPL_VAR DESC1><TMPL_ELSE><TMPL_VAR FILE1>
</TMPL_IF></small>
</td>
<td align="center" bgcolor="white" width="140"><!-- PHOTO 2
--><a href="<TMPL_VAR URL2>"><!--
--><TMPL_IF THUMB2><!--
--><img border="0" src="<TMPL_VAR THUMB2>"
alt="<TMPL_IF DESC2><TMPL_VAR DESC2><TMPL_ELSE><TMPL_VAR
FILE2></TMPL_IF>"><!--
--><TMPL_ELSE><TMPL_VAR FILE2></TMPL_IF><!--
--></a>
<br>
<small><TMPL_IF DESC2><TMPL_VAR DESC2><TMPL_ELSE><TMPL_VAR FILE2>
</TMPL_IF></small>
</td>
<td align="center" bgcolor="white" width="140"><!-- PHOTO 3
--><a href="<TMPL_VAR URL3>"><!--
--><TMPL_IF THUMB3><!--
--><img border="0" src="<TMPL_VAR THUMB3>"
alt="<TMPL_IF DESC3><TMPL_VAR DESC3><TMPL_ELSE><TMPL_VAR
FILE3></TMPL_IF>"><!--
--><TMPL_ELSE><TMPL_VAR FILE3></TMPL_IF><!--
--></a>
<br>
<small><TMPL_IF DESC3><TMPL_VAR DESC3><TMPL_ELSE><TMPL_VAR FILE3>
</TMPL_IF></small>
</td>
</tr>
</TMPL_LOOP>
</table>
<TMPL_ELSE>
<p>No images to show</p>
</TMPL_IF>
</center>
</body>
</html>
=== END: photobrowser.tmpl.html
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: 26 Feb 2003 07:22:25 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Feedback request: photobrowser
Message-Id: <b3hpvh$12e$1@nets3.rz.RWTH-Aachen.DE>
Also sprach A. Sinan Unur:
> I now have a version of this script which works the way I would like on
> my system: It displays links (with optional thumbnails) to all jpeg files
> in a specified location in a table format (where the number of images per
> row is determined by the template), along with an optional description of
> each photo. Given my inexperience with Perl, I would appreciate comments
> on how to improve the script, especially regarding security holes. I
> would eventually like to use this script on my personal web pages, and I
> would hate to cause trouble for my hosting service.
Given your "inexperience", the script is pretty well done. Rather a
pleasant exception for posts like "Comment my script".
> By the way, I am not sure the included code below is getting too long for
> posting here. Should I just post a URL in the future?
Depends on the length of the script. This one isn't too long and by
putting it into the post, the group can comment on it line-by-line
without any prior copying.
>=== BEGIN: photobrowser.pl
>
> #!C:/Perl/bin/perl.exe -Tw
> # photobrowser
> # Display links (optionally with thumbnails and descriptions)
> # to images in a directory
>
> $|++;
> use strict;
> use diagnostics;
That's how any script of this length (and even of shorter length) should
start. Very nice.
> use CGI qw(:standard);
> use HTML::Template;
>
> use FileHandle;
> use Config::Properties;
>
> my $query = CGI::new();
You are calling the constructor as a function, but it really is a
class-method:
my $query = CGI->new;
This should make a difference actually and I wonder that it also worked
the way you did it. Anyway, keep in mind that class methods are not
functions so call them with 'CLASS->method'.
Since you are using the object-oriented interface of CGI, you don't need
to import the ':standard' tag from CGI. I think, an empty import would
have done as well:
use CGI ();
> my $location = $query->param("location");
> $location = '' if !$location;
The above two lines can be squeezed to one:
my $location = $query->param("location") || '';
> # See if location contains any relative paths
> bail_out($location, 'Invalid location specified in request.')
> if $location =~ /(\.\.)/;
>
> # Configuration Variables
> my %config = (
> wwwroot => '',
> script_location => '/cgi-bin/photobrowser.pl',
> htdocs_path => 'C:/Program Files/Apache Group/Apache2/htdocs',
> template_path => 'C:/Program Files/Apache Group/Apache2/templates',
> template_file => 'photobrowser.tmpl.html',
> thumb_dir => 'thumb',
> descriptions => 'album',
> default_description => '© 2003 A. Sinan Unur',
> );
>
> my $photo_path = "$config{htdocs_path}/${location}";
^ ^
Not wrong, but I'd have written that as
my $photo_path = "$config{htdocs_path}/$location";
The curlies aren't needed in the above case. But you can leave them in
if you find that it makes the string concatenation clearer.
> my $template = HTML::Template->new(
> filename => "$config{template_path}/$config{template_file}");
>
> # Provide some information during development
> $template->param(HTDOCS => $config{htdocs_path});
> $template->param(LOCATION => $location);
> $template->param(PHOTO_PATH => $photo_path);
> $template->param(DESC_FILE => "$photo_path/$config{descriptions}");
>
> # get the list of images
> opendir(PHOTO_DIR, $photo_path) || bail_out($photo_path);
> my @files = grep { !/^\.+/ && /\.jpe?g$/i } readdir(PHOTO_DIR);
> closedir PHOTO_DIR;
You are using @files later in the do-block, but nowhere else. You should
therefore move the above three lines into this block to further restrict
the scope of @files. Thus you keep the top-level block clean and
uncluttered with variables.
> # get photo descriptions if possible
> my $descriptions = Config::Properties->new();
> my $desc_fh = new FileHandle("< $photo_path/$config{descriptions}");
> if(defined $desc_fh) {
> $descriptions->load($desc_fh);
> undef $desc_fh;
I found this line confusing. The intent is to close the file-handle.
According to the docs of FileHandle undeffing it is the same as using
the close() method:
$desc_fh->close;
looks more natural and doesn't keep the reader wondering what undef()
does in this context.
> }
>
> my $title = $descriptions->getProperty('title');
> $template->param(TITLE => ($title ? $title : $location));
Simpler:
$template->param( TITLE => $title || $location );
> # Use the technique described by Chris Davies at
> # http://bluedot.net/mail/archive/read.php?f=9&i=2353&t=2345
> # to deduce the number of photos to display per row
>
> my $photos_per_row
> = scalar grep { /^URL\d+$/i } $template->query (loop => 'PHOTO_LIST');
You can even drop the scalar() here, although it does no harm.
> my @loop_data;
> do {
> my $counter = 0;
> my $iter_data = {};
> foreach my $file (@files) {
I would change the foreach to a while-loop:
opendir PHOTO_DIR, $photo_path) || bail_out($photo_path);
while (<PHOTODIR>) {
# directory entry now in $_
next if /^\.+/ || ! /^.jpe?g$/i;
Possibly you want to skip over subdirectories instead of things matching
'/^\.+/'. If so:
next if -d "$photo_path/$_" || ! /^.jpe?g$/i;
# or perhaps only regular files
next if ! (-f "$photo_path/$_" && /^.jpe?g$/i);
> $iter_data->{'FILE'.($photos_per_row ? $counter : '')} = $file;
> $iter_data->{'URL'.($photos_per_row ? $counter : '')}
> = "$config{wwwroot}/$location/$file";
> $iter_data->{'THUMB'.($photos_per_row ? $counter : '')}
> = -e "$photo_path/$config{thumb_dir}/$file"
> ? "$config{wwwroot}/$location/$config{thumb_dir}/$file" : "";
Hmmh, you have this '($photos_per_row ? $counter : '')' three times.
Perhaps a temporary variable to store this expression is better:
my $prefix = $photos_per_row ? $counter : '';
$iter_data->{"FILE$prefix"} = $file;
$iter_data->{"URL$prefix"} = "$config{wwwroot}/$location/$file";
$iter_data->{"THUMB$prefix" = ...;
Change $file to $_ each time in the above, if you plan using the
while-loop.
> my $desc = $descriptions->getProperty(lc($file));
> $iter_data->{'DESC'.($photos_per_row ? $counter : '')}
> = $desc ? $desc : $config{default_description};
> $counter = ($counter + 1) % ($photos_per_row || 1);
> if(!$counter) {
> push(@loop_data, $iter_data);
> $iter_data = {};
> }
> }
> push(@loop_data, $iter_data) if scalar keys %$iter_data;
I have some problems with the logic of the last six lines. Currently it
looks like:
do {
my $iter_data;
foreach (...) {
...
if (! $counter) {
push @loop_data, $iter_data;
$iter_data = { };
}
}
push @loop_data, $iter_data if keys %$iter_data;
}
It has something to do with the amount of photos that can be stored in
one row. It might be better to change the structure of @loop_data and
$iter_data to make the intent of the above clearer. @loop_data should be
a two-dimensional array, like a table, and $iter_data should become
$picture or so:
# second picture in first row
$loop_data[0][1] = $picture;
Right now you have (simplified):
@loop_data = (
{ FILE1 => ..., URL1 => ...,
FILE2 => ..., URL2 => ...,
... },
{ FILE1 => ..., URL1 => ...,
FILE2 => ..., URL2 => ...,
... },
...
);
where
@loop_data = (
# first row
[ { FILE => ..., URL => ..., ...},
{ FILE => ..., URL => ..., ...},
... ],
# second row
[ { FILE => ..., URL => ..., ...},
{ FILE => ..., URL => ..., ...},
... ],
...
);
would be easier to handle. You make quite some contortions to give the
several entries in the hash unique prefixes to distinguish later which
"URL"-key belongs to which "FILE"-key.
So it's a matter of a more suitable data-structure really.
> };
> $template->param(PHOTO_LIST => \@loop_data);
>
> print header, $template->output;
You are mixing the object-oriented interface of CGI.pm with the
functional one. Not wrong, but a little inconsistent IMHO.
print $query->header, $template->output;
[...]
Anyway, it's mostly the odd choice of data-structure that needs some
attention. The other complains are more of a cosmetical nature.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 25 Feb 2003 19:36:40 -0800
From: yuanxi80@hotmail.com (David Tian)
Subject: Help - Inserting '?' at empty places in a string of tab delimited numbers
Message-Id: <da930649.0302251936.74a8a4ae@posting.google.com>
A string of tab delimited numbers(positive or negative) as follows:
$str = "-0.33 -5 3 9 ";
There should be 79 numbers (with tab in between) in the string, but
some of them were missing. '?' were required to be inserted at the
missing places.
I used @attrs = split \t, $str; and then print out every element of
@attrs up to 79, subject to following condition:
if elem == an empty string
then print '?' to newfilehand
else print the elem;
It seems that the 'if condition' is not easily tested - /\s/ or / /
doesn't work.
Am I in the right direction to do this? I am being stuck at this place
for two days and would really appreciate any suggestions at all.
Thanks,
David
------------------------------
Date: Tue, 25 Feb 2003 22:37:24 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Help - Inserting '?' at empty places in a string of tab delimited numbers
Message-Id: <slrnb5oh44.3oa.tadmc@magna.augustmail.com>
David Tian <yuanxi80@hotmail.com> wrote:
> if elem == an empty string
> It seems that the 'if condition' is not easily tested - /\s/ or / /
> doesn't work.
Of course not, each of those requires at least one character.
if ( length $elem == 0 )
or
unless ( length $elem )
or
if ( $elem =~ /^$/ )
or
if ( $elem eq '' )
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 25 Feb 2003 23:42:39 -0800
From: sade_bhat@yahoo.com (Sade Bhat Kalasabail)
Subject: How to access proxy server for Perl Soap client
Message-Id: <3a621d3c.0302252342.2c8a94d@posting.google.com>
Need help for running a perl soap client. Am new to soap.
Have installed soaplite on a solaris. The server is behind a
firewall.
I am trying to run an example program
#!/usr/local/bin/perl -w
use SOAP::Lite;
print SOAP::Lite
-> uri('http://www.soaplite.com/Demo')
-> proxy('http://services.soaplite.com/hibye.cgi')
-> hi()
-> result;
but keep getting the error message
500 Can't connect to services.soaplite.com:80 (Interrupted system
call) at ./hib
ye.pl line 7
IS it because I haven't given my proxy server and user/password
access? If so how do I do it. What gives the 500 error message.
Can someone please guide me.
Thanks in Advance.
Sade
------------------------------
Date: Wed, 26 Feb 2003 08:11:08 +0100
From: "The M@db@T" <madbat28@hotmail.com>
Subject: NET::FTP cut my file ?
Message-Id: <b3hpcq$2k2$1@grillo.cs.interbusiness.it>
I have a simple Win32 Perl code with FTP::NET module, and when my ftp client
downloading file, he lost me some bytes. For example if the file is
3.000.503 bytes, after the download he become 3.000.465 : result i lost 38
bytes.....???? I wrong something or there is a bug ..............
This is my code :
use Net::FTP;
use Strict;
use Warnings;
print "Insert IP address : ";
chomp($site = <STDIN>);
print "Insert Username: ";
chomp($username = <STDIN>);
print "Insert Password: ";
chomp($password = <STDIN>);
$ftp = Net::FTP->new($site,Timeout => 60,Passive => 1,Port => 21, Debug =>
3)
or die "Can't connect: $@\n";
$ftp->login($username,$password);
$ftp->type(binary);
$ftp->get('file.zip');
$ftp->quit;
Anyone has an idea ???
Thanks
------------------------------
Date: 26 Feb 2003 07:44:18 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: NET::FTP cut my file ?
Message-Id: <b3hr8i$1t5$1@nets3.rz.RWTH-Aachen.DE>
Also sprach The M@db@T:
> I have a simple Win32 Perl code with FTP::NET module, and when my ftp client
> downloading file, he lost me some bytes. For example if the file is
> 3.000.503 bytes, after the download he become 3.000.465 : result i lost 38
> bytes.....???? I wrong something or there is a bug ..............
>
> This is my code :
>
> use Net::FTP;
> use Strict;
> use Warnings;
use strict;
use warnings;
Note the capitalization. Strictures and warnings are both pragmatas and
therefore there's no capital first letter.
>
> print "Insert IP address : ";
> chomp($site = <STDIN>);
chomp(my $site = <STDIN>);
> print "Insert Username: ";
> chomp($username = <STDIN>);
chomp(my $username = <STDIN>);
> print "Insert Password: ";
> chomp($password = <STDIN>);
chomp(my $password = <STDIN>);
> $ftp = Net::FTP->new($site,Timeout => 60,Passive => 1,Port => 21, Debug =>
> 3)
my $ftp = ...
> or die "Can't connect: $@\n";
^^
You are checking the wrong variable here. Check $!. $@ is for something
else. See 'perlvar.pod' for details on all of these special variables.
> $ftp->login($username,$password);
> $ftp->type(binary);
^^^^^^
Don't use barewords. Make it a string:
$ftp->type("binary");
or simply
$ftp->binary;
> $ftp->get('file.zip');
> $ftp->quit;
>
> Anyone has an idea ???
I suspect that the transfer-mode wasn't correctly set to 'binary' since
you used a bareword instead of a properly quoted string.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Wed, 26 Feb 2003 03:14:10 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: newbie regexp question
Message-Id: <pan.2003.02.26.02.06.39.498189@aursand.no>
On Wed, 26 Feb 2003 00:11:50 +0000, Mike wrote:
> $var =~ s/<\/nwl>/\n/g;
> $var =~ s/<lwr>(.*?)<\/lwr>/\U$1/gs;
> $var =~ s/<.*?>//g;
Seems to be that you're trying to parse - or in some way do something - a
markup langage. There are plenty of modules for that kind of work. Check
the CPAN repository;
http://www.cpan.org/
Back to your question; When posting code, and what you want it to do with
some specific data, you should _always_ post some example data as well.
That way we can be sure that we understand what you're really trying to
do.
--
Tore Aursand - tore@aursand.no - http://www.aursand.no/
------------------------------
Date: Wed, 26 Feb 2003 04:40:36 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Passing 2D arrays?
Message-Id: <x77kbniri4.fsf@mail.sysarch.com>
>>>>> "TH" == Tom Hoffmann <trh411@earthlink.net> writes:
TH> On Tue, 25 Feb 2003 15:50:30 +0000, Joe Creaney wrote:
>> I am writing a simple role playing game in PERL. I would like to know
>> if I can pass 2 demential array to functions using references. If it is
>> possible how do I do it?
TH> Sure, just pass a reference to the array to the subroutine, and in the
TH> subroutine use:
TH> $array_ref->[i][j] to refernce the elements
and are i and j functions? if not, that won't compile nor run too well.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
Date: Wed, 26 Feb 2003 01:09:10 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Perl -- CGI and background process
Message-Id: <3E5C5A06.B3817E54@earthlink.net>
"Randal L. Schwartz" wrote:
[snip]
> Been There, Done That.
>
> google site:stonehenge.com cgi nntp fork =>
>
> http://www.stonehenge.com/merlyn/WebTechniques/col62.html
>
> In fact, thanks to my 160+ magazine column articles online, it's hard
> to find a set of interesting keywords that doesn't already have a
> solution there. And if you *do*, please write me, because I'm still
> writing 2.5 columns per month, and would give you public credit for a
> new idea.
This isn't entirely a *new* idea, merely an enhancement to your existing
idea described in that article.
All the url links (for fetching news stuff) that the daemon outputs are
relative to the daemon itself. After the alarm() expires, the daemon is
dead, and clicking on any of these links produces a connection refused
error in the user's browser.
You could avoid this, if all of the daemon's links were relative to
$SELF_URL, and if you changed the main cgi script so that instead of
merely redirecting to $url, it redirected to "$url/$ENV{PATH_INFO}".
Thus, all the links would be relative to the real web server, not the
daemon, and all would pass through the CGI before being redirected back
to the daemon, and, if the daemon has died due to the alarm() it would
be automatically restarted, thus avoiding connection refused errors when
clicking on the links.
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
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 4625
***************************************