[19532] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1727 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 10 18:05:45 2001

Date: Mon, 10 Sep 2001 15:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1000159508-v10-i1727@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 10 Sep 2001     Volume: 10 Number: 1727

Today's topics:
    Re: @INC on VMS <Patrick_member@newsguy.com>
    Re: Annoying warning message <mjcarman@home.com>
    Re: Annoying warning message (Garry Williams)
    Re: AoH - continued (jason)
    Re: Baiting Gozilla to obtain quality code for nothing! <matthew.garrish@sympatico.ca>
        Can't fork on certain computers? (Graham W. Boyes)
        Cannot overload operator <> ? <c.hintze@gmx.net>
        Efficiency <tm@kernelconsult.com>
    Re: Efficiency (Chris Fedde)
    Re: Extract the relative sorting of items from multiple <jurgenex@hotmail.com>
        GetOptions($argument => \$output); (Sten Sogaard)
    Re: HELP: Capture a page? <spam@funnybytes.com>
    Re: HELP: Capture a page? <jurgenex@hotmail.com>
    Re: mysql INSERT is broken by some charactors in the in (John J. Trammell)
        Newbie TEXTAREA to a File Problem <ofirb1@netvision.net.il>
    Re: Newbie TEXTAREA to a File Problem <o.moser@mobilkom.at>
    Re: Perl docs <jurgenex@hotmail.com>
    Re: Possible in Perl, download via FTP a variable filen <bart.lateur@skynet.be>
    Re: Possible in Perl, download via FTP a variable filen <info@edrox.demon.nl>
    Re: printing all even || odd numbers from array (Charles DeRykus)
    Re: Probelm with undefined atgumnets (Anno Siegel)
    Re: Probelm with undefined atgumnets <mjcarman@home.com>
        Problems with sample modules from a book <mark.riehl@agilecommunications.com>
        replace string with wildcards (Larry S)
    Re: replace string with wildcards (Tad McClellan)
    Re: Where can I find a Perl SSH Telnet Client? (BUCK NAKED1)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 10 Sep 2001 14:06:57 -0700
From: Patrick Flaherty <Patrick_member@newsguy.com>
Subject: Re: @INC on VMS
Message-Id: <9nja1h01c18@drn.newsguy.com>

Thanx Dan,

  That did the trick.

  pat



In article <LF3n7.324201$v5.32430837@news1.rdc1.ct.home.com>, Dan says...
>
>Patrick Flaherty <Patrick_member@newsguy.com> wrote:
>> In article <6Hem7.316511$v5.31719849@news1.rdc1.ct.home.com>, Dan says...
>>>
>>>Patrick Flaherty <Patrick_member@newsguy.com> wrote:
>>>
>>>>How do I define @INC on VMS?  (Presumably with a logical name).  Looked through
>>>> the documentation and it's not yet apparent to me.
>>>
>>>Just like you do everywhere else. :)
>
>> Well I of course tried that but it didn't work (to the best of my
>> understanding):
>
>> RM763A>defi "@INC" U8:[UTIL.PERL5.LIB]
>
>Nonononono. Like this:
>
>  perl "-Ifoo/bar" "-Isome_place:[a.dir]" prog.pl
>
>or
>
>  perl -e "push @INC, ""foo/bar"""
>
>@INC is a perl variable. You need to set it from within perl. :)
>
>If you want it persistent because, say, you have a private library
>directory, take a look at the perlrun section of the manual,
>specifically for the PERL5LIB environment variable. Set that
>(As a process-mode or higher logical on VMS) and you should
>be OK.
>
>				Dan



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

Date: Mon, 10 Sep 2001 13:53:03 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Annoying warning message
Message-Id: <3B9D0C0F.54E49B4E@home.com>

Alicia wrote:
> 
> The following snippet:
> 
>     use Getopt::Std qw(getopts);
>     getopts("h");
>     if(defined $Getopt::Std::opt_h) {
>       print HELP;
>       exit(0);
>     }
> 
> produces the infuriating message:
> 
>     Name "Getopt::Std::opt_h" used only once: possible typo at
> ./MakeEvidenceTallies.p l line 22.

That particular snippet should also issue the same warning about "HELP"
unless you've declared it (as a constant or sub) elsewhere.
 
> One workaround is to prepend the line:
> 
>     use vars '$opt_h'

No, that will not silence the warning.
 
> Is there no other better way to silence the idiotic warning?  The
> warning shouldn't be there anyway.  $Getopt::Std::opt_h *is* a package
> variable (according to the documentation for Getopt::Std, anyway).

The warning isn't idiotic, and it should be there. With warnings
enabled, Perl squawks when you only use a package variable once. You
seem to be confusing this warning with the 

    Global symbol "$foo" requires explicit package name...

compile-time error issued under strict. 

Getopt::Std doesn't keep the $opt_* vars within its package, it expects
them to be in the caller's package, which is why the documentation tells
you that you will have to declare them if you are running under "strict
'vars'." So when you tested $Getopt::Std::opt_h, you were indeed
referencing a variable that was used only once, and Perl (rightly)
warned you about it.

In fairness, if you have warnings enabled but not strict, you would have
gotten the same message even if you had used $opt_h in your test, but
that's because of how Getopt::Std exports variables. With strict
enabled, Perl would have forced you to predeclare $opt_h and all would
have been quiet and happy.

Or (as Anno said) use the hash syntax.

-mjc


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

Date: Mon, 10 Sep 2001 20:50:27 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Annoying warning message
Message-Id: <slrn9pq9sh.37i.garry@zfw.zvolve.net>

On 10 Sep 2001 17:30:16 GMT, Anno Siegel
<anno4000@lublin.zrz.tu-berlin.de> wrote:
> According to Alicia  <alicia090677@hotmail.com>:
>> 
>> The following snippet:
>> 
>>     use Getopt::Std qw(getopts);
>>     getopts("h");
>>     if(defined $Getopt::Std::opt_h) {
>>       print HELP;
>>       exit(0);
>>     }
>> 
>> produces the infuriating message: 
>> 
>>     Name "Getopt::Std::opt_h" used only once: possible typo at
>> ./MakeEvidenceTallies.p l line 22.
>> 
>> One workaround is to prepend the line:
>> 
>>     use vars '$opt_h'
>> 
>> Is there no other better way to silence the idiotic warning?  The
> 
> Yes, give getopt a hash(ref) to populate:
> 
>     my %opts;
>     getopts( 'h', \ %opts);
>     if ( $opts{ h} ) {
>         # etc
>     }
> 
> Much better than infesting a symbol table with unforseeable variable
> names.

The names *are* forseeable.  They are defined by the string passed to
getopts().  

-- 
Garry Williams


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

Date: 10 Sep 2001 11:16:47 -0700
From: jason@gimptroll.com (jason)
Subject: Re: AoH - continued
Message-Id: <45a0e21a.0109101016.1d5a06ef@posting.google.com>

Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:<3B9A08E6.FAC182D6@earthlink.net>...
[snip]
> It won't make a difference for very few [0..9] keys, but for more, you
> need to do it as sort {$a <=> $b} keys %sorthash, otherwise it will
> think "10" is less than "2".
[/snip]

Gotcha.

[snip]
> Have you considered simplifying your data?
> A fixed order, and just have the values, not the keys.
> 
> music|very good|mp3
> video|too long|mpeg
> 
> Then the program becomes *much* simpler:
[/snip]

The point in the program is to *pretend* I don't know anything(no need
for security comments, I'm creating the data) about the data. With
this program, the data can have any number of fields, and you can
change the order in which they are returned by simply changing the key
in the first row. This allows me to create any size DB file and use
the same script to produce my output. I'm using it explicitly with
CGI.pm to create HTML tables. Like this:
http://www.gimptroll.com/cgi-bin/sort.cgi?sortby=date&db_file=calls.dat

Thanks,
TuNNe|ing


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

Date: Mon, 10 Sep 2001 17:07:12 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Baiting Gozilla to obtain quality code for nothing!!
Message-Id: <bU9n7.8585$2r.905684@news20.bellglobal.com>


"Randal L. Schwartz" <merlyn@stonehenge.com> wrote in message
news:m1g09vksjf.fsf@halfdome.holdit.com...
>
> Sounds like you have your *own* axe to grind, and that blinds you to
> the actual distruption that Kira is... namely that some of the newbies
> get distracted into thinking that Kira's advice is not sometimes the
> blind leading the blind on a sightseeing tour. :)
>

I couldn't have put it better if I tried! I'm just a lowly (okay, snobby)
English major who wound up falling into a programmer's position because of
the field I work in, so I wouldn't pretend to put myself on the same level
as Randal or most of the people who post here, but this person pretends like
s/he knows everything under the sun about everything, and makes a lot of
horrible blunders and generally practices poor coding techniques along the
way.

> She's also very good at publicly criticizing her critics, usually
> devolving to a personal attack when she can't find a technical
> come-back.  This is a pretty junior thing to do as well.  I wish her
> the best, but she's still got some growing up to do.
>

Again, bang-on! A sure sign of immaturity is a person's response to
criticism. While most people would accept their limitations, "kira" shoots
back with cheap slurs and will try to drive the discussion off on a tangent
without ever acknowledging her blunders (and if you play her game she'll cry
racism/sexism/whatever will make her feel hard-done-by). She should perhaps
read the story of the little boy who cried wolf. One day she might actually
have something interesting to say, but there will be nobody left who will
listen...

Matt




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

Date: 10 Sep 2001 11:32:20 -0700
From: thepro@toao.net (Graham W. Boyes)
Subject: Can't fork on certain computers?
Message-Id: <e9503d3c.0109101032.5d4505ce@posting.google.com>

Hi,

I want to capture the output of a program called mem.exe and use it in
my program.  I have this code:

open FORK, "MEM |" or die "Doesn't work";

Something like that...you get the idea.  I've also tried using
backticks, like
$something = `mem`;

It works on most computers (I tried an NEC and two custom built
machines) but on certain IBM machines it gives the error "Doesn't
work! at a:\myfile.pl line 66, <STDIN> chunk 6."

Line 66 is the line I try to fork MEM with.  What does <STDIN> chunk 6
mean?  What baffles me is that the code works on some machines and not
others.  I have a boot disk with Perl for DOS and the program on it. 
I used the same boot disk in each machine.  The only thing that
changed is the machine.  Running MEM from the DOS prompt is fine, and
I can't fork any other programs.

Signed totally baffled,
Graham W. Boyes


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

Date: Mon, 10 Sep 2001 20:38:07 +0200
From: Clemens Hintze <c.hintze@gmx.net>
Subject: Cannot overload operator <> ?
Message-Id: <3B9D088F.55DD7165@gmx.net>

Hello,

I have tried to overload the <> operator within an own class. But it
didn't work, I get the message: 

  Not a GLOB reference at foo.pl line 240.

As I didn't find a way to get it working, I friend of mine has passed
the book "Programming Perl 3rd Edition" to me. Here was following
example program mentioned:

------------------------------8X------------------------------
package LuckyDraw;

use overload
    '<>' => sub {
        my $self = shift;
        return splice @$self, rand @$self, 1;
    };

sub new {
    my $class = shift;
    return bless [@_] => $class;
}

package main;

$lotto = new LuckyDraw 1 .. 51;

for (qw(1st 2nd 3rd 4th 5th 6th)) {
    $lucky_number = <$lotto>;
    print "The $_ lucky number is: $lucky_number.\n";
}

$lucky_number = <$lotto>;

print "\nAnd the bonus number is: $lucky_number.\n";
------------------------------8X------------------------------

This way it is shown to work here, was very similar to my own one. So I
put this sample into a file, started it and ...

  Not a GLOB reference at pp3ed-sample.pl line 19.

Gnark! What did I done wrong? :-(

I am using Perl on FreeBSD 4.3-STABLE. A perl -v shows:

  version 5.005_03 built for i386-freebsd

I have already searched groups.google.com, and some other documentation
like FAQ and manpages. Unfortunately I did not find anything referring
to that problem. That error did only occur not relating to overload
issues at elder Perl versions.

Any hints for me?


Thanks in advance,
Clemens.


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

Date: Mon, 10 Sep 2001 23:20:32 +0200
From: TM <tm@kernelconsult.com>
Subject: Efficiency
Message-Id: <3B9D2EA0.3796B3AD@kernelconsult.com>

Hi,

Can Perl instructions either from the core or from specific modules be
more efficient than system commands such as copy, xcopy, del, move etc
with their many switches and wildcards. Or maybe that's a nonsense. In
my case, I'm working on WIn2K with procedures that handle thousands of
files with such commands that's why I'm looking for improvement in
execution time of such actions.

Thanks

TM



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

Date: Mon, 10 Sep 2001 21:42:23 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Efficiency
Message-Id: <3tan7.286$Owe.265504256@news.frii.net>

In article <3B9D2EA0.3796B3AD@kernelconsult.com>,
TM  <tm@kernelconsult.com> wrote:
>Hi,
>
>Can Perl instructions either from the core or from specific modules be
>more efficient than system commands such as copy, xcopy, del, move etc
>with their many switches and wildcards. Or maybe that's a nonsense. In
>my case, I'm working on WIn2K with procedures that handle thousands of
>files with such commands that's why I'm looking for improvement in
>execution time of such actions.
>

Copying data from one disk to another is usually choked by the
drive bandwidth.  You are not apt to see any performance improvement
by implementing the same algorithm in perl over some other language.
Occasionally though you'll see improvement if you find a better
algorithm.  I don't have much hope for that in this case unless you can
find some way to take advantage of wasted cycles.

good luck
-- 
    This space intentionally left blank


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

Date: Mon, 10 Sep 2001 14:34:46 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Extract the relative sorting of items from multiple lists
Message-Id: <3b9d31f6$1@news.microsoft.com>

"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3B9A17C7.AA6F172F@earthlink.net...
> I forget where I saw it, but this makes me think of a quote that was
> something like "Real Programmers edit using 'cat'" :)

Actually, you missed half of the quote:
    "Real Programmers use 'cat > a.out' "

jue




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

Date: 10 Sep 2001 12:52:19 -0700
From: sten_sogaard@juno.com (Sten Sogaard)
Subject: GetOptions($argument => \$output);
Message-Id: <5ad86837.0109101152.2c5d17b3@posting.google.com>

Hi All,

I am trying to get GetOptions to work with variable arguments.
Bacially I am getting the possible arguments somewhere else during
runtime and want to feed that to GetOptions.
When I define the argument as a constant (line 2) it works, but when I
get the argument from another variable it does not work.

Can anyone please give me a hint to what I am doing wrong.

>  $set{'name'}="teste_2";
>  my $argument = "$set{'name'}=s";    # this does not work
>  #	  my $argument = "teste_2=s"; # this works
>
>  print ">$argument<\n";   # prints out >teste_2=s< 
>  my $output;
>  GetOptions($argument => \$output);


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

Date: Mon, 10 Sep 2001 23:47:07 +0200
From: "Admin UsePad" <spam@funnybytes.com>
Subject: Re: HELP: Capture a page?
Message-Id: <9njc5n$obi$1@news.hccnet.nl>

Ok than,.. could you tell me where to find that perl faq? and what's that
special -q operator, is it quick?


"Tad McClellan" <tadmc@augustmail.com> schreef in bericht
news:slrn9ppncn.ul8.tadmc@tadmc26.august.net...
> Nigel Heinsius <Nigel_member@newsguy.com> wrote:
>
> >I hope someone can help me with this.
>         ^^^^^^^
>
> Too lazy to spend even 30 seconds trying to help yourself first?
>
> That's what it is going to look like to most of us...
>
>
> >Is it possible to capture a complete HTML page
>
>    perldoc -q HTML
>
>       "How do I fetch an HTML file?"
>
>
> You are expected to check the Perl FAQs *before* posting to the
> Perl newsgroup.
>
>
> >write the page to a server and email it as an attachment to the end user.
I can
> >do this with a PERL script,
>                 ^^^^^^^^^^^
>
> You mean either "Perl script" or "perl script" there.
>
> Only those not in the know spell it "PERL"...
>
>
> >but I need to "get" the page without having to
>                 ^^^
>                 ^^^ serendipitous, heh.
>
> >completely rebuild it using javascript forms and the PERL script.
> >
> >Any thoughts?
>
>    use LWP::Simple;   # part of the 'libwww' bundle from CPAN
>    my $htmlpage = get 'http://www.somewhere.com/silly.asp';
>
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas




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

Date: Mon, 10 Sep 2001 15:01:56 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: HELP: Capture a page?
Message-Id: <3b9d3858@news.microsoft.com>

[Please do not post jeopardy-style]
"Admin UsePad" <spam@funnybytes.com> wrote in message
news:9njc5n$obi$1@news.hccnet.nl...
> Ok than,.. could you tell me where to find that perl faq? and what's that
> special -q operator, is it quick?

It is sitting right there on your very own harddrive as part of every
standard Perl installation.
And the "special -q operator" is the hint for perldoc to search in the FAQ
rather than in the man pages, in the module description, etc.

Further details see
    perldoc perldoc

jue

BTW: a quick search in google or reading this NG for a few days would have
told you this without ever asking the same question again.




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

Date: 10 Sep 2001 18:10:49 GMT
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: mysql INSERT is broken by some charactors in the inserted record
Message-Id: <slrn9pq0h8.oah.trammell@haqq.hypersloth.net>

On Mon, 10 Sep 2001 12:36:24 -0500, Bing Du <bing-du@tamu.edu> wrote:
> Hi,
> 
> Mysql version: 3.23.39.  Perl 5.005.
> 
> My Perl script has the following statement.  But sometimes it gives
> 'ERROR 1064: You have an error in your SQL syntax near...'.  Then I
> notice that the value that $value holds has a "'" or maybe some other
> characters that INSERT does not like.
> 
> $sth = $dbh->prepare("INSERT INTO $table (var_name,var_value) values
> ('$name','$value')");
> 
> What should I do to get the record inserted?

Use the DBI quote() function, or let DBI do it for you:

$sth = $dbh->prepare("INSERT INTO $table (var_name,var_value) values (?,?)");

$sth->execute($name,$value);

-- 
If the organizational structure is threatening in any way, nothing is
going to be documented until it is completely defensible.
                                - F. Brooks, _The Mythical Man-Month_


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

Date: Mon, 10 Sep 2001 20:55:02 +0200
From: "biG" <ofirb1@netvision.net.il>
Subject: Newbie TEXTAREA to a File Problem
Message-Id: <9niuua$mca$1@news.netvision.net.il>

Hi all,
Sorry for a newbie question:
I want to capture user's input from a form to a file.
Latter, I need to import the file to an MS Excel (CSV) file.
The problem is the one of the form fields is a TEXTAREA field, and when user
write in several lines, and hit the Enter key - the results from this field
are breaking into several lines, instead of one, which messes the entire
file.
How/what should I do to prevent it?

TIA,
Ofir
"When I got to the top of Everest, I was tired."  -Aracelli Segarra





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

Date: Mon, 10 Sep 2001 20:29:57 +0200
From: Oliver Moser <o.moser@mobilkom.at>
Subject: Re: Newbie TEXTAREA to a File Problem
Message-Id: <1k1qptgsbrp1k75bmvqtvvh2evfg384m80@4ax.com>

On Mon, 10 Sep 2001 20:55:02 +0200, "biG" <ofirb1@netvision.net.il>
wrote:

>Hi all,
>Sorry for a newbie question:
>I want to capture user's input from a form to a file.
>Latter, I need to import the file to an MS Excel (CSV) file.
>The problem is the one of the form fields is a TEXTAREA field, and when user
>write in several lines, and hit the Enter key - the results from this field
>are breaking into several lines, instead of one, which messes the entire
>file.
>How/what should I do to prevent it?
>
>TIA,
>Ofir
>"When I got to the top of Everest, I was tired."  -Aracelli Segarra
>
>
use a regex like 

	$q->param('textareaname') =~ s/\n/ /g 

to replace the newlines (\n) with a single space.

 ------------------------------
Oliver Moser
mobilkom austria AG & Co. KG
IT://mob.app
Mobil: +43-664-331-2544
mailto:o.moser@mobilkom.at


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

Date: Mon, 10 Sep 2001 14:42:38 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perl docs
Message-Id: <3b9d33ce$1@news.microsoft.com>

"ekkis" <e@nospam:[arix.com]> wrote in message
news:eZTm7.454$884.141247@news.pacbell.net...
> does anyone know where I could download the Perl HTML documentation?  I
> don't want to keep using perldoc.com because it's sometimes unavailable so
> I'd like to install this on my web server... but I can't find it!

Does it really have to be in HTML?
If you can live with plain text just use "perldoc".

jue




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

Date: Mon, 10 Sep 2001 18:23:49 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Possible in Perl, download via FTP a variable filename based on date?
Message-Id: <hk0qptkhn3n89q4ttkksm0fb4vaeur39tk@4ax.com>

Eduard de Vries wrote:

>I need to do the following, I need to download a file from an FTP server, I
>can automatically dial in to the server and start the ftp connection.
>But then I need to enter test20010910.csv as a file name, and tomorrow it is
>the filename of tomorrow, obviously the date is made 1 higher.
>
>Is this possible with Perl?
>If yes, I will try and learn Perl.

Yes. You can construct the desired filename from the fields returned
from localtime. Don't forget to add 1900 to the year and 1 to the month:

	my($day, $month, $year) = (localtime)[3, 4, 5];
	$month++; $year += 1900;
	my $file = sprintf 'test%04d%02d%02d.csv', $year, $month, $day;
	#Let's see what we got:
	print $file;

Today this prints

	test20010910.csv


As for getting the file: the module Net::FTP can retrieve it. Lincoln
Steins book "Network Programming with Perl" devotes a large part of a
chapter to it. You're in luck: this entire chapter is available on the
web: <http://www.modperl.com/perl_networking/sample/ch6.html> . Figure
6.1 is the minimum you need. It's a script of 11 lines. The source code
for the whole book is downloadable from
<http://www.modperl.com/perl_networking/source/>.

-- 
	Bart.


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

Date: Mon, 10 Sep 2001 21:26:49 +0200
From: "Eduard de Vries" <info@edrox.demon.nl>
Subject: Re: Possible in Perl, download via FTP a variable filename based on date?
Message-Id: <tpq4u97cl3438c@news.demon.nl>

Bart,

thanks!!

I will test tomorrow.

Thanks again,

Eduard
"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:hk0qptkhn3n89q4ttkksm0fb4vaeur39tk@4ax.com...
> Eduard de Vries wrote:
>
> >I need to do the following, I need to download a file from an FTP server,
I
> >can automatically dial in to the server and start the ftp connection.
> >But then I need to enter test20010910.csv as a file name, and tomorrow it
is
> >the filename of tomorrow, obviously the date is made 1 higher.
> >
> >Is this possible with Perl?
> >If yes, I will try and learn Perl.
>
> Yes. You can construct the desired filename from the fields returned
> from localtime. Don't forget to add 1900 to the year and 1 to the month:
>
> my($day, $month, $year) = (localtime)[3, 4, 5];
> $month++; $year += 1900;
> my $file = sprintf 'test%04d%02d%02d.csv', $year, $month, $day;
> #Let's see what we got:
> print $file;
>
> Today this prints
>
> test20010910.csv
>
>
> As for getting the file: the module Net::FTP can retrieve it. Lincoln
> Steins book "Network Programming with Perl" devotes a large part of a
> chapter to it. You're in luck: this entire chapter is available on the
> web: <http://www.modperl.com/perl_networking/sample/ch6.html> . Figure
> 6.1 is the minimum you need. It's a script of 11 lines. The source code
> for the whole book is downloadable from
> <http://www.modperl.com/perl_networking/source/>.
>
> --
> Bart.




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

Date: Mon, 10 Sep 2001 19:59:43 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: printing all even || odd numbers from array
Message-Id: <GJGq7J.DoM@news.boeing.com>

In article <3B9C713C.9635F035@earthlink.net>,
Benjamin Goldberg  <goldbb2@earthlink.net> wrote:
>GunneR wrote:
>> @array1 = qw(1 2 3 4 5 6);
>[snip]
>> Want it to print "2 4 6"
>
>perl -e 'print join(" ", grep !($_ & 1), 1 .. 6 ), "\n"'

I like it but the golf "voices" are kicking in:

perl -le 'print "@{[grep !($_ % 2), 1..6]}"'


--
Charles DeRykus


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

Date: 10 Sep 2001 18:20:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Probelm with undefined atgumnets
Message-Id: <9nj09f$bum$1@mamenchi.zrz.TU-Berlin.DE>

According to Stan Brown <stanb@panix.com>:
> A kind member of this group showed me a neat trick to print out the
> arguments to a given function. It goes like this:
> 
> join ', ', map { "Arg$_ ->$_[$_]<-" } 0 .. $#_;
> 
> This works great _except_ when I pass in undef for an argumentm then I get
> a warning about concatenating an unitliazed variable. 
> 
> How can I improve thsi to allow for this case?

    join ', ', map "Arg$_ " . ( defined $_[$_] ? "->$_[$_]<-" : '-undef-'),
        0 .. $#_;

Or switch off the offending warning locally, but then you won't see
the difference between "" and undef.

Anno


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

Date: Mon, 10 Sep 2001 14:08:50 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Probelm with undefined atgumnets
Message-Id: <3B9D0FC2.1E061C9E@home.com>

Stan Brown wrote:
> 
> A kind member of this group showed me a neat trick to print out the
> arguments to a given function. It goes like this:
> 
> join ', ', map { "Arg$_ ->$_[$_]<-" } 0 .. $#_;
> 
> This works great _except_ when I pass in undef for an argumentm then
> I get a warning about concatenating an unitliazed variable.
> 
> How can I improve thsi to allow for this case?

Two options:

Disable warnings for just that block:

{
    local $^W;
    print join ', ', map { "Arg$_ ->$_[$_]<-" } 0 .. $#_;
}

Or catch the undef and map it into something else:

print join ', ', map {defined($_[$_])
    ? "Arg$_ ->$_[$_]<-"
    : "Arg$_ ->*UNDEF*<-"
} 0 .. $#_;


-mjc


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

Date: Mon, 10 Sep 2001 18:58:38 GMT
From: "Mark Riehl" <mark.riehl@agilecommunications.com>
Subject: Problems with sample modules from a book
Message-Id: <y38n7.4285$hE2.2818280@typhoon2.gnilink.net>

All - I'm on Win2k and I'm trying to work through some of the examples in
Lincoln Stein's Perl Network Programming  book.  The samples come with
modules, and install script.  Everything installed w/o any errors.

When I try to run the sample server, I get the following error:

perl eliza_select.pl
Can't locate Chatbot/Eliza.pm in @INC (@INC contains: C:/Perl/lib
C:/Perl/siib .) at C:/Perl/site/lib/Chatbot/Eliza/Polite.pm line 2.
BEGIN failed--compilation aborted at
C:/Perl/site/lib/Chatbot/Eliza/Polite.pne 2.
Compilation failed in require at eliza_select.pl line 7.
BEGIN failed--compilation aborted at eliza_select.pl line 7.

The following directories were created:

c:\Perl\site\lib\Chatbot\Eliza, and the Eliza directory contains the
following modules: Polite.pm and Server.pm.

Any suggestions?

Thanks,
Mark





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

Date: 10 Sep 2001 11:50:01 -0700
From: dime0000@yahoo.com (Larry S)
Subject: replace string with wildcards
Message-Id: <8fd7acb0.0109101050.2fb1ae79@posting.google.com>

ok, i want to get rid of html in a text field... 

basically, i want something where everything beginning with a <a href
and ending with a </a> (including the a href and /a) are deleted

anyone know the syntax?

this listed below isnt correct, but its what i'm trying to do:

$text =~ s//<a href="/cust/cdeploy * </a>/g;


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

Date: Mon, 10 Sep 2001 19:46:42 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: replace string with wildcards
Message-Id: <slrn9pq382.v5p.tadmc@tadmc26.august.net>

Larry S <dime0000@yahoo.com> wrote:

>i want to get rid of html in a text field... 
                      ^^^^

   perldoc -q html

      "How do I remove HTML from a string?"

You are expected to check the Perl FAQ *before* posting to the
Perl newsgroup.


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


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

Date: Mon, 10 Sep 2001 13:21:33 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Where can I find a Perl SSH Telnet Client?
Message-Id: <16872-3B9D04AD-74@storefull-248.iap.bryant.webtv.net>

This is ridiculous. All I asked was a simple question; and instead of
help, some folks insist on flaming me. Thanks to the few who did post
assistance. I have never expected people to do my work for me. I am far
from lazy. I usually spend days trying to figure something out and
researching it before asking for help here. 

Additionally, I usually check Google and the FAQ first; and the CPAN
modules. This time, I missed checking the CPAN modules, and admitted it.
I make mistakes. I'm human. 

I don't appreciate the implications that the likes of Peter, Anno and
Tad are throwing out. Posting history? I have only being kind and tried
to help others when I could. Yes, I post under 2 different names, my PC
name and WebTV name. What's your point?

Regards,
Dennis



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

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


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