[22990] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5210 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 10 14:06:48 2003

Date: Thu, 10 Jul 2003 11:05:11 -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           Thu, 10 Jul 2003     Volume: 10 Number: 5210

Today's topics:
    Re: All instances of regexp <thens@nospam.com>
        and EZ way to convert XLS file to CSV? (Sara)
    Re: and EZ way to convert XLS file to CSV? <g4rry_short@zw4llet.com>
    Re: and EZ way to convert XLS file to CSV? (Helgi Briem)
        creating a directory with cgi and owner ends up as apac <me@home.com>
    Re: creating a directory with cgi and owner ends up as  <mbudash@sonic.net>
    Re: creating a directory with cgi and owner ends up as  <me@home.com>
    Re: Fastest way to build a hash (=?ISO-8859-1?Q?Stefan_Fischerl=E4nder?=)
    Re: Fastest way to build a hash (=?ISO-8859-1?Q?Stefan_Fischerl=E4nder?=)
    Re: Find string in web page (Greg Bacon)
    Re: Grabbing certain section of a string (fatted)
        Has anybody successfully built HTML::Parser module on C (Jose Gilberto Torres)
    Re: Help with Perl Script (Sara)
        Help, perlcc bug or wrong code? (Gareth Glaccum)
        How to check writing permission? (Math55)
    Re: How to check writing permission? <grazz@pobox.com>
    Re: How to do SSL FTP? <mpompey@versuslaw.com>
    Re: How to do SSL FTP? <b.gaber@pwgsc.gc.ca>
    Re: How to do SSL FTP? <glex_nospam@qwest.net>
        iis and dbi <jgiblin@roadrunner.com>
    Re: iis and dbi <mbudash@sonic.net>
        NET::FTP  ls error <rpl-erroroneous@goldengate.net>
    Re: NET::FTP  ls error <mbudash@sonic.net>
    Re: NET::FTP  ls error <rpl-erroroneous@goldengate.net>
        Newbie Perl Question: RE Configuration Files (Orisopha)
    Re: Newbie Perl Question: RE Configuration Files <nap@illx.org>
    Re: Newbie Perl Question: RE Configuration Files <thens@nospam.com>
        Perl FAQ error in "variable as a variable name" (Eric Pement)
    Re: Q- Empirical usable upper limit on hash array numbe (Eric Pement)
    Re: Question about Devel::Cover <usenet@expires082003.tinita.de>
    Re: Reading Lines into an Array <infomatic@aol.com>
    Re: Regular expression imesh and timesheet <g4rry_short@zw4llet.com>
    Re: string question (Sam Holden)
    Re: string question <usenet@expires082003.tinita.de>
    Re: string question <abigail@abigail.nl>
        Stringifying data without newlines. <stjm2@hermes.cam.ac.uk>
    Re: Stringifying data without newlines. (Greg Bacon)
        Wanted - push/rexec/pull script for remote program buil (John Ramsden)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 10 Jul 2003 23:13:55 +0530
From: Thens <thens@nospam.com>
Subject: Re: All instances of regexp
Message-Id: <20030710231355.30202e4d.thens@nospam.com>

On Thu, 10 Jul 2003 13:26:51 +0200
Grzegorz Borowiak <grzes@gnu.univ.gda.pl> wrote:

>Thx a lot to all you who helped me. Perl doc is very large and I didn't
>know where to search it.

  and is quite informative !!

For functions use perldoc -f <function name>

  perldoc -f open
  perldoc -f grep
  perldoc -f split


for FAQs use the -q and the keywords

 perldoc -q compare arrays
 perldoc -q web page

 The most referred sections

perldoc perlop   - Operators
perldoc perldata - All about Perl's data structures
perldoc perlref  - References ! References ! References !
perldoc perlre   - Perl regular expressions

-
Regards,
Thens. 


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

Date: 10 Jul 2003 06:25:45 -0700
From: genericax@hotmail.com (Sara)
Subject: and EZ way to convert XLS file to CSV?
Message-Id: <776e0325.0307100525.37b06a42@posting.google.com>

OK, I'm painted into a corner by Bill G again.. This time with XL, yet
another package NIH by Microsoft but still controlled by them...

If I bop into OpenOffice I can read in an XLS and export it as a CSV.
I looked in cpan and news but didn't see a straightforward way to do
the same thing with a Perl module. I saw XL-Parse but the readme
implied it didn't have a quick-conversion capability.

Something, perhaps, like

  my @csv = DreamXLModule::Convert($XLFilePath, 'csv');

Thanks!
Gx


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

Date: Thu, 10 Jul 2003 15:20:52 +0000
From: Garry Short <g4rry_short@zw4llet.com>
Subject: Re: and EZ way to convert XLS file to CSV?
Message-Id: <bejstc$msb$1$8302bc10@news.demon.co.uk>

Sara wrote:

> OK, I'm painted into a corner by Bill G again.. This time with XL, yet
> another package NIH by Microsoft but still controlled by them...
> 
> If I bop into OpenOffice I can read in an XLS and export it as a CSV.
> I looked in cpan and news but didn't see a straightforward way to do
> the same thing with a Perl module. I saw XL-Parse but the readme
> implied it didn't have a quick-conversion capability.
> 
> Something, perhaps, like
> 
>   my @csv = DreamXLModule::Convert($XLFilePath, 'csv');
> 
> Thanks!
> Gx

Not seen one, sorry. You could write your own without too much trouble,
using Spreadsheet::ParseExcel, something like this:

--

#!/usr/bin/perl -w
use strict;
use Spreadsheet::ParseExcel;
my ($file) = (@ARGV);
my $dest = $file;
my $xls = Spreadsheet::ParseExcel::Workbook->Parse("$file");
foreach my $sheet (@{$xls->{Worksheet}}) {
  my $name = $sheet->{Name};
  my $dest =~ s/\.xls$/_sheet$name\.cvs/;
  open OUT, ">$dest" or die "Can't write to $dest: $!\n";
  my ($col, $row);
  for ($row = $sheet->{MinRow};
              defined $sheet->{MaxRow} && $row <= $sheet->{MaxRow};
              $row++) {
    for ($col = $sheet->{MinCol}; 
                defined $sheet->{MaxCol} && $col <= $sheet->{MaxCol};
                $col++){
      my $cell = $sheet->{Cells}[$row][$col]->Value;
      print OUT "$cell,";
    }
    print OUT "\n";
  }
  close OUT;
}  

--

It should write every sheet to a different file, in the form 
<filename>_<sheetname>.cvs
Not tested, but it may work. Gives you the idea, anyway.

Two things, though - this module throws up lots of warnings, so you may wish
to switch them off once you get it working.
Also, this won't be quick (from recent experience, I'd guess about 15mins
for an xls with 12 sheets, each around 150x400. That's on a P3/700mhz with
128mb RAM & Linux, just to give you an idea)!

Hopefully this'll give you a good start on writing it, anyway. It may just
need a check to make sure the cell's not empty.

Regards,

Garry




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

Date: Thu, 10 Jul 2003 15:44:19 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: and EZ way to convert XLS file to CSV?
Message-Id: <3f0d8994.15320453@news.cis.dfn.de>

On 10 Jul 2003 06:25:45 -0700, genericax@hotmail.com (Sara) wrote:

>OK, I'm painted into a corner by Bill G again.. This time with XL, yet
>another package NIH by Microsoft but still controlled by them...
>
>If I bop into OpenOffice I can read in an XLS and export it as a CSV.
>I looked in cpan and news but didn't see a straightforward way to do
>the same thing with a Perl module. I saw XL-Parse but the readme
>implied it didn't have a quick-conversion capability.

Are you talking about Excel, by any chance?

use Spreadsheet::ParseExcel;


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

Date: Thu, 10 Jul 2003 13:36:13 -0700
From: Steve <me@home.com>
Subject: creating a directory with cgi and owner ends up as apache
Message-Id: <nhjrgvs3q58cpdijg0oge8n7p6hpet3i0c@4ax.com>

Hi,

I'm trying to create a directory and files using cgi. The strange
thing is when I call the script directly, I have no problem, but when
I call it using forms on an index.html file, the directory and files
have user:owner as apache:apache. Any ideas why this is happpening.

The method to create the file is:

`mkdir $path`;

Of course, I am using !#/usr/bin/perl -Tw
and am untainting the data using:

$user_input =~ /^([-_\@\w.\s]+)$/

also, I put this in at the top, but I don't think it is causing it:
$ENV{PATH} = "/bin:/usr/bin"; 
delete @ENV{ 'IFS', 'CDPATH', 'ENV', 'BASH_ENV' }; 

I'm a little bit of a newbie here, so thanks for any help!


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

Date: Thu, 10 Jul 2003 17:41:43 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: creating a directory with cgi and owner ends up as apache
Message-Id: <mbudash-1B1AE8.10414210072003@typhoon.sonic.net>

In article <nhjrgvs3q58cpdijg0oge8n7p6hpet3i0c@4ax.com>,
 Steve <me@home.com> wrote:

> Hi,
> 
> I'm trying to create a directory and files using cgi. The strange
> thing is when I call the script directly, I have no problem, but when
> I call it using forms on an index.html file, the directory and files
> have user:owner as apache:apache. Any ideas why this is happpening.

[snip code]

cgi scripts usually run as 'nobody', though they can run as whatever the 
admin set apache up as... in your case, it looks like they run as 
'apache'... you can usually change the permissions and/or user/group in 
the script...
-- 
Michael Budash


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

Date: Thu, 10 Jul 2003 14:02:04 -0700
From: Steve <me@home.com>
Subject: Re: creating a directory with cgi and owner ends up as apache
Message-Id: <90lrgv08kedm1lst04f39ulhbv9eunqnf5@4ax.com>

On Thu, 10 Jul 2003 17:41:43 GMT, Michael Budash <mbudash@sonic.net>
wrote:

>In article <nhjrgvs3q58cpdijg0oge8n7p6hpet3i0c@4ax.com>,
> Steve <me@home.com> wrote:
>
>> Hi,
>> 
>> I'm trying to create a directory and files using cgi. The strange
>> thing is when I call the script directly, I have no problem, but when
>> I call it using forms on an index.html file, the directory and files
>> have user:owner as apache:apache. Any ideas why this is happpening.
>
>[snip code]
>
>cgi scripts usually run as 'nobody', though they can run as whatever the 
>admin set apache up as... in your case, it looks like they run as 
>'apache'... you can usually change the permissions and/or user/group in 
>the script...

wow...thanks for the quick reply. Can you give me a hint as to how to
create a file and directory with me as owner? Or point me in the right
direction?

Thanks


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

Date: 10 Jul 2003 06:06:45 -0700
From: fischerlaender@gmx.de (=?ISO-8859-1?Q?Stefan_Fischerl=E4nder?=)
Subject: Re: Fastest way to build a hash
Message-Id: <ff9bee6c.0307100506.112bbf6d@posting.google.com>

fischerlaender@gmx.de (Stefan Fischerländer) wrote in message news:<ff9bee6c.0307100301.4403e8d7@posting.google.com>...

> > Note that I left out the unpack(), since doing so makes the hash keys
> > smaller, and thus use less memory, and also, they're'll be fewer hash
> > collisions, which should also speed up the program.
> 
> This is what made the program faster, not the pre-allocation of memory
> for the hash.

I did something wrong again: If you want to pre-allocate memory, you
should use the same hash in the keys statement as you are using later
in your loop ...

keys(%hash) = (-s IN) / 5;
while(read IN, $buf, 4)
{
  $hash{$buf} = getc IN;
}

This needs just 2.0 seconds - thank you very much.


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

Date: 10 Jul 2003 06:31:18 -0700
From: fischerlaender@gmx.de (=?ISO-8859-1?Q?Stefan_Fischerl=E4nder?=)
Subject: Re: Fastest way to build a hash
Message-Id: <ff9bee6c.0307100531.4a3a12f6@posting.google.com>

"Eric J. Roode" <REMOVEsdnCAPS@comcast.net> wrote in message news:<Xns93B43D68554D7sdn.comcast@206.127.4.25>...

> Okay, this is the fastest I've come up with yet:
>     open IN, $input_file or die "Can't read $input_file: $!\n";
>     $/ = \5;     # set input record length to 5 bytes
>     my %hash;
>     $hash{$_} = chop  while <>;

Took some time to figure out that the last line must read:
$hash{$_} = chop  while <IN>;

This solutions is also rather quick, takes 2.0 seconds.


I now have three different solutions (this is the Perl way *g*) that
are nearly equally fast and about 60% faster than my initial code.

Thank you all very much!

Stefan


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

Date: Thu, 10 Jul 2003 13:18:31 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Find string in web page
Message-Id: <vgqpt7kpvg8280@corp.supernews.com>

In article <4628ab88.0307100504.3c4f6f9e@posting.google.com>,
    Kirk Larsen <spamme@kirklarsen.com> wrote:

: Can't seem to get it to work.  It just outputs nothing.  Am I doing
: something wrong, or is there another way?  I did print out my search
: string var and verified that it is in the source I'm searching, so
: that's not the problem.  Thanks again!

Out of the box, does the code produce the same output as shown in
my followup?

What are you looking for?  It looks like I was forcing the match to
be at the end:

    next unless $text =~ /$lookfor$/;

If you don't want to look at the end, change that to

    next unless $text =~ /$lookfor/;

It would also help if you showed your code, but, as always with
Usenet, cutting-and-pasting megabytes of source code isn't useful.

Greg
-- 
The greatest dangers to liberty lurk in insidious encroachment by men
of zeal, well-meaning but without understanding.
    -- Justice Louis D. Brandeis


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

Date: 10 Jul 2003 08:21:21 -0700
From: fatted@yahoo.com (fatted)
Subject: Re: Grabbing certain section of a string
Message-Id: <4eb7646d.0307100721.1e7fd616@posting.google.com>

Abigail <abigail@abigail.nl> wrote in message news:<slrnbgob6k.q45.abigail@alexandra.abigail.nl>...
> Desmo (me@helpme.com) wrote on MMMDXCIX September MCMXCIII in
> <URL:news:94724eff9e851813349be69596df5d41@free.teranews.com>:

<snip>

> Assuming the string is in $str:
> 
>     my @filenames = $str =~ /filename="([^"]*)"/g;

Can you explain how the part of the regexp thats inside the () works.
I just don't follow :(. Is there any reason not to use (.*?) {instead
of what you have ([^"]*)}?


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

Date: 10 Jul 2003 09:36:32 -0700
From: jogeedaklown69@yahoo.com (Jose Gilberto Torres)
Subject: Has anybody successfully built HTML::Parser module on Cygwin?
Message-Id: <ac9e029c.0307100836.6f9b81d6@posting.google.com>

Hello,
I was wondering if anyone in the cyber world was able to build the
HTML::Parser module under cygwin?

I've tried both 3.26 and 3.26 version of the code as well as perl 5.6
and 5.8 on cygwin and I get this error everytime.

"Can't find /usr/lib/perl5/5.6.1/ExtUtils/typemap in /home/blah
blah/HTML-Parser3.26."

Any luck?

Thanks!

Jose


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

Date: 10 Jul 2003 06:17:58 -0700
From: genericax@hotmail.com (Sara)
Subject: Re: Help with Perl Script
Message-Id: <776e0325.0307100517.6b053616@posting.google.com>

helgi@decode.is (Helgi Briem) wrote in message news:<3f0d3305.1470030078@news.cis.dfn.de>...
> On Wed, 9 Jul 2003 11:32:53 -0500, "William Alexander Segraves"
> <wsegrave@mindspring.com> wrote:
> 
> >Let's see if I understand your logic. You have a problem 
> >which you steadfastly refuse to describe to me. I am not 
> >able to glean enough relevant clues from your posting 
> >to improve on your definition of the problem; so I
> >am an unhelpful nitwit.
> 
> Bill, this message was a joke, a sarcastic paraphrasing
> of the earlier one from *Robert*.
> 
> It goes to show what can happen when people
> forget or refuse to use smileys.

Tomorrow on Perl Network- "The Perils & Dangers of Not Using Emoticons!"

-Gx


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

Date: 10 Jul 2003 07:57:11 -0700
From: verycoldpenguin@hotmail.com (Gareth Glaccum)
Subject: Help, perlcc bug or wrong code?
Message-Id: <991491a9.0307100657.12b679e3@posting.google.com>

Hi, I am using perlcc to compile up some perl programs but I think I
have a bug report to make.
The problem is that $0 or $PROGRAM_NAME seems to be being squashed by
the perlcc.

#!/usr/bin/perl
print "$0 is my name, as is $PROGRAM_NAME\n";

If the above two lines are saved as temp.pl and then the following
commands are run, I need the answer to be the same. Any ideas?
Gareth

#perl temp.pl
temp.pl is my name, as is temp.pl
#perlcc temp.pl -o temp.out
#./temp.out
-e is my name, as is -e


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

Date: 10 Jul 2003 08:03:57 -0700
From: magelord@t-online.de (Math55)
Subject: How to check writing permission?
Message-Id: <a2b8188a.0307100703.26c9a834@posting.google.com>

how can i check my writing permissions with perl?
im working on unix...

THANKS:)


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

Date: Thu, 10 Jul 2003 15:15:28 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: How to check writing permission?
Message-Id: <kqfPa.41156$U23.13032@nwrdny01.gnilink.net>

Math55 <magelord@t-online.de> wrote:
> how can i check my writing permissions with perl?
> im working on unix...

Look for "-W":

    % perldoc -f -X

-- 
Steve


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

Date: Thu, 10 Jul 2003 06:58:41 -0700
From: "Michael Pompey" <mpompey@versuslaw.com>
Subject: Re: How to do SSL FTP?
Message-Id: <bejr8s$jp2$1@eskinews.eskimo.com>

> How do I create SSL FTP?
    Good question.
   I recommend that you try using the ftp 'passive' mode.
   This was designed to give ftp a modicum of security.



"J. Gleixner" <glex_nospam@qwest.net> wrote in message
news:m5%Oa.48$z21.53776@news.uswest.net...
> Brian wrote:
> > I am able to use Net::FTP fine.  I have new requirements to create
> > secure FTP using SSL.  SSH or SCP is not suitable due to FTP server.
> > How do I create SSL FTP?
> >
> > Thanks.
> >
> Net::SFTP
>




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

Date: Thu, 10 Jul 2003 10:25:11 -0400
From: Brian <b.gaber@pwgsc.gc.ca>
Subject: Re: How to do SSL FTP?
Message-Id: <3F0D7747.EE69901A@pwgsc.gc.ca>

I don't think Net::SFTP uses SSL.  I think Net::SFTP is based on SSH,
which, unfortunately, my requirements do not allow me to use.

Any other suggestions?

"J. Gleixner" wrote:

> Brian wrote:
> > I am able to use Net::FTP fine.  I have new requirements to create
> > secure FTP using SSL.  SSH or SCP is not suitable due to FTP server.
> > How do I create SSL FTP?
> >
> > Thanks.
> >
> Net::SFTP



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

Date: Thu, 10 Jul 2003 10:36:10 -0500
From: "J. Gleixner" <glex_nospam@qwest.net>
Subject: Re: How to do SSL FTP?
Message-Id: <1JfPa.32$7a1.22547@news.uswest.net>

Brian wrote:
> I don't think Net::SFTP uses SSL.  I think Net::SFTP is based on SSH,
> which, unfortunately, my requirements do not allow me to use.

Right, I thought the ultimate goal was to use a secure/encrypted FTP 
because you can't use scp. Sorry.



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

Date: Thu, 10 Jul 2003 17:41:12 GMT
From: "John Giblin" <jgiblin@roadrunner.com>
Subject: iis and dbi
Message-Id: <YyhPa.24090$Aw.17715@twister.nyc.rr.com>

Hi,

I am making a simple program that connects to Oracle  and then display the
results.  When I exec the program via command like, there does not seem to
be a problem. When I do it through a browser I do not get any print commands
past the connection

here is what I have:
use strict;
use DBI;

my ($dbh, $sth, @row);
my %attr = (
    PrintError => 0,
    RaiseError => 0,
);
$ENV{"ORACLE_HOME"}="F:/oracle/ora92";


print "Content-type:text/html\n\n";
print <<HEADER;
<HTML>
<HEAD>
<TITLE>A Test Page</TITLE>
</HEAD>
<BODY BGCOLOR ="#FFFFFF" TEXT="#000000">
<P>
HEADER


print "Connecting to DB..<br>\n";
$dbh = DBI->connect( 'dbi:Oracle:Mysid','SYSTEM','pawel', \%attr)
  or die "Can't connect to database: $DBI::errstr\n";
print "Connected<br>\n";
print "Create sql statement<br>\n";


$sth = $dbh->prepare( "SELECT * FROM Scott.dept" )
or die "Can't prepare SQL statement: $DBI::errstr\n";

print "Exec sql statement<br>\n";

$sth->execute
or die "Can't execute SQL statement: $DBI::errstr\n";

### Retrieve the returned rows of data
while ( my @row = $sth->fetchrow_array() ) {
    print "Row: @row\n";
}

warn "Data fetching terminated early by error: $DBI::errstr\n"
if $DBI::err;


$dbh->disconnect();

Results in a browser:
Connecting to DB..







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

Date: Thu, 10 Jul 2003 17:44:03 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: iis and dbi
Message-Id: <mbudash-D5B489.10440810072003@typhoon.sonic.net>

In article <YyhPa.24090$Aw.17715@twister.nyc.rr.com>,
 "John Giblin" <jgiblin@roadrunner.com> wrote:

> Hi,
> 
> I am making a simple program that connects to Oracle  and then display the
> results.  When I exec the program via command like, there does not seem to
> be a problem. When I do it through a browser I do not get any print commands
> past the connection
> 
> here is what I have:
> use strict;
> use DBI;
> 
> my ($dbh, $sth, @row);
> my %attr = (
>     PrintError => 0,
>     RaiseError => 0,
> );
> $ENV{"ORACLE_HOME"}="F:/oracle/ora92";
> 
> 
> print "Content-type:text/html\n\n";
> print <<HEADER;
> <HTML>
> <HEAD>
> <TITLE>A Test Page</TITLE>
> </HEAD>
> <BODY BGCOLOR ="#FFFFFF" TEXT="#000000">
> <P>
> HEADER
> 
> 
> print "Connecting to DB..<br>\n";
> $dbh = DBI->connect( 'dbi:Oracle:Mysid','SYSTEM','pawel', \%attr)
>   or die "Can't connect to database: $DBI::errstr\n";
> print "Connected<br>\n";
> print "Create sql statement<br>\n";
> 
> 
> $sth = $dbh->prepare( "SELECT * FROM Scott.dept" )
> or die "Can't prepare SQL statement: $DBI::errstr\n";
> 
> print "Exec sql statement<br>\n";
> 
> $sth->execute
> or die "Can't execute SQL statement: $DBI::errstr\n";
> 
> ### Retrieve the returned rows of data
> while ( my @row = $sth->fetchrow_array() ) {
>     print "Row: @row\n";
> }
> 
> warn "Data fetching terminated early by error: $DBI::errstr\n"
> if $DBI::err;
> 
> 
> $dbh->disconnect();
> 
> Results in a browser:
> Connecting to DB..

try:

use strict;
use DBI;
use CGI::Carp qw/fatalsToBrowser/;

my ($dbh, $sth, @row);
my %attr = (
    PrintError => 1,
    RaiseError => 1,
);

etc.

hth
-- 
Michael Budash


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

Date: Thu, 10 Jul 2003 12:33:13 -0500
From: "Bob" <rpl-erroroneous@goldengate.net>
Subject: NET::FTP  ls error
Message-Id: <3f0da34a$0$99$8f4e7992@newsreader.goldengate.net>

running on w2k pro sp2  system.  Code is:

#  ftptst.plx - 10 July 2003.   testing ftp script
use warnings;
use strict;
use Net::FTP;
my ($hostname, $username, $password, $directory, $filename, $ftpobj, @last);
#declaration of parameters
$hostname="ftp.nowhere.com";
$username="anonymous";
$password="tst\@tsthere";
$directory="/pub";
$filename="*.txt";

$ftpobj = Net::FTP -> new ($hostname);
$ftpobj -> login($username, $password);
$ftpobj -> cwd ($directory);
@last = ftp->ls($filename) or die "No $filename found.\n";
$ftpobj -> quit;
--------------------  end of code ---------------------------
The above code works -  the error is with the line requesting   ls
        @last = ftp->ls($filename) or die "No $filename found.\n";

the error reported is:
    D:\perl\srccode\ftp>perl ftptst.plx
    Can't locate object method "ls" via package "ftp" (perhaps you forgot to
load "ftp"?) at ftptst.plx line 25.

Questions:
1.  Doesnt  the line --   use NET::FTP    --   load "ftp" ???
2.  Is there a source for examples of  using net::ftp?

thanks
r









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

Date: Thu, 10 Jul 2003 17:39:19 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: NET::FTP  ls error
Message-Id: <mbudash-EFA94D.10392510072003@typhoon.sonic.net>

In article <3f0da34a$0$99$8f4e7992@newsreader.goldengate.net>,
 "Bob" <rpl-erroroneous@goldengate.net> wrote:

> running on w2k pro sp2  system.  Code is:
> 
> #  ftptst.plx - 10 July 2003.   testing ftp script
> use warnings;
> use strict;
> use Net::FTP;
> my ($hostname, $username, $password, $directory, $filename, $ftpobj, @last);
> #declaration of parameters
> $hostname="ftp.nowhere.com";
> $username="anonymous";
> $password="tst\@tsthere";
> $directory="/pub";
> $filename="*.txt";
> 
> $ftpobj = Net::FTP -> new ($hostname);
> $ftpobj -> login($username, $password);
> $ftpobj -> cwd ($directory);
> @last = ftp->ls($filename) or die "No $filename found.\n";
> $ftpobj -> quit;
> --------------------  end of code ---------------------------
> The above code works -  the error is with the line requesting   ls
>         @last = ftp->ls($filename) or die "No $filename found.\n";
> 
> the error reported is:
>     D:\perl\srccode\ftp>perl ftptst.plx
>     Can't locate object method "ls" via package "ftp" (perhaps you forgot to
> load "ftp"?) at ftptst.plx line 25.
> 

s/b:

@last = $ftpobj -> ls($filename) or die "No $filename found.\n";

> Questions:
> 1.  Doesn't the line --   use NET::FTP    --   load "ftp" ???

no. it loads a set of methods, mainly.

> 2.  Is there a source for examples of  using net::ftp?

perldoc Net::FTP

-- 
Michael Budash


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

Date: Thu, 10 Jul 2003 12:48:37 -0500
From: "Bob" <rpl-erroroneous@goldengate.net>
Subject: Re: NET::FTP  ls error
Message-Id: <3f0da6e5$0$100$8f4e7992@newsreader.goldengate.net>

Hi Michael -

thanks.

another question..   to avoid these really "bad" mistakes, is there some
kind of checker program that checks the code for content or properly defined
statement, etc...




"Michael Budash" <mbudash@sonic.net> wrote in message
news:mbudash-EFA94D.10392510072003@typhoon.sonic.net...
> In article <3f0da34a$0$99$8f4e7992@newsreader.goldengate.net>,
>  "Bob" <rpl-erroroneous@goldengate.net> wrote:
>
> > running on w2k pro sp2  system.  Code is:
> >
> > #  ftptst.plx - 10 July 2003.   testing ftp script
> > use warnings;
> > use strict;
> > use Net::FTP;
> > my ($hostname, $username, $password, $directory, $filename, $ftpobj,
@last);
> > #declaration of parameters
> > $hostname="ftp.nowhere.com";
> > $username="anonymous";
> > $password="tst\@tsthere";
> > $directory="/pub";
> > $filename="*.txt";
> >
> > $ftpobj = Net::FTP -> new ($hostname);
> > $ftpobj -> login($username, $password);
> > $ftpobj -> cwd ($directory);
> > @last = ftp->ls($filename) or die "No $filename found.\n";
> > $ftpobj -> quit;
> > --------------------  end of code ---------------------------
> > The above code works -  the error is with the line requesting   ls
> >         @last = ftp->ls($filename) or die "No $filename found.\n";
> >
> > the error reported is:
> >     D:\perl\srccode\ftp>perl ftptst.plx
> >     Can't locate object method "ls" via package "ftp" (perhaps you
forgot to
> > load "ftp"?) at ftptst.plx line 25.
> >
>
> s/b:
>
> @last = $ftpobj -> ls($filename) or die "No $filename found.\n";
>
> > Questions:
> > 1.  Doesn't the line --   use NET::FTP    --   load "ftp" ???
>
> no. it loads a set of methods, mainly.
>
> > 2.  Is there a source for examples of  using net::ftp?
>
> perldoc Net::FTP
>
> --
> Michael Budash




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

Date: 10 Jul 2003 07:16:07 -0700
From: jameskirby@hotmail.com (Orisopha)
Subject: Newbie Perl Question: RE Configuration Files
Message-Id: <80da20be.0307100616.22a8eb3@posting.google.com>

Dear all, 

I'm just beginning my voyage on the Perl adventure, and have covered
the basics.  I now need to develop a program which can handle
configuration files.

After reading several posts, I can see that there is a debate about
using your own bespoke config language or to use Perl itself.

Could someone (with the aid of a small example) explain how to use the
Perl alternative.

Thanks very much in advance,

Jim


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

Date: Thu, 10 Jul 2003 08:49:39 -0600
From: Nick Pinckernell <nap@illx.org>
Subject: Re: Newbie Perl Question: RE Configuration Files
Message-Id: <3F0D7D03.A03E43C8@illx.org>

Orisopha wrote:

> Could someone (with the aid of a small example) explain how to use the
> Perl alternative.

A very simple config file that looked like:

#comment here
BLAH             = 4
MOREBLAH = another_value

Could be read with this little snippit taken right from the Cookbook:

while(<CONFIG>) {
   chomp;
   s/#.*//;
   s/^\s+//;
   s/\s+$//;
   next unless length;
   my ($var, $value) = split(/\s*=\s*/, $_, 2);
   $User_Preferences{$var} = $value;
}

_nick



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

Date: Thu, 10 Jul 2003 23:17:41 +0530
From: Thens <thens@nospam.com>
Subject: Re: Newbie Perl Question: RE Configuration Files
Message-Id: <20030710231741.3d612da8.thens@nospam.com>

On 10 Jul 2003 07:16:07 -0700
jameskirby@hotmail.com (Orisopha) wrote:

>Dear all, 
>
>
>After reading several posts, I can see that there is a debate about
>using your own bespoke config language or to use Perl itself.
>
>Could someone (with the aid of a small example) explain how to use the
>Perl alternative.


    The intelligent ones will use the Config::General or Config::Simple
and save themselves of all the trouble of parsing config files.. But if
your application does not require complex constructs like nested
information or record like data then you are better off using simple
perl files that you can just 'do' or require in your file.

  http://search.cpan.org for more details on those modules

Regards,
Thens.


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

Date: 10 Jul 2003 08:44:08 -0700
From: pemente@northpark.edu (Eric Pement)
Subject: Perl FAQ error in "variable as a variable name"
Message-Id: <227a55e9.0307100744.6170bb93@posting.google.com>

In trying to learn about references, I believe I've found an error in
the Perl FAQ, section 7 ("General Perl Language Issues"), under the
question, "How can I use a variable as a variable name?" The problem
exists in the documentation for Perl 5.6 and Perl 5.8. I tried
emailing the FAQ keepers a while ago and got no response. Maybe
somebody can confirm or correct me here. (smile)

The FAQ currently reads in part:

   By using symbolic references, you are just using the package's
   symbol-table hash (like %main::) instead of a user-defined hash.
   The solution is to use your own hash or a real reference instead.

       $fred    = 23;
       $varname = "fred";
       $USER_VARS{$varname}++;  # not $$varname++

This solution does not work and does not provide "24" as one would
expect. You can prove it by just running the script:

    #!/usr/bin/perl
    use strict;
    my ($fred, $varname, %USER_VARS);
    $fred    = 23;
    $varname = "fred";
    $USER_VARS{$varname}++;
    print "Value is: $USER_VARS{$varname}\n";

The output is "Value is: 1". So how should this be corrected? Here's
the replacement I suggest for the FAQ. It returns "24", as expected:

    $USER_VARS{fred} = 23;
    $varname         = "fred";
    $USER_VARS{$varname}++;  # not $$varname++

Is this indeed the "proper" or intended solution?

Finally, the FAQ says another solution is to use a real reference
instead. Am I correct in thinking that such a solution would look like
this, or would this not meet the needs of the original "request" posed
in the Perl FAQ?

    $fred       = 23;
    $varname    = \$fred;
    $$varname++; 

Thanks in advance for courteous treatment here.

Eric Pement


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

Date: 10 Jul 2003 09:50:11 -0700
From: pemente@northpark.edu (Eric Pement)
Subject: Re: Q- Empirical usable upper limit on hash array number of elements
Message-Id: <227a55e9.0307100850.1319c430@posting.google.com>

carltonbrown@hotmail.com (Carlton Brown) wrote in message news:<aa611a32.0307090638.23f8297f@posting.google.com>...

> The essence of the problem is to take extremely large list A, compare
> it to slightly smaller list B, and identify the elements from list A
> that are not found in list B.
> 
> Thanks in advance.

   Hope it's not too much off-topic, but if the lists are already
sorted, there is a dedicated Unix utility for this task:

      join -v1 list_a list_b

--
Eric Pement


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

Date: 10 Jul 2003 13:30:25 GMT
From: Tina Mueller <usenet@expires082003.tinita.de>
Subject: Re: Question about Devel::Cover
Message-Id: <bejpph$5nem9$3@ID-24002.news.dfncis.de>

Himal wrote:
> Hi Tina,
> I downloaded it from cpan. 
> tar -xvf
> make 
> make test 
> perl -Mdevel::Cover temp.pl
> There were no error messages during make or make test.

how about "make install"?

hth, tina
-- 
http://www.tinita.de/     \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
- my mail address expires end of august 2003 -


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

Date: Thu, 10 Jul 2003 18:05:38 GMT
From: "nreedr" <infomatic@aol.com>
Subject: Re: Reading Lines into an Array
Message-Id: <4c6ec3f272ff7a7aa925ab8a9d50be5c@free.teranews.com>

Joe, thanks for your help.
I've seen many indications in the Perl doc that hashes are usually the
recommended way to go. In interpreting your code, I'm not quite sure if I
should read the initial list of URL's into the '@to_do' array or the '%seen'
hash or both and I don't see how you're using '@potential_urls'. What is
used as the default keys for the hash? Are you examining the hash keys or
the values to eliminate the dups?
"Joe Smith" <inwap@inwap.com> wrote in message
news:htOOa.290$603.15826@iad-read.news.verio.net...
> In article <82494aaf900ecc16d654970167a0f4db@free.teranews.com>,
> nreedr <infomatic@aol.com> wrote:
> >
> >You're right. I did not state what I was actually trying to accomplish. I
> >guess after a while I just wanted to get the array working. All I wanted
to
> >do was store a variable number of URL's in an array, sort them and output
a
> >sorted list. The code snippet I provided is several iterations removed
from
> >my original algorithm. I'm sure there are probably modules or code out
there
> >that'll do exactly what I'm trying to do and probably way better than
> >anything I could design. I've already created a working Perl utility that
> >will remove dups from a sorted list. I just need one that works for any
> >list.
>
> The list does not have to be sorted to remove duplicates.
> Just use a hash instead of an array.
>
>   my %seen; # Hash of URLs that have been seen already
>   my @to_do; # Array of unique URLs (in order found)
>   foreach (@potential_urls) {
>     push @to_do,$_ unless $seen{$_}++;
>   }
>
> If you're planning to handle URLs in alphabetical order instead of
> in the order they are in the input, you can use this:
>
>   $seen{$_}++ foreach @potential_urls;
>   @to_do = sort keys %seen;
>
>
> > If you can please recommend the following:
> >(a) Any available code and/or module that will do the trick
> >(b) Any decent free Perl tutorial or documentation that would help with
this
> >(the doc that comes with Active Perl is extremely extensive but
frequently
> >lacks real-world examples)
> >Chow ;-)
>
> How about a link-checker?  Randal Schwartz wrote 'slinky'.
> http://www.stonehenge.com/merlyn/WebTechniques/col35.html
>
> Check out his other columns for real-world examples, or go buy
> the Perl Cookbook, 2nd edition, when it becomes available in August.
>   http://www.oreilly.com/catalog/perlckbk2/
>   http://www.oreilly.com/catalog/cookbook/
>
> -Joe
> -- 
> See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.




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

Date: Thu, 10 Jul 2003 14:48:52 +0000
From: Garry Short <g4rry_short@zw4llet.com>
Subject: Re: Regular expression imesh and timesheet
Message-Id: <bejr1b$bih$1$8300dec7@news.demon.co.uk>

TG wrote:

> Helgi Briem wrote:
>> On Wed, 09 Jul 2003 17:53:11 +0200, TG <gallet@free.fr> wrote:
>> 
>> 
>>>i wan't to write a regular expression who match imesh but no match
>>>tIMESHeet. How can i do that ?
>> 
>> 
>> You mean, match a single word only?
>> 
>> Use the boundary matching tag \b
>> 
>> print "Match!" if /\bimesh\b/;
> 
> 
> not exactly, here an example of that i want :
> 
> 
> imesh -> match
> timessheet -> not match
> myimeshsite -> match
> 
> Thank you

In which case, you're going to have to provide a *much* better specification
on what should match, and what should not. Even then, I'm not sure it'll be
possible.

One better approach may be to get a dictionary file (i.e. a file full of
dictionary words - the more the better). Then do something like:



open DICT, "mydictfile" or die "Can't open mydictfile: $!\n";
my @dict = <DICT>;
close DICT;
foreach $word (@dict) {
  $dict_hash{$word} = 1;        # Load the array into a hash
        # (since I couldn't think of how to do it using the filehandle :-)
}
$test_this_word =~ /\b[a-z]+imesh[a-z]+\b/i;
unless ($dict_hash{$word}) {            # Unless this word is in the dictionary hash:
  print "Found iMesh: $test_this_word\n";
}


Totally untested, and straight off the top of my head, but it might be
useful ...

Garry




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

Date: 10 Jul 2003 13:14:17 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: string question
Message-Id: <slrnbgqpl9.ere.sholden@flexal.cs.usyd.edu.au>

On Thu, 10 Jul 2003 03:43:58 -0500, J. Smith <charlie_baratski@yahoo.com> wrote:
> Why use "while/last" when you mean "if"?
> --Because I didn't mean "if". <-ESP? I meant "while".

while (A) {
	B;
	last;
}

is *identical* to

if (A) {
	B;
}

Other than being deceptive and condusing to the next person to 
read the code.

> 
> Why use "$&" when by definition its value is "Re:"?
> --Yes. It's definition is "Re:", but not until it returns true, and I wanted
> to see it. I printed out exactly what I wanted to see. john62 doesn't HAVE
> to do that.
> 
> Why use \" in a ""ed string, when you could use qq{} or similar?
> --It's my preference. I Ran it in a console window. It would've died.
> 
> Go have sex or something Sam. You need to relax.

I'm relaxed. My wife wouldn't appreiciate me having sex right now,
since she's not here and all.

> And please answer this poor man's question.
> I'm obviously not qualified.
> 
> "There's more than one way to do it"

I already said that.

[snip another TOFU - you might want to stop doing that]

-- 
Sam Holden



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

Date: 10 Jul 2003 13:26:57 GMT
From: Tina Mueller <usenet@expires082003.tinita.de>
Subject: Re: string question
Message-Id: <bejpj1$5nem9$2@ID-24002.news.dfncis.de>

Abigail wrote:
> john62@electronmail.com (john62@electronmail.com) wrote on MMMDC
> September MCMXCIII in <URL:news:3f0cee2b$1_2@127.0.0.1>:
> \\  i am a perl novice, and i have a really simple question. 
> \\  what is the easiest way to tell if a string begins with "Re:
> \\  " (without the quotes)?


>     if ("Re:" eq substr $str => 0, 3) {
>         ...
>     }

or:
unless (index $str, "Re:") {
 ...
}
(ok, might be a bit too obfuscating to use index here...)

tina
-- 
http://www.tinita.de/     \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
- my mail address expires end of august 2003 -


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

Date: 10 Jul 2003 13:52:40 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: string question
Message-Id: <slrnbgqrt7.f4e.abigail@alexandra.abigail.nl>

Tina Mueller (usenet@expires082003.tinita.de) wrote on MMMDC September
MCMXCIII in <URL:news:bejpj1$5nem9$2@ID-24002.news.dfncis.de>:
==  Abigail wrote:
== > john62@electronmail.com (john62@electronmail.com) wrote on MMMDC
== > September MCMXCIII in <URL:news:3f0cee2b$1_2@127.0.0.1>:
== > \\  i am a perl novice, and i have a really simple question. 
== > \\  what is the easiest way to tell if a string begins with "Re:
== > \\  " (without the quotes)?
==  
==  
== >     if ("Re:" eq substr $str => 0, 3) {
== >         ...
== >     }
==  
==  or:
==  unless (index $str, "Re:") {
==   ...
==  }
==  (ok, might be a bit too obfuscating to use index here...)


Using index () isn't obfuscated - but suggesting that index () returns
a true/false value *is*.

By all means, if you use index, use it like this:

    if (0 == index $str => "Re:")


The reason I didn't use index() is that if 'Re:' isn't present, it
might scan the entire string.



Abigail
-- 
BEGIN {my $x = "Knuth heals rare project\n";
       $^H {integer} = sub {my $y = shift; $_ = substr $x => $y & 0x1F, 1;
       $y > 32 ? uc : lc}; $^H = hex join "" => 2, 1, 1, 0, 0}
print 52,2,10,23,16,8,1,19,3,6,15,12,5,49,21,14,9,11,36,13,22,32,7,18,24;


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

Date: Thu, 10 Jul 2003 14:33:10 +0100
From: Stuart Moore <stjm2@hermes.cam.ac.uk>
Subject: Stringifying data without newlines.
Message-Id: <Pine.SOL.4.44.0307101426040.11507-100000@red.csi.cam.ac.uk>

I'm looking at ways to stringify large, simple data structures (i.e. non
self-referential multi-dimensional data structures). They're to be passed
over a socket to another perl process in the same machine - currently I
use a newline as a "message terminator", I can change this if necessary
but would perfer not to.

Data::Dumper works with Indent 0 and Useqq 1 (and if the data contains no
newlines I don't need Useqq 1) but it's still a little on the slow side, I
was wondering whether any of the other modules (FreezeThaw, Storable etc)
are also guaranteed not to contain newline characters in their stored
version; neither documentation says anything on this matter.

Any suggestions?

Stuart Moore



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

Date: Thu, 10 Jul 2003 13:47:05 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Stringifying data without newlines.
Message-Id: <vgqrip8etlfq90@corp.supernews.com>

In article <Pine.SOL.4.44.0307101426040.11507-100000@red.csi.cam.ac.uk>,
    Stuart Moore  <stjm2@hermes.cam.ac.uk> wrote:

: I'm looking at ways to stringify large, simple data structures (i.e.
: non self-referential multi-dimensional data structures). They're to be
: passed over a socket to another perl process in the same machine -
: currently I use a newline as a "message terminator", I can change this
: if necessary but would perfer not to.

Why not frame your messages differently?  For example,

    print $sock length($msg), "\n", $msg;

: [...]

Greg
-- 
The popular notion that an increase in the stock of money is socially and
economically beneficial and desirable is one of the great fallacies of our
time . . . It has . . . inflicted incalculable harm . . .
    -- Hans F. Sennholz


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

Date: 10 Jul 2003 10:17:47 -0700
From: john_ramsden@sagitta-ps.com (John Ramsden)
Subject: Wanted - push/rexec/pull script for remote program builds
Message-Id: <d27434e.0307100917.35665a0c@posting.google.com>

I have various ActiveState Perl scripts that run on Windows, Linux,
and Solaris, and soon AIX and possibly others. These must be compiled
using the PDK on each platform to produce a runfile specific to that
platform.

Each time I amend the source I must manually FTP the updated file[s]
to a couple of remote systems, compile it on each of these these,
and FTP the resulting runfiles back to the development system.

Obviously this is very tedious and error prone, and will become more
so the more platforms are involved. So I'd very much like to start
using a simple script that would automate the process.

This wouldn't take me too long to write, but not wanting to reinvent
the wheel I wondered if anyone had or knew of a suitable script that
was already available, preferably in Perl.

It needn't be an all singing and dancing system; in fact I'd rather it
wasn't - All I need is the ability to push a configurable set of files
to a configurable remote directory, rexec a build script there, and
pull back the result[s] as binary files.

Many thanks in anticipation.


Cheers

John Ramsden (john_ramsden@sagitta-ps.com)


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

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


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