[24064] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6261 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 15 21:05:37 2004

Date: Mon, 15 Mar 2004 18:05:06 -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           Mon, 15 Mar 2004     Volume: 10 Number: 6261

Today's topics:
        Absolute wxPerl newbie: Create wxGrid (Piet)
        ANNOUNCE:  Mail-Digest-Tools v2.08 <no_spam_for_jkeen@verizon.net>
        ANNOUNCE: DBD::Sprite does JOINS now! <jim.w.turner@lmco.com>
    Re: block of code doesn't get executed <dwall@fastmail.fm>
    Re: block of code doesn't get executed (stalwart)
    Re: block of code doesn't get executed (stalwart)
    Re: browser tries to download perl code <tore@aursand.no>
    Re: cgi & javascript (Malcolm Dew-Jones)
    Re: cgi & javascript <noreply@gunnar.cc>
    Re: Hash as a function argument.. plz help! <dwall@fastmail.fm>
    Re: How to remove lines containing "continuation" opera <krahnj@acm.org>
    Re: How to remove lines containing "continuation" opera (Chris Charley)
    Re: How to remove lines containing "continuation" opera (Chris Charley)
    Re: Matching File Content Values within Multiple Folder <tore@aursand.no>
    Re: Matching File Content Values within Multiple Folder <krahnj@acm.org>
    Re: Matching File Content Values within Multiple Folder <wksmith@optonline.net>
    Re: No more handles error with DBD::DB2 on Linux <shah@typhoon.xnet.com>
    Re: open(filehandle... is failing <dave@nowhere.com>
        problem passing args with system function <sugargenius@houston.rr.com>
    Re: socket problem <ThomasKratz@REMOVEwebCAPS.de>
        system(...) does not produce output using 5.8.* (Manzoor Ilahi)
    Re: Text editor implemented in Perl <*@eli.users.panix.com>
    Re: variable initialization question ctcgag@hotmail.com
        What is that tab char? <jillfr@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 15 Mar 2004 14:26:29 -0800
From: pit.grinja@gmx.de (Piet)
Subject: Absolute wxPerl newbie: Create wxGrid
Message-Id: <39cbe663.0403151426.29f852f@posting.google.com>

Hi there!
Some time ago, I started learning scripting languages to produce small
GUI apps. Perl/TK didn´t fit my needs, and I finally started learning
Python and the WxPython toolkit. I like both, but Perl seems far
superior to python in terms of third-party modules. I just found out
that the wx toolkit also exists for perl, but now I am stuck in a
(very probably entirely trivial) problem: I wanted to set up a wxGrid
using the following code:
#!/usr/bin/perl -w

use strict;
use Wx;

###########################################################
package MyGrid;
use base qw(Wx::Grid);
sub init{
    my $class = shift;
    my $this = $class->SUPER::new($_[0],-1);
    $this->CreateGrid(5,5);
    return $this;}
###########################################################
package MyFrame;
use base qw(Wx::Frame);
sub init {
    my $parent = shift;
    my $self = $parent->SUPER::new(@_); #call constructor of base
class
    my $panel = Wx::Panel->new($self,-1);
    $self->{grid} = MyGrid->init($panel);
#    $self->{grid}->CreateGrid(4,5);
    return $self;}
###########################################################
package MyApp;
use base qw(Wx::App);   # Inherit from Wx::App
sub OnInit {
    my $self = shift;
    my $frame = MyFrame->init(undef,1,"Simple Perl wxGrid", # Title
        [1,1],         # position X, Y
        [640, 480]     # size X, Y
        );
    $self->SetTopWindow($frame);    # Define the toplevel window
    $frame->Show(1);                # Show the frame
}
###########################################################
package main;

my $wxobj = MyApp->new(); # New HelloWorld application
$wxobj->MainLoop;

THe app is interpreted without errors, and the frame and panel show up
on the screen, but there is no grid. What have I done wrong? I think
it must have to do something with the class setup, but I haven´t (yet)
understood how these things work in Perl.
Many thanks for your help.

Peter


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

Date: Mon, 15 Mar 2004 23:09:11 GMT
From: "Jim Keenan" <no_spam_for_jkeen@verizon.net>
Subject: ANNOUNCE:  Mail-Digest-Tools v2.08
Message-Id: <Hun6xw.11AH@zorch.sf-bay.org>

I have uploaded Perl extension Mail::Digest::Tools to CPAN.  It is available
at http://search.cpan.org/~jkeenan/Mail-Digest-Tools-2.08/ and on CPAN
mirrors.  So far it has passed tests on Linux, Darwin, Solaris and MSWin32.
(There are certain operating systems such as pre-OS X Mac and VMS on which
Mail::Digest::Tools is NOT currently expected to work.)

>From the POD:  "Mail::Digest::Tools provides useful tools for processing
mail which an individual receives in a 'daily digest' version from a mailing
list. Digest versions of mailing lists are provided by a variety of mail
processing programs and by a variety of list hosts. Within the Perl
community, digest versions of mailing lists are offered by such sponsors as
Active State, Sourceforge, Yahoo! Groups and London.pm. However, you do not
have to be interested in Perl to make use of Mail::Digest::Tools. Mail from
any of the thousands of Yahoo! Groups, for example, may be processed with
this module."

Please send comments with 'Mail-Digest-Tools' or 'Mail::Digest::Tools' in
the subject line to jkeenan [at] cpan [dot] org.  Enjoy.







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

Date: Mon, 15 Mar 2004 17:41:38 GMT
From: "Jim Turner's LMAERO News" <jim.w.turner@lmco.com>
Subject: ANNOUNCE: DBD::Sprite does JOINS now!
Message-Id: <Hun6y5.1Fyx@zorch.sf-bay.org>

Greetings fellow Perl/DBI users:

I am pleased to announce that DBD::Sprite now supports basic 2-table
inner-joins as of version 0.50, an oft-requested feature.  This is my
first stab at joins and it should be considered alpha.  This is the
only type of joins currently supported. Other aspects of DBD::Sprite
should now be considered production quality (but use at your own risk
- no warentees expressed or implied!)

For example, if one had the following 2 tables:

Students:

first            last         age
================ ============ ===
Joe              Smith        20
Susan            Mitchel      21
Bob              Miller       19
Richard          Smith        21

Employees:

first            last         company
================ ============ ================
Bob              Jones        Acme
Mike             Smith        GM
Mark             Williams     Red Hat

One can now do a query like:

	select s.first, s.last, e.company, s.age
	from students s, employees e
	where s.last = e.last order by s.first, e.company

This would return:

Joe      Smith   GM   20
Richard  Smith   GM   21

I know this isn't the best example, but the one I wanted to use is
copyrighted.

Jim Turner
turnerjw@wwol.com





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

Date: Mon, 15 Mar 2004 19:53:06 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: block of code doesn't get executed
Message-Id: <Xns94AD976B083A1dkwwashere@216.168.3.30>

stalwart <hammer@thatbox.net> wrote:

> I"m fairly new to perl, 

Ditto what Brian McCauley said.

A few things I noticed:

> #!/usr/bin/perl 
> 
> use Net::FTP ;
> use Date::Parse ;
> $home = "/home/backups/recordings";
> 
> # this should go out before the mp3 backup script runs and get a
> listing for it to use to compare file dates
> chdir $home;

Check to see if chdir() succeeded:

    chdir $home or die "Cannot chdir to $home: $!";

Consider what might happen if, for some reason, the chdir() did not 
succeed. Might be bad, might not be a problem -- but it should be checked 
and appropriate action taken.

[snip]
> print("Getting directory listing of mp3s.....\n");
> %filename =  $ftp->ls
>       or die "Unable to list the dir!:\n", $ftp->message;

The 'ls' method returns a list, which this code... puts into a hash? 
Probably not what you want.

> 
> print("Ok, now I need to do some date checking....\n");
> 
>         foreach($filename) {

$filename has not been used until now, so it's auto-vivified as undef. 
Strictures would have caught this.

>                 s/^_RC//;
>                 s/_RC^/"\n"/;

A carat (^) in a regex means the beginning of a string.  How can '_RC' be 
*before* the beginning of the string? 

>                 };
> 
>         while ($filename)  {

$filename is undefined, so this loop never runs.

[snip rest of code]

I get the impression you're confused about Perl data types. %filename, 
@filename, and $filename can exist in the same program, but they don't 
necessarily have *anything* to do with each other. They are completely 
different variables.

-- 
David Wall


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

Date: 15 Mar 2004 15:14:52 -0800
From: hammer@thatbox.net (stalwart)
Subject: Re: block of code doesn't get executed
Message-Id: <f21704f9.0403151514.759bbd0@posting.google.com>

"David K. Wall" <dwall@fastmail.fm> wrote in message news:<Xns94AD976B083A1dkwwashere@216.168.3.30>...
> stalwart <hammer@thatbox.net> wrote:
> 
> > I"m fairly new to perl, 
> 
> Ditto what Brian McCauley said.
> 
> A few things I noticed:
> 
> > #!/usr/bin/perl 
> > 
> > use Net::FTP ;
> > use Date::Parse ;
> > $home = "/home/backups/recordings";
> > 
> > # this should go out before the mp3 backup script runs and get a
> > listing for it to use to compare file dates
> > chdir $home;
> 
> Check to see if chdir() succeeded:
> 
>     chdir $home or die "Cannot chdir to $home: $!";

Thanks, I missed that the first time.
 
> [snip]
> > print("Getting directory listing of mp3s.....\n");
> > %filename =  $ftp->ls
> >       or die "Unable to list the dir!:\n", $ftp->message;
> 
> The 'ls' method returns a list, which this code... puts into a hash? 
> Probably not what you want.

My intention was to have the filenames in a hash so i could call them
individually with keys to compare file by file the unix timestamps. 
Perhaps I should use an array instead or just not bother with
something like that?
> > 
> > print("Ok, now I need to do some date checking....\n");
> > 
> >         foreach($filename) {
> 
> $filename has not been used until now, so it's auto-vivified as undef. 
> Strictures would have caught this.
> 
> >                 s/^_RC//;
> >                 s/_RC^/"\n"/;
> 
> A carat (^) in a regex means the beginning of a string.  How can '_RC' be 
> *before* the beginning of the string? 

Good point, my mistake.  I had thought it meant everything before THAT
string..when I get an ls using the FTP module i needed to get rid of
everything BEFORE the _RC string...again, my mistake.

> 
> >                 };
> > 
> >         while ($filename)  {
> 
> $filename is undefined, so this loop never runs.

ok, makes sense.  thanks.
 
> [snip rest of code]
> 
> I get the impression you're confused about Perl data types. %filename, 
> @filename, and $filename can exist in the same program, but they don't 
> necessarily have *anything* to do with each other. They are completely 
> different variables.

I suppose I am.  I had the impression you could call an array or hash
as $ARRAY or $HASH after they were defined.
Thanks for the help, I will do some strict checking and warnings and
go from there.  I appreciate the help David.


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

Date: 15 Mar 2004 15:21:40 -0800
From: hammer@thatbox.net (stalwart)
Subject: Re: block of code doesn't get executed
Message-Id: <f21704f9.0403151521.105fc460@posting.google.com>

Brian McCauley <nobull@mail.com> wrote in message news:<u9wu5mm1rd.fsf@wcl-l.bham.ac.uk>...
> hammer@thatbox.net (stalwart) writes:
> 
> > Hello everyone.  
> > 
> > I"m fairly new to perl,
> 
> Get into the habit of always declaring all your variables as
> lexically scoped in the smallest applicable scope unless you have a
> positive reason to do otherwise.  Do this from day 0.  Do not wait
> until you failure to do so causes you pain.
> 
> Indent your code.

Ok, thanks, good advice.  A newbie mistake I shall correct.  I do have
the code indented better than it pasted here.  My bad.

> Put "use strict" and "use warnings" at the top of your script to help
> Perl to help you.
> 
> > Here is the oode (I aplogize if it's too long and spams up the list):
> 
> I can't be bothered to attempt to figure out what's wrong.  The first
> 5-10 minuites would be spent looking for mistakes that would have
> been avoided if you'd followed the advice above.   If you can't be
> bothered to help yourself you shouldn't expect anyone else to do so.

Hrm, ok, well, thanks for bothering to tell me you can't bother. 
That's constructive enough.  I had no intention of being lazy, I was
unaware this was a better method.

> Random shot in the dark - you have a } in the wrong place.
> 
> Another random shot in the dark, you are confusing exit() and last().

Well, since you can't be bothered to look over the code, I guess these
are just random things to say.  I'll figure it out, thanks anyways.


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

Date: Mon, 15 Mar 2004 21:28:15 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: browser tries to download perl code
Message-Id: <pan.2004.03.15.19.38.07.375407@aursand.no>

On Mon, 15 Mar 2004 09:05:37 -0800, Ki wrote:
> I am currently using apache server and trying to write perl programs.
> It is working for some other perl programs, but my browser tries to
> download not actual output but perl source code.

That is a server issue;  Apache isn't set up to execute the Perl program,
so it will just throw it to the client as it is.

> #!/usr/local/bin/perl

  use strict;
  use warnings;
  use CGI qw(:cgi);

> print "Content-type: text/html/n/n";

  my $CGI = CGI->new();
  print $CGI->header(-type => 'text/html');

> print "<HTML><HEAD><TITLE>Slicer grapher</TITLE></HEAD>";
> print "<BODY BGCOLOR=#99CCFF><BR>";

You should seriously look at some of the Template modules; Mixing
presentation code and Perl code is never a good idea.

> #takes the input from the text box in html and stores value
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> [...]

You won't do this;  CGI.pm will do it for you.

> $date='/bin/data';

No.

> #inputs all the data into a file called file.dat
> `echo "$date" >> ./files.dat`;
> `echo "$Name" >> ./files.dat`;
> `echo "$Number" >> ./files.dat`;
> `echo "$Int" >> ./files.dat`;
> `echo >> ./files.dat`;
> `echo >> ./files.dat`;

No.


-- 
Tore Aursand <tore@aursand.no>
"Omit needless words. Vigorous writing is concise. A sentence should
 contain no unnecessary words, a paragraph no unnecessary sentences,
 for the same reason that a drawing should have no unnecessary lines
 and a machine no unnecessary parts." -- William Strunk Jr.


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

Date: 15 Mar 2004 11:18:36 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: cgi & javascript
Message-Id: <4056018c@news.victoria.tc.ca>

Luca Ferrari (fluca1978@libero.it) wrote:
: Hi,
: I'm developing some cgis using perl to access a database. Often I put a
: button (submit) to delete one or more rows in a table, but I'd like to
: ask the user before doing it. To do so I thought about using javascript,
: and in particular javascript:confirm(..) as onClick property of the
: submit button. The problem is that the form is submitted even if the
: user says no. I've tried with a javascript button but I don't know how
: to post data submitting the form.
: My javascript code to check is:

: Any suggestions on how to ask the user before submitting?

The onclick handler should return a value.

A javascript usenaut could better tell you the syntax and values to use.


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

Date: Mon, 15 Mar 2004 21:19:18 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: cgi & javascript
Message-Id: <c35337$24dgqj$1@ID-184292.news.uni-berlin.de>

Luca Ferrari wrote:
> I'm developing some cgis using perl to access a database. Often I
> put a button (submit) to delete one or more rows in a table, but
> I'd like to ask the user before doing it. To do so I thought about
> using javascript, and in particular javascript:confirm(..) as
> onClick property of the submit button.

What happens if the user has disabled JavaScript?

I don't think it's a good idea to rely on JavaScript for anything that
sounds pretty important. I'd rather have the script print a separate
confirm button, and have it delete rows only when the user clicks that
button.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Mon, 15 Mar 2004 20:06:04 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: Hash as a function argument.. plz help!
Message-Id: <Xns94AD999D88A71dkwwashere@216.168.3.30>

<$_@_.%_> wrote:
 
> Karel Kubat <karel@e-tunity.com> wrote in message-id:
><4055ce4a$0$161$e4fe514c@dreader5.news.xs4all.nl>
>>
>>I have a problem with a snippet of code. I'm trying to pass a hash as an
>>argument to a function. Below is some test code:
>>
> 
> I think you have to pass a referance to the subroutine.

That's one way.
 
> $href = \%hash;
> somesub($href);

Or just

    somesub(\%hash);

You *can* do it that way, but you don't have to.

    sub somesub {
        my %arg = @_;
        print "$_ => $arg{$_}\n" for keys %arg;
    }

    my %hash = (arg1=>'val1', arg2=>'val2');

    somesub(%hash);
    # or....
    somesub(arg1=>'val1', arg2=>'val2');

will work fine. 

It's a way to get named arguments if you want them.

-- 
David Wall


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

Date: Mon, 15 Mar 2004 22:23:00 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: How to remove lines containing "continuation" operator
Message-Id: <40562CBC.9EC516FB@acm.org>

werlax wrote:
> 
> I am looking for a way to process a file containing C code and remove
> specific lines.  These lines can be more than one line long and,
> therefore, may have the \ operator at the end of the line.  Currently
> I am setting a variable when the \ is found and removing any lines
> that follow until no more \ are found.  It seems to me that I should
> be able to use a more simple method but I don't know how I could do
> this.  I was hoping to come up with a simple -i -e method.  Is this
> possible?
> 
> An example line.  All lines to be removed begin with the "#pragma"
> statement.
> 
> #pragma export(ConfigurationRepository::write\
>    (char** ppsBuffer,const string& strTSTAMP_TRANS,\
>    const short iUNIQUENESS_KEY))
> 
> I hope I provided enough information.
> Thanks for any help!


perl -i -ne'
if ( /^#pragma/ and /\\$/ ) {
    $_ = <> while /\\$/
    }
else {
    print
    }
' *.c



John
-- 
use Perl;
program
fulfillment


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

Date: 15 Mar 2004 15:00:35 -0800
From: charley@pulsenet.com (Chris Charley)
Subject: Re: How to remove lines containing "continuation" operator
Message-Id: <4f7ed6d.0403151500.40348d42@posting.google.com>

werlax@hotmail.com (werlax) wrote in message news:<744cd116.0403150643.5e3c96e3@posting.google.com>...
> "Suresh Govindachar" <sgovindachar@yahoo.com> wrote in message news:<7IP4c.8492$_3.107020@typhoon.sonic.net>...
> > my $onelinertemplate = '^\s*#pragma.*[^\\\\\\r\\n]+$';
> > my $starttemplate    = '^\s*#pragma.*\\\\$';
> > my $endtemplate      = '[\\\\]$';
> > 
> > my @non_pragma_c;
> > 
> > push @non_pragma_c,
> >      grep !(/$starttemplate/ .. !/$endtemplate/),
> >      grep !/$onelinertemplate/, (<DATA>);
> > 
> > print @non_pragma_c;
> > 
> I've added the line 
> local ($^I, @ARGV) = ('.bak', glob("*.cpp"));
[snip]

perldoc perlrun

Will explain it. Scroll down to the '-i' command switch.

Chris


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

Date: 15 Mar 2004 15:00:36 -0800
From: charley@pulsenet.com (Chris Charley)
Subject: Re: How to remove lines containing "continuation" operator
Message-Id: <4f7ed6d.0403151500.64d48cb7@posting.google.com>

werlax@hotmail.com (werlax) wrote in message news:<744cd116.0403150643.5e3c96e3@posting.google.com>...
> "Suresh Govindachar" <sgovindachar@yahoo.com> wrote in message news:<7IP4c.8492$_3.107020@typhoon.sonic.net>...
> > my $onelinertemplate = '^\s*#pragma.*[^\\\\\\r\\n]+$';
> > my $starttemplate    = '^\s*#pragma.*\\\\$';
> > my $endtemplate      = '[\\\\]$';
> > 
> > my @non_pragma_c;
> > 
> > push @non_pragma_c,
> >      grep !(/$starttemplate/ .. !/$endtemplate/),
> >      grep !/$onelinertemplate/, (<DATA>);
> > 
> > print @non_pragma_c;
> > 
> I've added the line 
> local ($^I, @ARGV) = ('.bak', glob("*.cpp"));
[snip]

perldoc perlrun

Will explain it. Scroll down to the '-i' command switch.

Chris


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

Date: Mon, 15 Mar 2004 21:28:14 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Matching File Content Values within Multiple Folder
Message-Id: <pan.2004.03.15.20.07.53.518891@aursand.no>

On Mon, 15 Mar 2004 10:46:35 -0800, KP wrote:
> I have a directory C:\Temp that contains multiple folders (300) to be
> exact each one increments.
> 
> C:\temp\CL_100
> C:\temp\CL_101
> 
> Within each of those 300 folders is a text file. Each text file
> contains many of the same values however each one has 3 minor
> differences between them.
> 
> FileName: Info.txt
> 
> ID 1 Blah
> ID 3 Pizza
> ID 30 Beer
> ID 31 Blah
> ID 32 Blah
> ID 58 Pepto
> 
> I would like to be able to loop through all directories within C:\temp
> from CL_1 to CL_300 read each Info.txt trying to match the values I'm
> looking for withing the contents of the file. The goal is to be able
> to print to the console all CL_* folders that contain the Info.txt
> file that has the three values i'm looking for namely Pizza, Beer and
> Pepto.

You should take a look at the File::Find::Rule module.  I haven't been
using it too much myself, but according to the documentation it seems like
you can do something like this (untested):

Totally untested;

  #!/usr/bin/perl
  #
  use strict;
  use warnings;
  use File::Find::Rule;

  my $rule = File::Find::Rule->new();
  $rule->file();
  $rule->name( 'Info.txt' );
  $rule->grep( qr/Pizza/ && qr/Beer/ && qr/Pepto/ );
  my @files = $rule->in( 'c:\temp' );


-- 
Tore Aursand <tore@aursand.no>
"I didn't have time to write a short letter, so I wrote a long one
 instead." -- Mark Twain


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

Date: Mon, 15 Mar 2004 23:00:55 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Matching File Content Values within Multiple Folder
Message-Id: <405635A1.3498F946@acm.org>

KP wrote:
> 
> I have a directory C:\Temp that contains multiple folders (300) to be
> exact each one increments.
> 
> C:\temp\CL_100
> C:\temp\CL_101
> 
> Within each of those 300 folders is a text file. Each text file
> contains many of the same values however each one has 3 minor
> differences between them.
> 
> FileName: Info.txt
> 
> ID 1 Blah
> ID 3 Pizza
> ID 30 Beer
> ID 31 Blah
> ID 32 Blah
> ID 58 Pepto
> 
> I would like to be able to loop through all directories within C:\temp
> from CL_1 to CL_300 read each Info.txt trying to match the values I'm
> looking for withing the contents of the file. The goal is to be able
> to print to the console all CL_* folders that contain the Info.txt
> file that has the three values i'm looking for namely Pizza, Beer and
> Pepto.
> 
> open (FILE, $filename) or die "Could not read file: $!";
> while ($filename = <FILE>) {
>     if ($filename =~ /.*Pizza.*/) {
>         while ($match2 = <FILE>) {
>             if ($match2 =~ /.*Beer.*/) {
>                 while ($match3 = <FILE>) {
>                     if ($match3 =~ /.*Pepto.*/) {
>                     $matchfound = $matchfound .';'. $1;
>                     }
>                 }last;
>             }
>         }
>     }
> }

Untested.

$/ = undef;
@ARGV = <C:/temp/CL_*/Info.txt>;
while ( <> ) {
    print "$ARGV\n" if /Pizza/ and /Beer/ and /Pepto/;
    }

__END__



John
-- 
use Perl;
program
fulfillment


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

Date: Mon, 15 Mar 2004 23:18:00 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: Matching File Content Values within Multiple Folder
Message-Id: <IQq5c.50652$Sp2.13855209@news4.srv.hcvlny.cv.net>


"KP" <snazystyl@hotmail.com> wrote in message
news:dc2b0830.0403151046.7db67cb@posting.google.com...
> I have a directory C:\Temp that contains multiple folders (300) to be
> exact each one increments.
>
> C:\temp\CL_100
> C:\temp\CL_101
>
> Within each of those 300 folders is a text file. Each text file
> contains many of the same values however each one has 3 minor
> differences between them.
>
> FileName: Info.txt
>
> ID 1 Blah
> ID 3 Pizza
> ID 30 Beer
> ID 31 Blah
> ID 32 Blah
> ID 58 Pepto
>
> I would like to be able to loop through all directories within C:\temp
> from CL_1 to CL_300 read each Info.txt trying to match the values I'm
> looking for withing the contents of the file. The goal is to be able
> to print to the console all CL_* folders that contain the Info.txt
> file that has the three values i'm looking for namely Pizza, Beer and
> Pepto.
>
<snip sample code>

Do you want to print all the Pizza, Beer, and Pepto lines?

use strict;
use warnings;

foreach my $seg (1..300){ # To test, Change '300' to '1'
 my $filename = "C:\\Temp\\CL_"
  .sprintf('%d',$seg).
  "\\infotxt";
 open INFILE, $filename or do{
  warn "Error:  Unable to open $filename\n";
  next; # Remove for local test case
 };
 local $/ = undef;
 $_ = <INFILE>;
# $_ = <DATA>; # Insert for local test case
 close INFILE;
 if ((my $pizza) = /(.*Pizza)/
   and (my $beer) = /(.*Beer)/
   and (my $pepto) = /(.*Pepto)/
  ){
  print "$filename - $pizza; $beer; $pepto;\n" ;
 }
}
__END__
ID 1 Blah
ID 3 Pizza
ID 30 Beer
ID 31 Blah
ID 32 Blah
ID 58 Pepto

Bill




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

Date: Mon, 15 Mar 2004 23:33:19 +0000 (UTC)
From: Hemant Shah <shah@typhoon.xnet.com>
Subject: Re: No more handles error with DBD::DB2 on Linux
Message-Id: <c35efv$23i$1@flood.xnet.com>

While stranded on information super highway Darin McBride wrote:
> Hemant Shah wrote:
> 
>> While stranded on information super highway James Willmore wrote:
>>> On Tue, 09 Mar 2004 17:54:28 +0000, Hemant Shah wrote:
>>> 
>>>>   I am not sure if this is a perl of DB2 problem. I had posted this
>>>>   problem last week but did not get any reply. I am posting it again
>>>>   with some more info to see it someone can identiry the problem.
>>> [ ... ]
>>> 
>>> To determine if DBI is at fault or something else is going on, use the
>>> 'trace' method of the DBI module.  I recommend setting it to 4, since you
>>> may have a suttle bug.
>>> 
>>> `perldoc DBI` for more info.
>>> 
>>> HTH
>>> 
>>> --
>>> Jim
>>> 
>>> Copyright notice: all code written by the author in this post is
>>>  released under the GPL. http://www.gnu.org/licenses/gpl.txt
>>> for more information.
>>> 
>>> a fortune quote ...
>>> "And what will you do when you grow up to be as big as me?" asked
>>> the father of his little son.  "Diet."
>>> 
>> 
>> 
>> The problem is in the way DBI, DBD interacts with the database. I added
>> same select statement into a file 1000 times and ran it as follows:
>> 
>> db2 -stf tstdb2.ddl
> 
> Have you tried emailing db2perl@ca.ibm.com with your questions?

Thanks for the e-mail address. I sent the information to the above e-mail
address and next day Michael sent me newer version of dbdimp.c file. I
re-built the DBD::DB2 module and it fixed the problem.



-- 
Hemant Shah                           /"\  ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com       \ /  --------------------- 
                                       X     against HTML mail
TO REPLY, REMOVE NoJunkMail           / \      and postings      
FROM MY E-MAIL ADDRESS.           
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind,                Above opinions are mine only.
it's backed up on tape somewhere.      Others can have their own.


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

Date: Mon, 15 Mar 2004 15:41:02 -0800
From: Dave Smith <dave@nowhere.com>
Subject: Re: open(filehandle... is failing
Message-Id: <dave-E35F07.15410215032004@corp.supernews.com>

I converted to the system command and it is returning a 2 and failing. 
I'm reading the perldoc but I don't see what that would indicate. Thanks 
for all your help.

Dave


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

Date: Tue, 16 Mar 2004 01:52:57 GMT
From: Woody <sugargenius@houston.rr.com>
Subject: problem passing args with system function
Message-Id: <Xns94ADCA3B7DC53sugargeniushoustonrr@24.93.43.119>

I'm about half way through llama book, and I decided to try and write a 
script that scans a text file and wget the urls. I realize wget has an --
input-file option that does the same thing my script is trying to do, but 
I'm doing it merely as an exercise.

The program:

#!/usr/bin/perl -w
use strict;
use warnings;

print "Enter the name of the file you want to process.\n";

chomp( my $dl_list_file = <STDIN> );

open IN, $dl_list_file
        or die "Can't open '$dl_list_file' for input: $!";

while (<IN>) {
        if(/^http/){    #if the line begins with http assume it's a url
                chomp( my $url = $_ );
                print "the url is '$url'\n";  #just for debugging
                system 'wget -bc $url';
        }
}

The text file:
AUDIO
http://ftp.us.dell.com/audio/R66937.EXE

BIOS
http://ftp.us.dell.com/bios/BR71964.exe

NETWORK
http://ftp.us.dell.com/network/R67150.EXE

VIDEO
http://ftp.us.dell.com/video/1312KA02.EXE


The output:

[woody@homebase bin]$ ./dl.pl
Enter the name of the file you want to process.
4600
the url is 'http://ftp.us.dell.com/audio/R66937.EXE'
wget: missing URL
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.
the url is 'http://ftp.us.dell.com/bios/BR71964.exe'
wget: missing URL
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.
the url is 'http://ftp.us.dell.com/network/R67150.EXE'
wget: missing URL
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.
the url is 'http://ftp.us.dell.com/video/1312KA02.EXE'
wget: missing URL
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.

Why is wget not getting the url?

Thanks,
Woody


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

Date: Mon, 15 Mar 2004 20:19:12 +0100
From: Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: socket problem
Message-Id: <405602d2.0@juno.wiesbaden.netsurf.de>

Sébastien Cottalorda wrote:

[snipped]

> unless ($socket = IO::Socket::INET->new(PeerAddr=> 'aaa.bbb.ccc.ddd',
>                                 PeerPort=> '21110',
>                                 Proto=> "tcp",
>                                 Timeout=>10,
>                                 Type=> SOCK_STREAM))
>     {
>         print ("Unable to connect \n");
>         exit 1;
>     }
> my $s=IO::Select->new();
> $s->add($socket);
> while(1){
>     if ($s->can_write(10)){      # ===>>> OK even if the socket is closed
>         unless ($socket->send('@025123459876556789L@@')){ #====>CRASH-->bash
>             print "Unable to write\n";
>             last;
>         }
>         print "sent\n";

you could check with $socket->connected() whether the socket is still 
valid or check with $s->has_exception() whether there are sockets that 
have those.

Thomas

-- 
open STDIN,"<&DATA";$=+=14;$%=50;while($_=(seek( #J~.> a>n~>>e~.......>r.
STDIN,$:*$=+$,+$%,0),getc)){/\./&&last;/\w| /&&( #.u.t.^..oP..r.>h>a~.e..
print,$_=$~);/~/&&++$:;/\^/&&--$:;/>/&&++$,;/</  #.>s^~h<t< ..~. ...c.^..
&&--$,;$:%=4;$,%=23;$~=$_;++$i==1?++$,:_;}__END__#....>>e>r^..>l^...>k^..


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

Date: 15 Mar 2004 18:02:33 -0800
From: sbix650@hotmail.com (Manzoor Ilahi)
Subject: system(...) does not produce output using 5.8.*
Message-Id: <68b0f42a.0403151802.7eb723d4@posting.google.com>

Hi

I have a program that contains the following code 

log_message("executing system($command)");
return (system("$command") == 0);

I run this on an NT machine using Cygwin.  Using Perl 5.6.1, I get the
"$command"'s output on the screen.  But with Perl 5.8.* I do not see
any output.

I would like to migrate our code to use 5.8, but cannot because the
output of the commands we run is essential.  Can someone tell me what
could be causing the lack of output?  The command used in 99% of the
cases is a java invocation (e.g. java -Xms128m -Xmx256m
org.apache.tools.ant.Main .... ).

Thanks,
sb

Summary of my perl5 (revision 5 version 8 subversion 3) configuration:
  Platform:
    osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    usethreads=undef use5005threads=undef useithreads=define
usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cl', ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32
-D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT  -DNO_HASH_
SEED -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO
-DPERL_MSVCRT_READFIX',
    optimize='-MD -Zi -DNDEBUG -O1',
    cppflags='-DWIN32'
    ccversion='', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
    ivtype='long', ivsize=4, nvtype='double', nvsize=8,
Off_t='__int64', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf 
-libpath:"C:\Perl.803\lib\CORE"  -machine:x86'
    libpth=C:\PROGRA~1\MICROS~3\VC98\lib
    libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
 comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib  netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib 
version.lib odbc32.lib odbccp32.lib msvcrt.lib
    perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.
lib oleaut32.lib  netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib 
version.lib odbc32.lib odbccp32.lib msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
    gnulibc_version='undef'
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug
-opt:ref,icf  -libpath:"C:\Perl.803\lib\CORE"  -machine
:x86'


Characteristics of this binary (from libperl):
  Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES
PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS
  Locally applied patches:
        ActivePerl Build 809
        22218 Remove the caveat about detached threads crashing on
Windows
        22201 Avoid threads+win32 crash by freeing Perl interpreter
slightly later
        22169 Display 'out of memeory' errors using low-level I/O
        22159 Upgrade to Time::Hires 1.55
        22120 Make 'Configure -Dcf_by=...' work
        22051 Upgrade to Time::HiRes 1.54
        21540 Fix backward-compatibility issues in if.pm
  Built under MSWin32
  Compiled at Feb  3 2004 00:28:51
  @INC:
    c:/Perl.803/lib
    c:/Perl.803/site/lib


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

Date: Mon, 15 Mar 2004 20:36:24 +0000 (UTC)
From: Eli the Bearded <*@eli.users.panix.com>
Subject: Re: Text editor implemented in Perl
Message-Id: <eli$0403151522@qz.little-neck.ny.us>

In comp.lang.perl.misc,
Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote:
> People will probably be using one or the other, but not both. The one
> you start with (and provided you stick with it for a couple of weeks)
> will ultimately be your editor.

Maybe. There is more than one way to edit files, and not everyone likes
all the ways. Some people like to switch from time to time, and some
people like to pick one way and stick with it. But what works for one
person might not work for another.

> Both emacs and vim are "functionally complete", in that they both offer
> everything that could ever be related with file editing.

Even plain old vi is Turing complete, but quite a bit harder to program
than vim or emacs (or perl).

> Also - and to give this a bit of on-topicness - vim has an excellent
> syntax highlighter for Perl code. And this comes as default unlike emacs
> which has two different Perl modes.

"Excellent" must be a very subjective term. I've yet to see an "excellent"
(by my standards) syntax highlighter for Perl code. Just a few days ago
I made the mistake of leaving on the vim syntax highlighting. The code
had a number of lines like:

	@foo = grep /someregexp/, @bar;

Some of which were highlighted correctly, some not. It seems like if
{someregexp} starts with a space or a few other conditions break it.

Elijah
------
back to the original topic, the PPT project has a partial version of 'ed'


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

Date: 15 Mar 2004 20:14:36 GMT
From: ctcgag@hotmail.com
Subject: Re: variable initialization question
Message-Id: <20040315151436.532$bv@newsreader.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
>  <ctcgag@hotmail.com> wrote in comp.lang.perl.misc:
> > Paul Lalli <ittyspam@yahoo.com> wrote:
>
> > > Yes, but before I answer that, you should be asking yourself why
> > > you're doing that.  Perl variables are undef by default, which is
> > > treated as 0 in numeric context.
> >
> > Let's say you are running an accumulator.  It is true that you don't
> > get a warning upon incrementing an undef accumulator.  However, there
> > is no point in having an accumulator which you don't use elsewhere, and
> > when you do use it elsewhere you may find that it will emit errors on
> > the boundary condition that the accumulator was incremented zero times.
> > That's ugly and not particularly desirable.
> >
> > > There's generally no reason to initialize a variable
> > > to 0.
> >
> > Unless you like clean programs.
>
> You're not recommending to initialize *all* variables, are you?

Well, I wasn't explicitly recommending that, but looking over my code
(fgrep my *pl | fgrep -v foreach) I see that I almost always initialize
scalars.  Of course, I usually initialize them to something other than 0
or ''.  And where I don't initialize scalar, it is usually in my oldest
code (or in other people's code), and usually the variable is not being
declared in the best scope.


> There are situations that demand initialization, and you have given
> an example, but that's still a special case.

I understand people use Perl for all different kinds of things, and so
will have differnt experiences, but from my experience if
1) the scalar variable is declared in the right scope, and
2) there is nothing substantial to initialize it to,
then being an accumulator *is* the usual case, and it probably should
be initialized to either 0 or '', depending on how it is used.

Plus, I like the clue that this gives about the variable's use ("hey, this
is an accumulator, and a stringy one at that!")

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Tue, 16 Mar 2004 00:31:11 GMT
From: "Jill" <jillfr@hotmail.com>
Subject: What is that tab char?
Message-Id: <jVr5c.51922$Sp2.14094007@news4.srv.hcvlny.cv.net>

When I create a tab delimited file form perl it is fine and I use the /t
char to designate a tab.
the code in the web page works fine and I can import into my excel
spreadsheet.

I am trying to do the same with html code.
how can I create the same ascii char or control char by using just html.

I am trying to make a table for users to download using tab delimited
import.

Now why can the perl achieve this and not the html?

for example when i run the perl, I just do file-save as and choose txt in
IE6, and all is well.

if not, can javascript do this? what about php.
I can embed that perhaps.

thanks




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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 6261
***************************************


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