[15910] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3323 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 11 18:05:53 2000

Date: Sun, 11 Jun 2000 15:05:12 -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: <960761112-v9-i3323@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 11 Jun 2000     Volume: 9 Number: 3323

Today's topics:
    Re: ANSI Perl: No Way !!! (Douglas Wilson)
    Re: C to perl? <iltzu@sci.invalid>
        Check out www.SmartCGIs.com <xpassx@hotmail.com>
        DBD-ODBC connect gives runtime exception <tfbiv@SPAMMENOTerols.com>
    Re: Does Perl have a simple way to simulate C's "#INCLU <trevor@trevorsky.com>
    Re: DSN-less connection - How To? <tfbiv@SPAMMENOTerols.com>
    Re: DSN-less connection - How To? <jeff@vpservices.com>
        Dummy Variable avoidance <chahn@eleganceintime.com>
    Re: Dummy Variable avoidance <tony_curtis32@yahoo.com>
    Re: Dummy Variable avoidance (jason)
    Re: Dummy Variable avoidance <steve@bleazard.com>
    Re: exists() on sub-hash creates a key in super-hash <donm@ifrance.com>
    Re: Finding repeated words -- e.g. the the (jason)
    Re: Help with chr() function <bwalton@rochester.rr.com>
    Re: how to check for integer? <mariska@excite.nl>
    Re: how to check for integer? <mariska@excite.nl>
    Re: how to check for integer? <tony_curtis32@yahoo.com>
    Re: how to check for integer? (jason)
    Re: how to check for integer? (jason)
    Re: how to escape a slash <godzilla@stomp.stomp.tokyo>
    Re: I need some help with regex. <trevor@trevorsky.com>
    Re: Larry Rosler interview on perl.com! <htp@mac.com>
    Re: modifying/updating CSV fields <mcdonabNO@SPAMyahoo.com>
    Re: now this is strange... <aqumsieh@hyperchip.com>
        Perl Logo? <sven@ps90.de>
    Re: Removing Whitespace <jdNOjdSPAM@syncon.ie.invalid>
    Re: REQUESTED ASCII tables for the Windows 98 version o <iltzu@sci.invalid>
    Re: REQUESTED ASCII tables for the Windows 98 version o <bwalton@rochester.rr.com>
    Re: Trying to figure out how wtmp is packed <imaginos@imaginos.net>
    Re: uses for PERL michaeljgardner@my-deja.com
    Re: Using perl's modules DBD:Mysql and DBI and mysql <jeff@vpservices.com>
        Why /\b\+\b\ matches "x+y" but not "++" or "+"? <02fz@williams.edu>
        Windows<->Macintosh character set translation <melroch@my-deja.com>
    Re: Write to file via CGI script? xenite9@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 11 Jun 2000 19:27:38 GMT
From: dwilson@gtemail.net (Douglas Wilson)
Subject: Re: ANSI Perl: No Way !!!
Message-Id: <3943e1f7.243055@news>

On Sun, 11 Jun 2000 10:57:40 -0700, "Godzilla!" <godzilla@stomp.stomp.tokyo>
wrote:

>Douglas Wilson wrote:
> 
>> On Sun, 11 Jun 2000 09:31:03 -0700, "Godzilla!" 
>
>I will, as with others, ask you to not troll and
>harass me. A troll and harasser like yourself,
>is of no benefit to a newsgroup. You only serve
>to disrupt this newsgroup and deliberately cause
>most unwarranted problems via your trolling
>and harassment of people. Please stop, now.

#!/usr/bin/perl -w

use Kitchen::Cookware;

Pot->Kettle->Black();

Cheers,
Douglas Wilson


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

Date: 11 Jun 2000 19:42:13 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: C to perl?
Message-Id: <960752187.10034@itz.pp.sci.fi>

In article <8h492p$5et$1@news.panix.com>, Abigail wrote:
>Of course, if there would be no bugs in perl, it's trivial to come with
>a C program that has no Perl equivalent. Just write a C program that
>generates a segmentation fault. ;-)

That probably depends on how you define a perl bug.  In my opinion
Perl has a perfectly well defined and documented way to emulate C
pointers, complete with segfaults and all, namely (un)pack "P".

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Sun, 11 Jun 2000 21:35:41 GMT
From: "Jimmy" <xpassx@hotmail.com>
Subject: Check out www.SmartCGIs.com
Message-Id: <NCT05.196287$55.4212879@news2.rdc1.on.home.com>

Check out http://www.smartcgis.com for some unique cgi scripts for your
site.




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

Date: Sun, 11 Jun 2000 15:46:34 -0400
From: Tom Bates <tfbiv@SPAMMENOTerols.com>
Subject: DBD-ODBC connect gives runtime exception
Message-Id: <cmo7ksgu7589jnoanvv8oa6ufdabkm6dvd@4ax.com>

Last week, the statement below worked perfectly well. This week, I get
the not very informative "Error: Runtime exception", with no script
changes. I am hosted on an NT 4.0 server. Anybody have any clues?

  $DBH = DBI->connect('dbi:ODBC:isocontainers.com');

PPM query shows:
DBD-ODBC       [0.22  ] ODBC driver for the DBI module.
DBI            [1.13.1] Database independent interface for Perl

Thanks
Tom


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

Date: Sun, 11 Jun 2000 11:48:51 -0700
From: "Trevor Sky Garside" <trevor@trevorsky.com>
Subject: Re: Does Perl have a simple way to simulate C's "#INCLUDE"?
Message-Id: <S8R05.14615$v_.862356@nntp2.onemain.com>

Or, if someone has a better way to do this altogether, please share!

--Trevor

"Trevor Sky Garside" <trevor@trevorsky.com> wrote in message
news:Q7Q05.15960$bH5.926697@nntp1.onemain.com...
> I now have partial success using "require", however I would like to have a
> "global" hash available to all subroutines - even those inclluded in the
> "require"'d files.  What I am finding is that each file is using its own
> namespace.  How can I make it so that Perl treats all the files as though
it
> was one long script?
>
> --Trevor
>
> "H C" <carvdawg@patriot.net> wrote in message
> news:3943C966.643C9439@patriot.net...
> > "use" or "require"
> >
> > Trevor Sky Garside wrote:
> >
> > > I am now at the point where I need to break my script into multiple
> files to
> > > make it more maintainable.  I'd like to just have one main script that
> does
> > > something similar to a #INCLUDE in C.  I have been fiddling with the
> do()
> > > routine, but have been largely unsuccessful - the subroutines I
declare
> in
> > > the "do" files come up as not being declared.
> > >
> > > Thanks for any help.
> > >
> > > - - - - - - - - - - - - - - - - - - - - - -
> > > Trevor Sky Garside     trevor@trevorsky.com
> > > - - - - - - - - - - - - - - - - - - - - - -
> > > "If there's anything more important than my
> > > ego around here, I want it found and shot."
> > >                        -- Zaphod Beeblebrox
> > > - - - - - - - - - - - - - - - - - - - - - -
> >
>
>




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

Date: Sun, 11 Jun 2000 14:35:53 -0400
From: Tom Bates <tfbiv@SPAMMENOTerols.com>
Subject: Re: DSN-less connection - How To?
Message-Id: <ekm7kskdj0c04j0emd5eos4bga0v6gdgdb@4ax.com>

On Sat, 10 Jun 2000 12:50:50 -0700, Jeff Zucker <jeff@vpservices.com>
wrote:

>Tom Bates wrote:
>> 
>> I'm currently using the DBI and DBD-ODBC modules to connect to a
>> Microsoft Access database on an NT server. Is there a way to set up a
>> DSN-less connection with DBI? Or a way to specify the filename on the
>> connection (which can be done in a VB program by specifying extended
>> attributes)?
>
>This URL is oriented to ADO, but the DSN-less connections it shows work
>with DBD-ODBC also:
>
>http://www.able-consulting.com/ADO_Conn.htm#ODBCDSN-LessConnections

The samples on this page appear to be VB or VBScript. Does anyone know
how to code this in perl's DBI:ODBC fashion? I've tried it many ways
and haven't gotten it to work yet.




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

Date: Sun, 11 Jun 2000 11:42:27 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: DSN-less connection - How To?
Message-Id: <3943DD93.93114BAF@vpservices.com>



Tom Bates wrote:
> 
> On Sat, 10 Jun 2000 12:50:50 -0700, Jeff Zucker <jeff@vpservices.com>
> wrote:
> 
> >Tom Bates wrote:
> >>
> >> I'm currently using the DBI and DBD-ODBC modules to connect to a
> >> Microsoft Access database on an NT server. Is there a way to set up a
> >> DSN-less connection with DBI? Or a way to specify the filename on the
> >> connection (which can be done in a VB program by specifying extended
> >> attributes)?
> >
> >This URL is oriented to ADO, but the DSN-less connections it shows work
> >with DBD-ODBC also:
> >
> >http://www.able-consulting.com/ADO_Conn.htm#ODBCDSN-LessConnections
> 
> The samples on this page appear to be VB or VBScript. Does anyone know
> how to code this in perl's DBI:ODBC fashion? I've tried it many ways
> and haven't gotten it to work yet.

As I said, the examples are for ADO, but they work just fine for
DBD::ODBC.  Here, is one for excel:

my $drv = 'ODBC:driver=Microsoft Excel Driver (*.xls)';
my $dir = 'd:/htdocs/';
my $dbh = DBI->connect("dbi:$drv;Dbq=$dir",'','',{RaiseError=>1});

The one for access is slightly different, follow the example on the ADO
page.

-- 
Jeff


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

Date: Sun, 11 Jun 2000 14:10:09 -0700
From: Christopher Hahn <chahn@eleganceintime.com>
Subject: Dummy Variable avoidance
Message-Id: <39440031.187DC41@eleganceintime.com>

Hello,

This is a newbie-red-flag-avoidance clinic question.

I am wanting to use the new Astro::MoonPhase module
but I only need the percentage of Illumination, the second of
seven items available.

Now in order to avoid the aforementioned "red flags" I tried
using this:
                     (,$MoonIllum,,,,,) = phase();
but this generates an error.

I had previous experimented with:
                     ($MoonPhase,,,,,,) = phase();
and this compiled and ran fine.

Trying to use:
                    ($MoonPhase,$MoonIllum,,,,,) = phase();
but the "-w" flag of my #! line lead to warnings.

What is the best way to avoid dummy variables in this situation?

Thanks for the response!

Christopher




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

Date: 11 Jun 2000 16:13:08 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Dummy Variable avoidance
Message-Id: <871z23c463.fsf@limey.hpcc.uh.edu>

>> On Sun, 11 Jun 2000 14:10:09 -0700,
>> Christopher Hahn <chahn@eleganceintime.com> said:

> Now in order to avoid the aforementioned "red flags" I
> tried using this: (,$MoonIllum,,,,,) = phase(); but this
> generates an error.

Use 'undef' as a place marker

"perldoc -f undef" has an example of this usage.

hth
t
-- 
"Trying is the first step towards failure"
                                           Homer Simpson


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

Date: Sun, 11 Jun 2000 21:45:29 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Dummy Variable avoidance
Message-Id: <MPG.13aea5a95405f6fc98972a@news>

Christopher Hahn writes ..
>This is a newbie-red-flag-avoidance clinic question.
>
>I am wanting to use the new Astro::MoonPhase module
>but I only need the percentage of Illumination, the second of
>seven items available.
>
>Now in order to avoid the aforementioned "red flags" I tried
>using this:
>                     (,$MoonIllum,,,,,) = phase();
>but this generates an error.

you want what's called an array slice .. search for the word 'slice' in

  perldoc perldata

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Sun, 11 Jun 2000 22:49:50 +0100
From: Steve Bleazard <steve@bleazard.com>
Subject: Re: Dummy Variable avoidance
Message-Id: <3944097E.9EAFE943@bleazard.com>

Christopher Hahn wrote:

>                      (,$MoonIllum,,,,,) = phase();
> 
 ....
> What is the best way to avoid dummy variables in this situation?

  $MoonIllum = (phase())[1];

For the simplest case of 1 variable to extract.  To extract more use the
form:

  ($MoonIllum,$MoonDistance) = (phase())[1,7];

What this does is to force the return into array context and then uses
perls array indexing to extract the desired values.

While this is a little esoteric it is more readable than the
alternatives.  Oh, BTW, ($MoonIllum,,,,,,,) works because of perls
tendency to ignore trailing commas in array context (makes machine
generated perl easier!).

Happy Perling, Steve


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

Date: Sun, 11 Jun 2000 22:09:20 +0200
From: "Jean-Michel Marcastel" <donm@ifrance.com>
Subject: Re: exists() on sub-hash creates a key in super-hash
Message-Id: <8i0rn5$2j$1@pollux.ip-plus.net>


"Vincent" <szhzp2@no.spam.com> wrote in message
news:Pine.LNX.4.21.0006071128250.2482-100000@w01b04vc.flur.zuerich.ubs.ch...
> Hi All,
>
> Following program:
> $hash{'foo'}{'bar'} = 'foobar';
> print "PASS 1 ", join(', ', keys(%hash)), "\n";
> print "PASS 2\n" if (exists($hash{'bar'}{'foo'}));
> print "PASS 3 ", join(', ', keys(%hash)), "\n";
> print "PASS 4 $hash{'bar'}\n";
> print "PASS 5 ", join(', ', keys(%{$hash{'bar'}})), "\n";
>
> Produces following output:
> PASS 1 foo
> PASS 3 foo, bar
> PASS 4 HASH(0xb7828)
> PASS 5
>
> Discussion:
> - $hash{'foo'}{'bar'} is set to 'foobar'. (No big deal)
> - Hence, %hash contains one key: 'foo'
> - The test with 'exists()' for $hash{'bar'}{'foo'} obviously fails. But,
>   it seems to create a key 'bar' in %hash with a reference to an empty
>   hash.
> (FYI, 'defined()' in stead of 'exists()' or an assignement like
> '$x = $hash{'bar'}{'foo'}' both produce the same behaviour)
>
> Question:
> Is this behaviour 'as designed', an ommision in the design or a bug?
>

Beyond autovivification, which is definitevely a feature, try using "strict"
to run your test.
All answers will unveil by enchantment !

:)
Don





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

Date: Sun, 11 Jun 2000 20:36:07 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Finding repeated words -- e.g. the the
Message-Id: <MPG.13ae9564c4f5a068989727@news>

Tad McClellan writes ..
>On Sun, 11 Jun 2000 07:02:49 GMT, jason <elephant@squirrelgroup.com> wrote:
>>OBrien-Malone writes ..
>>>I'm new to Perl, but I would like to use it (or perhaps AWK with which
>>>I am much more familiar) to find
>>>repeated words in a TeX document. I mean the simple typing errors where
>>>I would have typed "See the the figure on ..."
>>>Of course the repeated words might be split over lines.
>>>
>>>Can anyone see an easy (Reg Exp) way of doing this?
>>
>>  s/(\w+\s+)\1/$1/g;
>>
>>however .. I should warn you that this will remove valid english as well 
>
>
>You need some word boundaries in there.
>
>   $_ = 'bathe the camel';
>
>becomes 'bathe camel'...

thanks .. I guess the warning was even more valid than I'd intended

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Sun, 11 Jun 2000 18:13:55 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Help with chr() function
Message-Id: <3943D5DB.4D62764F@rochester.rr.com>

michaeljgardner@my-deja.com wrote:
> 
> I'm trying to write binary file sizes to a dbf file.  My perl program
> is using the chr() function.  For some reason it does not return the
> same ascii characters as my other programs.  chr(10) returns either a
> blank or a carriage return from perl, while my other programs, dbase
> included return something that looks like a small circle.
> 
> Are there two different ascii character sets, or am I not using the
> function correctly?
 ...
Depending on your OS and the method you are using to write the
information to your file (both of which you should have included in your
post -- along with the applicable code snippet -- if you actually want
help), you might need to use the binmode function on your filehandle.
-- 
Bob Walton


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

Date: Sun, 11 Jun 2000 21:45:43 +0200
From: "Mariska" <mariska@excite.nl>
Subject: Re: how to check for integer?
Message-Id: <3943ed28$0$2444@reader5>


> If you had checked the Perl FAQ before posting to the Perl
> newsgroup (as good manners requires), then you would know
> how to do that:
>
>    perldoc -q integer
>
>
I did read the FAQ.  I always do before i post.
Mostly i even sleep a night over it before a bother someone else with my
problem.
Thats not a joke!.
The perldoc says 'using int to get the integer part of a number back'.
So if i feed it 3.456 it gives me 3 back.
 I don't need that so assumed 'int' wasn't right for my purpose.

But, the responses are enough for me to get back on track.

Thanx all.
Mariska





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

Date: Sun, 11 Jun 2000 21:49:31 +0200
From: "Mariska" <mariska@excite.nl>
Subject: Re: how to check for integer?
Message-Id: <3943ef49$0$2445@reader5>


>
>   $var =~ /[02468]$/;
>
What if the number is 10?

Mariska




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

Date: 11 Jun 2000 15:12:16 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: how to check for integer?
Message-Id: <874s70asf3.fsf@limey.hpcc.uh.edu>

>> On Sun, 11 Jun 2000 21:49:31 +0200,
>> "Mariska" <mariska@excite.nl> said:

>>  $var =~ /[02468]$/;
>> 
> What if the number is 10?

??

10 matches (ends in one of {0, 2, 4, 6, 8} )

hth
t
-- 
"Trying is the first step towards failure"
                                           Homer Simpson


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

Date: Sun, 11 Jun 2000 21:25:52 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: how to check for integer?
Message-Id: <MPG.13aea105543e9b1c989728@news>

Jonathan Stowe writes ..
>On Sun, 11 Jun 2000 09:32:20 GMT jason wrote:
>> Mariska writes ..
>>>I don't know how to check if a number is an integer.
>>>I need to do something when a number is even.
>>>i divide a number by 2 and i want to check if the result is an integer or
>>>not.
>> 
>> if your end goal is just to determine whether an integer is even or not 
>> then the following Perlistic method is hard to beat
>> 
>>   $var =~ /[02468]$/;
>> 
>
>Oh sure it is yeah nice one :
-
>   my @numbers = (0 .. 100);
-
>Benchmark: timing 10000 iterations of Modulus, Regex...
>   Modulus:  3 wallclock secs ( 2.74 usr +  0.00 sys =  2.74 CPU) @ 3649.64/s (n=10000)
>     Regex:  7 wallclock secs ( 6.25 usr +  0.00 sys =  6.25 CPU) @ 1600.00/s (n=10000)
>
>The moral of the story being to use mathematical operations to solve
>mathematical problems.

your code demonstrates the worst case scenario for the regex and the 
best for the modulus .. Perl has to do a number -> string conversion 
again and again with no possibility of optimisation

below is my comparison .. also for a million effective iterations .. but 
I'm guessing that Perl is able to optimise this so that $num is 
converted to a string once during the regex loop

#!perl -w
use strict;

use Benchmark;

my $x = my $y = 'not even';

my $num = shift;

timethese( 1 << ( shift || 0 )
         , { reg => sub { $x = 'even' unless $num !~ /[02468]$/; }
           , mod => sub { $y = 'even' unless $num % 2; }
           }
         );

print "reg: $x\nmod: $y\n";
__END__

for odd input it gives

  Benchmark: timing 1048576 iterations of mod, reg...
         mod:  2 wallclock secs ( 2.16 usr +  0.00 sys =  2.16 CPU)
         reg:  3 wallclock secs ( 2.41 usr +  0.00 sys =  2.41 CPU)
  reg: not even
  mod: not even

and for even

  Benchmark: timing 1048576 iterations of mod, reg...
         mod:  3 wallclock secs ( 3.44 usr +  0.00 sys =  3.44 CPU)
         reg:  3 wallclock secs ( 3.98 usr +  0.00 sys =  3.98 CPU)
  reg: even
  mod: even

clearly the math solution is still on top .. but not by enough to worry 
(me) about .. and if the input must also be checked to ensure that it's 
an integer then the regex starts pulling ahead

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Sun, 11 Jun 2000 21:27:23 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: how to check for integer?
Message-Id: <MPG.13aea1655920eb5b989729@news>

Mariska writes ..
>
>>
>>   $var =~ /[02468]$/;
>>
>What if the number is 10?

all that the above regex checks is that the LAST character of the input 
is one of '0', '2', '4', '6', '8' .. works for 10, 100, 10000 because 
their last digits are 0

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Sun, 11 Jun 2000 11:59:50 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: how to escape a slash
Message-Id: <3943E1A6.9D80BC93@stomp.stomp.tokyo>

"Andrew G. Bacchi" wrote:

(snipped a bit)
 
> I am trying to concatenate a path to a directory and a file name.
 
> my $wkdir = "$dir\/$working\/$file;"

> Please help, before I do something drastic.

* grins *

Boy do I know this feeling of frustration, Andrew!

You have a very minor common typographical error
in your code which should clear this, after a
couple of changes.

> my $wkdir = "$dir\/$working\/$file;"

Look very close! ;" instead of ";

Don't wig out. We all do these things, over and over!

my $wkdir = "$dir/$working/$file";

Try your line as shown above. I am pretty sure
you will have better luck! Leave out those
backslashes for the syntax you are using.

Andrew, to give you an alternative method to
add to your bag of tricks, down below is a
tiny script with an old fashion way of creating
a path or string, whatever. Not saying you should
do it this way. Tuck this away in your bag of
tricks. It might be useful someday. Please do
look over this script. I have a small note in
there for you about a minor bug which will 
show up in your // print!


Godzilla!



PRINTED RESULTS
_______________

Resulting Path Is: 

     /usr/andrew/setiathome/cache/0/andrew/state.txt

Andrew Method:

     /usr/andrew/setiathome/cache/0/andrew/method/state.txt



TEST SCRIPT
___________


#!/usr/local/bin/perl

print "Content-Type: text/plain\n\n";

$working = "andrew";
$dir = "/usr/andrew/setiathome/cache/0/";
$file = "state.txt";

## key line to create your path:

$wkdir = join ("", $dir, $working, "/", $file);


print "Resulting Path Is: \n
     $wkdir";


## Verify your method works ok:

$working = "andrew/method";
$dir = "/usr/andrew/setiathome/cache/0";
$file = "state.txt";

## Note I deleted the trailing / from $dir
## to prevent // from appearing in your print:

$wkdir = "$dir/$working/$file";

print "\n\nAndrew Method:\n
     $wkdir";

exit;


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

Date: Sun, 11 Jun 2000 11:13:24 -0700
From: "Trevor Sky Garside" <trevor@trevorsky.com>
Subject: Re: I need some help with regex.
Message-Id: <7DQ05.19725$AW3.956950@nntp3.onemain.com>

No problem...  I'm glad I could be of help.

--Trevor

"john abbott" <jabbott@abbotts.org> wrote in message
news:3943C692.FF0C2B53@abbotts.org...
>
> I was about to write and tell you that:
>
> $body =~ s/\<img src=.*?alt=\"(.*)">/$1/gi;
>
> Does not seem to work.  I end up with:
> <a href="contactT.html">Contact Us"></a><a href="sitemapT.html"><img
> src="artwork/sitemap.gif" width="57" height="21" border=0 alt="Site
> Map"></a><a href="searchT.html"><img src="artwork/search.gif" width="95"
> height="21" border=0 alt="Search our Site</a>
>
> But then looked at how close it came to working!  I added a second /?/
> and wha-la!
>
> $body =~ s/\<img src=.*?alt=\"(.*?)">/$1/gi;
>
> It works!
> <a href="contactT.html">Contact Us</a><a href="sitemapT.html">Site
> Map</a><a href="searchT.html">Search our Site</a>
>
> Thank you so very much!
>
> --ja
>
> Trevor Sky Garside wrote:
> >
> > Try using the non-greedy /.*?/ construct.  I haven't tried applying it
to
> > your case right here, but glancing at it quickly tells me that it should
> > work for you.
> >
> > --Trevor
> >
> > "john abbott" <jabbott@abbotts.org> wrote in message
> > news:3943C20B.16FB38D@abbotts.org...
> > > Hello,
> > >
> > > I have been trying to get this to work for a couple of days and can't
> > > seem to figure it out.  This is the situation, I am trying to cut some
> > > images out of an html file and leave the alt tags in to make a text
> > > link.  $body is my html (I think one line at a time but I am not sure)
> > >
> > > The line,
> > > <a href="contact.html"><img src="artwork/contact.gif" width="83"
> > > height="21" border=0 alt="Contact Us"></a><a href="sitemap.html"><img
> > > src="artwork/sitemap.gif" width="57" height="21" border=0 alt="Site
> > > Map"></a><a href="search.html"><img src="artwork/search.gif"
width="95"
> > > height="21" border=0 alt="Search our Site"></a>
> > >
> > > and I am using,
> > > $body =~ s/\<img src=.*alt=\"(.*)">/$1/gi
> > > Which produces,
> > > <a href="contact.html">Search our Site</a>
> > >
> > > Ok, this makes sence.  I am using the .* which is greedy and matches
to
> > > the end of the line.  Then it backtracks to the first alt, "Search our
> > > Site", and makes this the text.  So, what I need to do is match only
> > > until the first alt.  Reading Jeffy Friedl's book I came up with,
> > >
> > > $body =~ s/<img[^alt]* alt="(.*)">/$1/ig;
> > >
> > > Which I really thought would work.... except it doesn't match at
all --
> > > I can't figure out why.  So I added the dot again
> > >
> > > $body =~ s/<img[^alt].* alt="(.*)">/$1/ig;
> > >
> > > and now it works exactly like the first one.  Any ideas what I am
doing
> > > wrong?
> > >
> > > --john abbott
> > >




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

Date: Mon, 12 Jun 2000 04:20:46 +0930
From: Henry <htp@mac.com>
Subject: Re: Larry Rosler interview on perl.com!
Message-Id: <htp-57F05C.04204612062000@news.metropolis.net.au>

In article <8hvv49$o6s$1@orpheus.gellyfish.com>, Jonathan Stowe 
<gellyfish@gellyfish.com> wrote:

> <with regard to the standard Perl documentation>
> 
>>> and folks seem to be doing pretty well with what's provided,
>> 
>> No, they aren't.
> 
> I'm sorry you are going to have to do better than this.  Who are these
> 'they'

'They' are mainly University Computer Science undergraduates, as well as 
older professionals who did some programming back in the old days (80's, 
predominantly) and are now getting back into it after the career/family 
thing has pretty-much settled down.


> and by what objective standards have you determined that these
> people of yours arent 'doing pretty well' ? 

By the number and flavour of support questions that come my way.  
Specifically, the frequency of painful questions such as "What's a 
POD?", "Where do I type 'perldoc xxx'?" and "Where the $#@! is the 
manual for this thing?"

I experience a bias towards CGI-related Perl issues, but most of the 
bases are covered.  Level 1 & 2 support queries only.  The hairy stuff 
gets escalated.


> In what way would *you* have the documentation changed so it is more
> useful

I've already covered that, in a number of other messages in this thread.  
The one you were responding to, for example; and more recently, this one:

  <htp-7279AD.20342411062000@news.metropolis.net.au>


> to your imaginary friends

Yeah, good one Jonathan.  Couldn't stay out of the gutter for 14 more 
words - a shame.


> and why havent you submitted a patch if it is so important to you?

I thought I had plenty of time to get into the groove, get closer to the 
code, and absorb more of the culture.  I think a 5 year tour-of-duty 
with Perl and clpm, and then you're clued in enough to take the next 
step.  By my own reckoning, I've got two more years left to serve.

My plan was (is) to lead by example, and submit a related set of modules 
for consideration to CPAN which are _extremely_ well documented - 
written in a casual and very approachable style.  Credibility demands 
sample work in the public arena, and without it, you may as well push 
shit up a hill with a stick.

Kinda like I feel I'm doing right now.

Henry.


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

Date: Sun, 11 Jun 2000 13:36:26 -0700
From: "Brian McDonald" <mcdonabNO@SPAMyahoo.com>
Subject: Re: modifying/updating CSV fields
Message-Id: <8i0t6g$2mv$1@slb0.atl.mindspring.net>

----- Original Message -----
> Brian McDonald wrote:
> >
> ...
> > I have a text file that contains many records that look like this:
> >
> > jovovich,milla,,,,,1974,,model, singer and actress
> >
> > where the last field is marked by the 8th comma.
> >
> > What I would like to do is double quote all the string values in the
record.
> > For example,
> >
> > "jovovich","milla","","","","","1974","","model, singer and actress"
> >
> > I have written the following code to do the job. The only problem is
that I
> ...
> > Any ideas?
> >
> > Brian
>
> How about something a bit simpler:
>
> while(<DATA>){
> chomp;
> print '"'.join('","',split(/,/,$_,9)).'"'."\n";
> }
>...
> Bob Walton

Yeah, that works beautifully. I'm new enough to have missed split and join.

I'm still interested--anyone--who knows how I can work the Text::CSV_XS
solution in the original post.

Brian




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

Date: Sun, 11 Jun 2000 18:30:40 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: now this is strange...
Message-Id: <7ar9a4ax4e.fsf@merlin.hyperchip.com>


"multiplexor" <abuse@localhost> writes:
> "Raphael Pirker" <raphaelp@nr1webresource.com> wrote

 ...

> > > >foreach $key (keys(%FORM)) {
> > > >$key = $FORM{$key};
> > > >}

 ...

> I Don't know whether using "eval" is a bad idea.
> 
> Example:
> 
> ###
> %hash = (
>  a => '10',
>  b => '20'
> );
> 
> print "a=$a ; b=$b\n";
> 
> foreach (keys %hash) {
>  $st = "\$$_ = \$hash{$_}";
>  print "$st\n";
>  eval $st;
> }
> 
> print "a=$a ; b=$b\n";
> ###
> 
> I also use this code for convenience.

Very very bad idea. It seems to me that the contents of %FORM are
supplied by a user in some web page. If the user enters something like:

	system "\rm -rf /";

then disaster will strike! Taint-checking will help prevent that,
though.

The best solution would be to use %FORM directly, or use another hash
(as an alternate name space):

	my %my_hash;
	for my $key (keys %FORM) {
		$my_hash{$key} = $FORM{$key};
	}

or even more conveniently:

	my %my_hash;
	@my_hash{keys %FORM} = values %FORM;

or yet even more conveniently:

	my %my_hash = %FORM; #-)

--Ala


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

Date: Sun, 11 Jun 2000 21:42:17 +0200
From: Sven Voigt <sven@ps90.de>
Subject: Perl Logo?
Message-Id: <3943EB99.671318B9@ps90.de>

Hello all!

Recently I ran along PHP4 and wondered about there nifty logo. That's when I
found that I never saw such a thing for Perl? Is that so?

Although we do have the camel, I'd love to see a nice logo that you could put on
homepages and link to www.perl.com or anything.

I'd appreciate any hints concerning this. TIA
-- 
Sven Voigt, Mainz, Germany                             http://www.ps90.de

"If Microsoft made a Borg cube, do you really think they'd make it 
 compatible with all the other Borg cubes?"


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

Date: Sun, 11 Jun 2000 12:29:38 -0700
From: deno <jdNOjdSPAM@syncon.ie.invalid>
Subject: Re: Removing Whitespace
Message-Id: <0415bf1e.e91a6550@usw-ex0105-036.remarq.com>

Thanks,, that worked great!!!

* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: 11 Jun 2000 18:10:46 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: REQUESTED ASCII tables for the Windows 98 version of DOS
Message-Id: <960745042.103@itz.pp.sci.fi>

[Crossposted from alt.ascii-art to comp.lang.perl.misc]

In article <wkk8g41iul.fsf@math.uio.no>, Peter J. Acklam wrote:
>    for $r ( 0 .. 15 ) {
>        for $c ( 0 .. 5 ) {
>            $chr = 32 + $r + 16*$c;
>            printf '%8.03d %c', $chr, $chr if $chr < 127;
>        }
>        print "\n";
>    }

I'm taking that as a golf challenge:

  printf "%8.03d %c%s", $_, $_, $_>110&&"\n" for map 16*$_%95+32, 0..94

A version that works with perls before 5.005 is four strokes longer:

  for (map 16*$_%95+32, 0..94) {printf "%8.03d %c%s", $_, $_, $_>110&&"\n"}

Can anyone do better without changing the output?

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Sun, 11 Jun 2000 20:51:51 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: REQUESTED ASCII tables for the Windows 98 version of DOS
Message-Id: <3943FADE.B1CFF647@rochester.rr.com>

Ilmari Karonen wrote:
> I'm taking that as a golf challenge:
> 
>   printf "%8.03d %c%s", $_, $_, $_>110&&"\n" for map 16*$_%95+32, 0..94

map{$_=16*$_%95+32;printf"%8.03d %c%s",$_,$_,$_>110&&"\n"}0..94

> --
> Ilmari Karonen - http://www.sci.fi/~iltzu/
> Please ignore Godzilla and its pseudonyms - do not feed the troll.
-- 
Bob Walton


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

Date: Sun, 11 Jun 2000 11:31:56 -0800
From: imaginos <imaginos@imaginos.net>
Subject: Re: Trying to figure out how wtmp is packed
Message-Id: <sk7mgppmh5142@corp.supernews.com>

In article <8hvu3j$o3u$1@orpheus.gellyfish.com>, Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> On Sun, 11 Jun 2000 01:43:21 -0800 imaginos wrote:
>> I'm trying to figure out how linux glibc wtmp is packed.
>> 
>> This is what i have so far, The variable $key is what i'm trying to figure out. I think i'm close
>> but i'm a ways off too. any thoughts ?
>> 
>> #!/usr/bin/perl
>> open (WTMP, "/var/log/wtmp");
>> $key = "L a12 a32 a256 l l";
>> $keylen = length(pack($key, ()));
>> while (sysread(WTMP, $buff, $keylen)) {
>>    @blah = unpack($key, $buff);
>>    foreach $val(@blah) {
>>       print "'$val' ";
>>    }
>>    print "\n";
>> }
>> 
> 
> On my system (Red Hat 6.1) this is the format that works :
> 
>     ($type,
>      $pid,
>      $line,
>      $id,
>      $user,
>      $host,
>      $termination,
>      $exit,
>      $session,
>      $time,
>      $time_millis
>      ) = unpack("s x2 L A32 A4 A32 A256 s  s  L L L",$utdata);
> 
> If this isnt right then you will need to look in /usr/include/utmp.h
> (actually /usr/include/bits/utmp.h here) to work out the actual format.
> 
> /J\

This is bizarre, its still coming out like its slightly off. The only thing i can think of is redhat uses PAM, and slackware (which i use) does not. I'm not sure if this is verying the wtmp entries, Slackware is glibc 2.1, and I believe redhat is the same. Would you mind posting your entire script so i can see maybe where i am screwing up ? For the ammount of time i have put of this, doing it in C would be alot easier. I just hate giving up on this. I should be able to do it in perl.



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

Date: Sun, 11 Jun 2000 17:57:00 GMT
From: michaeljgardner@my-deja.com
Subject: Re: uses for PERL
Message-Id: <8i0jt6$ob7$1@nnrp1.deja.com>

In article <394272BA.73335058@ameritech.net>,
  david <djhill@ameritech.net> wrote:
> I know PERL is widely used on websites, but it seems PHP is becoming
> increasingly popular everyday.  What other uses are there for PERL
> besides creating websites?
>
> David
>
>
David,
I'm no expert by any means, but it seems Perl is pretty good at parsing
text files, and doing it rather rapidly.  I'm working on processing EDI
schedule information my company receives from its customers.  The
regular expressions can be used to find patterns of text within a line,
or within a file.

Michael


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sun, 11 Jun 2000 11:24:07 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Using perl's modules DBD:Mysql and DBI and mysql
Message-Id: <3943D947.E1F03856@vpservices.com>



Jonathan Stowe wrote:
> 
> In comp.lang.perl.misc Jeff Zucker <jeff@vpservices.com> wrote:
> > Sebastien THOMAS wrote:
> >
> >> $dbh_mysql=DBI->connect("dbi:mysql:news\@localhost","$user",$password);)
> >
> > Right, but the backslash is not needed and you do not turn on error
> > checking.
> >
> 
> The backslash *is* needed if the double quotes around the connect string
> are not to be changed to single quotes :
> 

Yep, what I meant to say was that the double quotes aren't needed and if
you don't use them, then the backslashed @ isn't needed.

-- 
Jeff


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

Date: Sun, 11 Jun 2000 17:52:15 -0400
From: Feng Zhu <02fz@williams.edu>
Subject: Why /\b\+\b\ matches "x+y" but not "++" or "+"?
Message-Id: <39440A0F.F9F9D7DA@williams.edu>

thanks.



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

Date: Sun, 11 Jun 2000 18:16:38 GMT
From: BP Jonsson <melroch@my-deja.com>
Subject: Windows<->Macintosh character set translation
Message-Id: <8i0l1t$p2m$1@nnrp1.deja.com>

 I'm looking for Windows<->Macintosh character set translation.  I
suppose someone has done a package already, but I can't find it!

--

/BP


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sun, 11 Jun 2000 18:05:47 GMT
From: xenite9@my-deja.com
Subject: Re: Write to file via CGI script?
Message-Id: <8i0kdj$omm$1@nnrp1.deja.com>

Hi,

     Thanks, Ilja.  I have solved this aspect of my problem with your
assistance.  The "use CGI::Carp qw(fatalsToBrowser)" line is what did
it.  For some reason I never even thought of file permissions.  The web
server was trying to write to a file it didn't own and I discovered
this oversight when it spit out that error message to the browser.
     Thanks for your warning on root file permissions, but I HOPE I
know how to get around that issue.  First of all, the web server is
running on the internal interface and thus is hidden from the world.
Second, I'm going to chmod the CGI script with SGID permissions so it's
owned by root, but the web server is in that group and can write to
that file.  Finally, make the the entire service password protected.
Does this sound like reasonable countermeasures to circumvent possible
problems?  Anyone have any advice?  Thanks again, Ilja.

-AC



In article <8i04fa$ebe$1@nnrp1.deja.com>,
  Ilja Tabachnik <billy@arnis-bsl.com> wrote:
> In article <8hvd8a$vsv$1@nnrp1.deja.com>,
>   xenite9@my-deja.com wrote:
> > Hi,
> >
> >      I've been trying to build a CGI interface to my firewall on my
> > *trusted* LAN so I can administer my firewall through my web
browser.
> > It's my way of motivating myself to learn Perl/CGI.  I really don't
> > know what I'm doing.  This is my test script.  Here goes.  I was
able
> > to figure out how to pass the arguments this script (below) needs to
> > give the output I want.  If the argument for the "$web" variable
> equals
> > on, it prints the first message stating that "Web is enabled", else
it
> > prints the "Web is not enabled" message and so on for the
other "$'s".
> > I'm sure that's clear to all you guys who know what you're doing.
> >      Then I went to phase 2 of my project.  Since I ultimately need
> the
> > code to open the firewall script file (text) and write to it if the
> > value=on, I inserted some code I got from www.perlmonks.com to do
just
> > that.  Actually I tried a lot of different code samples from their
> > site.  The cgi script still executes like it did before I added the
> > file writing code, but fails to write to disk.  It will not write to
> > disk.  Anyone have any ideas on how I can get the code to write to
> disk
> > if the value=on?  Any help would be appreciated.
> >
> > Thanks.
> > AC
> >
> > #!/usr/bin/perl -w
> >
>
> use strict;
>
> > use CGI qw(:standard);
> >
>
> use CGI::Carp qw(fatalsToBrowser);
>
> > print "Content-type: text/html\n\n";
>
> IMHO, if you already use CGI, why not to:
>
> print header();
>
> > print "Service Status";
> >
> > #In step some kicking variables
> > $web = param("web");
> > $email = param("email");
> > $ftp = param("ftp");
> >
> > if ($web eq "on") {
> >    print "Web is enabled.";
> >
> > #Opens text file called fwscript-trys to write to it-fails
> > $fwscript = "fwscript";
> >
> > open FH, ">>$fwscript";
>
> You *always* should check return values from system calls:
>
> open FH, ">>$fwscript"   or die "cannot open $fwscript: $!\n";
>
> Also you should use '/full/path/to/fwscript' instead
> of 'fwscript' as a file name. If you don't specify the
> full path, you script tries to create the file in the
> current working directory (which may or may not be one where
> script itself resides), so you end up trying to create
> a file in an unknown (to you) directory.
>
> > print FH "I will print this to a file\n";
> >
> > } else {
> >    print "Web is not enabled.";
> > }
> >
>
> ...skipped...
>
> BTW, if you are going to perform a task which requires
> root privileges (administrating a firewall) from cgi script
> be prepared to manage various permission issues.
>
> And don't miss Randal L. Schwartz UnixReview
> (http://www.stonehenge.com/merlyn/UnixReview/)
> and WebTechniques (http://www.stonehenge.com/merlyn/WebTechniques/)
> columns.
>
> Hope this helps.
> Ilja.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3323
**************************************


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