[17006] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4418 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 24 18:09:26 2000

Date: Sun, 24 Sep 2000 15:05:09 -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: <969833109-v9-i4418@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 24 Sep 2000     Volume: 9 Number: 4418

Today's topics:
    Re: "not in string" - how to do it? (Keith Calvert Ivey)
    Re: "not in string" - how to do it? <godzilla@stomp.stomp.tokyo>
    Re: adding ".."(parent dir) to @INC (Peter J. Acklam)
    Re: best way to compare $var against <DATA> (Daniel Chetlin)
    Re: Hash and Join help, please? (Daniel Chetlin)
    Re: How to contatenate $1 with digits in s/// (Abigail)
    Re: Levels of Perl Programmer <nospam@david-steuber.com>
    Re: matching a date (Keith Calvert Ivey)
    Re: perl 5.6, Net::POP3, database files, and more (Joe Smith)
    Re: PERL and GPS <jpl@research.att.com>
        Problem(s) installing IndioPerl <tarrantr@my-deja.com>
        push-technology <thomas.guenter@isoe.ch>
    Re: push-technology (Abigail)
    Re: References and local (Daniel Chetlin)
    Re: regexp woes w/ Text-BibTeX (Keith Calvert Ivey)
    Re: regexp woes w/ Text-BibTeX (Daniel Chetlin)
    Re: regexp woes w/ Text-BibTeX (Keith Calvert Ivey)
    Re: Regular Expression for matching with email addresse (Gwyn Judd)
        safe2 test problem (Bob Campbell)
    Re: Testing file for directory: doesn't work hiroshiishii@my-deja.com
    Re: The best tutorial? <bwalton@rochester.rr.com>
    Re: The best tutorial? (Abigail)
    Re: vertical text renderer <uri@sysarch.com>
    Re: vertical text renderer <godzilla@stomp.stomp.tokyo>
    Re: vertical text renderer <uri@sysarch.com>
    Re: vertical text renderer <godzilla@stomp.stomp.tokyo>
    Re: vertical text renderer <uri@sysarch.com>
    Re: vertical text renderer <godzilla@stomp.stomp.tokyo>
        when is a DBM worth it <news@#nospam#althepal.com>
    Re: www.perl.com won't come in on my computer.... gerrit_griebel@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 24 Sep 2000 20:08:28 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: "not in string" - how to do it?
Message-Id: <39d15ea7.3249302@news.newsguy.com>

Jeff Zucker <jeff@vpservices.com> wrote:

>> The full problem is that the string must match certain criteria 
>> and must not match certain other; something like "have a "wxyz" 
>> followed by "mrst" and a q in between them but there must 
>> not be a "d" in between them.  
>
>    print if /wxyz(.+)mrst/  &&  $1 !~ /d/ && $1 =~ /q/;
>
>Or use Larry's answer which is probably oodles more effecient than this.

And works correctly on strings where yours doesn't, such as
'wxyzdwxyzqmrst'.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Sun, 24 Sep 2000 14:26:46 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: "not in string" - how to do it?
Message-Id: <39CE7196.ED00E195@stomp.stomp.tokyo>

Kurt Schmidt wrote:

> Let's say that I have arbitrary strings like
 
> aklklsdjjf
> ssdalkfj
> srwokgfl
> jkljsdpitl;
> skkdddk
> dlkliujgmn
> klksddffd
 

> I want to match all strings EXCEPT those that have one or more d in it.
> Seems like a simple question, but what is the answer?


"let's say...."

*laughs*

Rather amusing thread, certainly.

Here is a reliable, clean and lightning fast
method for resolution of such an easy task.


Godzilla!
-- 
Are you ready for Roberta The Remarkable Robot?



TEST SCRIPT:
____________


#!/usr/local/bin/perl

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

$data = "aklklsdjjf
ssdalkfj
srwokgfl
jkljsdpitl;
skkdddk
dlkliujgmn
klksddffd";

print "Input:\n\n$data";

print "\n\n\nOutput:\n\n";

@Array = split (/\n/, $data);
foreach $element (@Array)
 {
  if (index ($element, "d") == -1)
   { print "$element\n"; }
 }

exit;


PRINTED RESULTS:
________________


Input:

aklklsdjjf
ssdalkfj
srwokgfl
jkljsdpitl;
skkdddk
dlkliujgmn
klksddffd


Output:

srwokgfl


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

Date: 24 Sep 2000 17:42:05 +0100
From: jacklam@math.uio.no (Peter J. Acklam)
Subject: Re: adding ".."(parent dir) to @INC
Message-Id: <wkzokxkahu.fsf@math.uio.no>

Alex Hart <news@#nospam#althepal.com> writes:

> I want to include a module that is either in a the parent
> directory of the script or in the same directory. I do not want
> to hard code any directory.
> 
> How can I add ".." to my @INC for only some scripts?

1) To add '..' to @INC, you can

      * set the PERL5LIB environment variable
      * put  use lib '..';  in your code
      * use the  -I..  command line switch

2) See the FAQ for more information about how to change @INC.

3) Don't post to the group comp.lang.perl; it's dead.

Peter

-- 
$\="\n";$_='The quick brown fox jumps over the lazy dog';print +(split
//)[20,5,24,31,3,36,14,12,31,1,2,11,9,23,33,29,35,15,32,36,7,8,28,29];


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

Date: 24 Sep 2000 14:26:44 GMT
From: daniel@chetlin.com (Daniel Chetlin)
Subject: Re: best way to compare $var against <DATA>
Message-Id: <8ql2v402on4@news2.newsguy.com>

On 22 Sep 2000 23:07:38 -0500, Ren Maddox <ren.maddox@tivoli.com> wrote:
>{
>  my $found;
>  while(<DATA>) {
>    next unless /$users_newsgroup/;  # or $_ eq $users_newsgroup
>    $found++ and last;
---------->^^
>  }
>  warn "$users_newsgroup not found\n" unless $found;
>}
>
>This has the added benefit that it will stop processing DATA as soon
>as a match is found.

I think you want a preincrement for that.

[snip]

-dlc


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

Date: 24 Sep 2000 16:14:44 GMT
From: daniel@chetlin.com (Daniel Chetlin)
Subject: Re: Hash and Join help, please?
Message-Id: <8ql99k0vir@news1.newsguy.com>

On Sat, 23 Sep 2000 19:15:21 GMT,
 ptomsic@my-deja.com <ptomsic@my-deja.com> wrote:
>-----CODE-----
>#!/usr/local/bin/perl

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

>## hash test
>use HTML::TokeParser;

>$file = $ARGV[0];
>open(INFILE, "$file");
>@file =<INFILE>;
>close(INFILE);
>$wholeFile = join("", @file);

Those five lines are just a verbose way of saying:

  $wholeFile = join("",<>);

If you really want to do it that way, make sure you check the return
value of open() at least. See the discussion of TokeParser below for a
better way to handle filenames on the command line.

>%h = &getHyperlinks($wholeFile);

You almost never want to have a function return a hash -- which is
really just a list. That can cause memory pain if the list is long.
Instead, design the function to return a hashref. More on that later.

Also, you should probably get out of the habit of calling functions with
`&'. It's not necessary here.

See below for the implementation of getHyperlinks() that I think makes
sense, and then call it like this:

  my $hr = getHyperlinks();

>foreach $key (sort keys %h) {
>        $fullString = join(",","$key => $h{$key}\n");
>}

As someone (Bob Walton?) already pointed out, this is where the major
flaw is. See his message for an easy way (using map) to get the whole
output into your one variable. I'd probably do this:

  print "$_ => $hr->{$_}\n" for sort keys %$hr;

>print "\n==============\n$fullString\n";
>
>sub getHyperlinks {
>        ## object constructor
>        my $path = shift;
>        my (%href);
>        $parser=HTML::TokeParser->new(\$path);

I'd say this is misleading. You're calling the variable $path, which
makes me think of a path to a file. But what's really in it is the
entire HTML file, having been sucked in earlier. Aside from the
inefficiency of passing that string, it just doesn't feel clean to me.
So, at the very least, I'd rename that variable to something less
misleading. But I think you'd probably also want to consider changing
your method of invoking TokeParser.

TokeParser can accept, along with a string the way you've passed it, a
file name and any kind of IO thingy. You could pass it directly the name
of the file you've gotten on the command line, you could open the file
on the command line and give it the filehandle you've opened it with,
you could even let it default to STDIN. Basically, there are a lot of
ways to do this that make more sense to me.

Here's one concrete suggestion:

  my $parser = HTML::TokeParser::->new(shift || $ARGV[0] || *STDIN);

Then, you can call getHyperlinks() [cue Abigail to tell you that
studlyCaps hurts] without any arguments, and it'll default to parsing
the first file given from the command line, and if there was no file
given, it'll use STDIN. Or, you can call getHyperlinks with a specific
filename, or a filehandle, or a reference to a string containing HTML
like you have above.

>        while (my $token = $parser->get_tag("a")) {
>                my $linkURL = $token->[1]{href} || "-";
>                my $linkText = $parser->get_trimmed_text("/a");
>                if ($linkText=~/<image/i) {$linkText="image"}

Aside from the fact that the tag for an image is 'img', TokeParser puts
the text '[IMG]' wherever it finds an image tag, so this won't work.
Personally, I think '[IMG]' looks better aesthetically, but if you want
to make that change, do

  $linkText = "image" if ($linkText =~ /\[IMG\]/);

(Also note that this will put _only_ 'image' into your text string -- if
you have a link that looks like

  <a href="foo">Here is some text and an <img src="foo"> image</a>

You'll get nothing but 'image'. Which is fine, if that's what you want.

>                $href{$linkURL} = $linkText;

Hmm. Note here that you're blowing away any previous value of
$href{$linkURL} -- assuming you don't want that, I'd make this change:

  push @{$href{$linkURL}}, $linkText;

(With the appropriate change to the print statement above -- see the
full text of my changes below for a way to do this.)

>                print "$linkURL => $linkText\n";
>        }
>        return %href;

Here's where I'd return that as a reference rather than as a list. Not
only will it save on memory, it'll keep strange things from happening if
you accidentally call getHyperlinks() in scalar context.

  return \%href;

>}

So, in case you haven't fallen asleep yet, here follows the entirety of
my rewrite; I hope it's helpful.

-dlc

__END__

#!/usr/local/bin/perl -w
use HTML::TokeParser;
use strict;

my $hr = get_links();

# Here's something that will produce output similar to the original
#{
#    local $" = '//';
#    print "$_ => @{$hr->{$_}}\n" for sort keys %$hr;
#}

# Let's make it look pretty, though:
my ($key,$value);
format STDOUT =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$key,                          @{[join '//',@$value]}
 .

write while (($key,$value) = each %$hr);

sub get_links {
        my %href;
        my $parser = HTML::TokeParser::->new(shift || $ARGV[0]
                                                   || *STDIN);
        while (my $token = $parser->get_tag("a")) {
                my $url = $token->[1]{href} || "-";
                my $text = $parser->get_trimmed_text("/a");
                push @{$href{$url}},$text;
        }
        return \%href;
}



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

Date: 24 Sep 2000 19:07:43 GMT
From: abigail@foad.org (Abigail)
Subject: Re: How to contatenate $1 with digits in s///
Message-Id: <slrn8ssk5k.lo9.abigail@alexandra.foad.org>

Alan J. Flavell (flavell@mail.cern.ch) wrote on MMDLXXXI September
MCMXCIII in <URL:news:Pine.GHP.4.21.0009241506530.10314-100000@hpplus03.cern.ch>:
?? 
?? I have a substitution in which I want to concatenate the resulting
?? match string $1 with a string of digits, say e.g 20.
?? 
?? But if I write (the actual match pattern is of no importance here)
?? something like s/foo(...)baz/$120/ then I get "Use of uninitialized
?? value".  

That's because you didn't match anything in your 120th pair of parens. ;-)

?? Of course, something like s/foo(...)baz/$1_20/ does what it says
?? it does, but then there's an extra underscore in the result, that I
?? don't want.
?? 
?? I'm sure I'm missing something obvious.  Clue-stick, anyone, please?

    s/foo(...)baz/${1}20/;



Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


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

Date: Sun, 24 Sep 2000 18:37:48 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: Levels of Perl Programmer
Message-Id: <m3aecx7i11.fsf@solo.david-steuber.com>

I guess I'm *almost* a user ;-).  It seems I don't fit any of the
categories, but from user on down to novice, I have several fits.

-- 
David Steuber | Perl apprentice, Apache/mod_perl user, and
NRA Member    | general Internet web wannabe.
ICQ# 91465842  (Using Micq 0.4.6 under Linux)

It's time to be free: http://www.harrybrowne2000.org


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

Date: Sun, 24 Sep 2000 19:53:09 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: matching a date
Message-Id: <39d058b8.1730125@news.newsguy.com>

"tuple" <bachelart.pierre@skynet.be> wrote:

>How can i match a date given in something like this:
>    Exchange   2000-09-23  19:37:25    EST
>
>/\b20[0-9]{2}-[0-1][0-9]-[0-3][0-9]\b/ would work
>but would match  2000-19-39 too.

You could make the regex more specific, like

    m{ \b
       20\d\d
       -
       (?:0[1-9]|1[0-2])
       -
       (?:0[1-9]|[12]\d|3[01])
       \b
      }x

or something even more elaborate, but it's probably not worth
the bother.  If your text can contain sequences like
'2000-19-39' (stock numbers, perhaps?), then surely it can also
contain sequences like '2000-09-24' that look like dates but
aren't.  You'll have to look for something else about the
context to be sure that it's a date.

>I' ve search comp.lang.perl.* with the pattern "date" in a
>power search but it returns nothing !! Very strange.

Not strange, just annoying.  Since the word "date" occurs in
every article (in the header), it's generally ignored in
searches.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: 24 Sep 2000 18:33:43 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: perl 5.6, Net::POP3, database files, and more
Message-Id: <8qlhe7$2q71$1@nntp1.ba.best.com>

In article <39CD63E8.8D98925F@althepal.com>,
Alex Hart  <news@althepal.com> wrote:
>2. Are the database files (hashes opened with dbmopen) done differently
>in perl5.6? I couldn't seem to read my old files with 5.6.  Also, it
>didn't seem to put the ".db" extensions on the files.  Have others
>noticed this?

Don't use dbmopen.  There is more than one dbm implementation that perl
can use, and which one is the default for dbmopen depends on the mood of
the person who configured and compiled perl.  To get consistent results,
use 'tie' instead of 'dbmopen'.

The docs for AnyDBM_File lists the various dbm modules and their limitations.
  unix% perldoc AnyDBM_File
  C:\> perldoc AnyDBM_File

	-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Sun, 24 Sep 2000 19:51:10 GMT
From: "John P. Linderman" <jpl@research.att.com>
Subject: Re: PERL and GPS
Message-Id: <39CE5B2E.D3C9F07E@research.att.com>

Iain Chalmers wrote:

> In article <RHJy5.6403$gi1.125305@news.magma.ca>, slipper@canada.com
> (Bob M) wrote:
>
> > Are there any available PERL scripts or modules to facilitate uploading
> > and
> > downloading data from GPSs?  (I couldn?t find anything on CPAN).
>
> It doesn't seem to be on cpan, but take a look at
>
> < http://www.iscsp.utl.pt/joaop/work_in_progress/GPS-Garmin-0.02.tar.gz>
>
> cheers
>
> big

In general, interacting with GPSs has more to do with the
serial line manipulation, the NMEA 0183 standard, and
proprietary extensions thereto, than it does with Perl.
Chasing a few links for "NMEA 0183" from your
favorite search engine will uncover a lot of helpful info.
The code in the link that Iain cited looked useful,
particularly if you happen to have a Garmin GPS,
once you get past the GPL boilerplate.  -- jpl



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

Date: Sun, 24 Sep 2000 20:56:23 GMT
From: RST <tarrantr@my-deja.com>
Subject: Problem(s) installing IndioPerl
Message-Id: <8qlppg$euj$1@nnrp1.deja.com>

After installing IndioPerl on a Win95 machine, I'm unable to start the
PerlConole.  The install script created a shortcut to a program called
PerlConsole.exe which doesn't exist on my system.  I do have a
PerlConsole.exp though.

The install script also gave me the following message:

error: Configuration file c:/perl56i/BIN/conf/httpd.conf is invalid


Can someone inform me how to get around these issues?  Thanks!


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


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

Date: Fri, 22 Sep 2000 21:24:03 +0200
From: Thomas =?iso-8859-1?Q?G=FCnter?= <thomas.guenter@isoe.ch>
Subject: push-technology
Message-Id: <39CBB1D3.4320D9F1@isoe.ch>

hi,

i'm looking for a solution for the following problem:
my task is to bind a process control system to the internet. now, the
system changes its process and state data all the time and an internet
client should visualize the latest data simultaneously. By the way, the
web server knows if the data has changed and when he has to push them to
the client. a restriction is, that i'm not allowed to install other
applications than a web browser on the client machine (except built-in
jre, plug-in). i know it's possible to program a html-page which reloads
itself every few seconds, but that doesn't make much sense since just
one number on the whole page can be changed. with this solution, also
the network traffic would be too high, since the system has a great
amount of data that is changing all the time.
summary:
i need a technology which allows to push data (just strings or other
primitive data types, not whole html-pages) to a web-browser, running on
a client, because of a server-side event.

i would be very happy, if you could send some good hints which i can
follow or a proper news group.

thanks for your help!

tom



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

Date: 24 Sep 2000 20:43:35 GMT
From: abigail@foad.org (Abigail)
Subject: Re: push-technology
Message-Id: <slrn8ssppa.lo9.abigail@alexandra.foad.org>

Thomas Günter (thomas.guenter@isoe.ch) wrote on MMDLXXIX September
MCMXCIII in <URL:news:39CBB1D3.4320D9F1@isoe.ch>:
"" hi,
"" 
"" i'm looking for a solution for the following problem:
"" my task is to bind a process control system to the internet. now, the
"" system changes its process and state data all the time and an internet
"" client should visualize the latest data simultaneously. By the way, the
"" web server knows if the data has changed and when he has to push them to
"" the client. a restriction is, that i'm not allowed to install other
"" applications than a web browser on the client machine (except built-in
"" jre, plug-in). i know it's possible to program a html-page which reloads
"" itself every few seconds, but that doesn't make much sense since just
"" one number on the whole page can be changed. with this solution, also
"" the network traffic would be too high, since the system has a great
"" amount of data that is changing all the time.
"" summary:
"" i need a technology which allows to push data (just strings or other
"" primitive data types, not whole html-pages) to a web-browser, running on
"" a client, because of a server-side event.

Why on earth are you begging for solutions in an off-topic newsgroup,
a group that doesn't appreciate "give me fish" postings in the first
place?

"" i would be very happy, if you could send some good hints which i can
"" follow or a proper news group.

There are tens of thousands of news groups. Why on earth do you think
this newsgroup tracks what's discussed where?

Go away.


Abigail
-- 
# Perl 5.6.0 broke this.
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


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

Date: 24 Sep 2000 19:21:03 GMT
From: daniel@chetlin.com (Daniel Chetlin)
Subject: Re: References and local
Message-Id: <8qlk6v018rf@news1.newsguy.com>

On 24 Sep 2000 06:23:56 GMT, Abigail <abigail@foad.org> wrote:
>
>The perlsub manpage says:
>
>    A `local' just gives temporary values to global (meaning package)
>    variables. It does not create a _local_ variable.
>
>The perlref manpage says:
>
>    By using the backslash operator on a variable, subroutine, or
>    value.  (This works much like the & (addressof) operator in C.)
>    This typically creates another reference to a variable, because
>    there's already a reference to the variable in the symbol table.
>
>So, I would think that the following program:

Here's my understanding of how this works.

>    $var = "foo";

/-------------------\
|Symbol table: `var'|
|                   |        /--------------\
|Scalar-------------+------->| String "foo" |
\-------------------/        \--------------/

>    $ref = \$var;

/-------------------\
|Symbol table: `var'|
|                   |        /--------------\
|Scalar-------------+------->| String "foo" |
\-------------------/     /->\--------------/
                          |
/-------------------\     \--------------------------\
|Symbol table: `ref'|                                |
|                   |     /---------------------\    |
|Scalar-------------+---->| Reference to scalar |----/
\-------------------/     \---------------------/

>    local $var = "baz";
                             /--------------\
/-------------------\   /--->| String "baz" |
|Symbol table: `var'|   |    \--------------/
|                   |   |    /--------------\
|Scalar-------------+---/    | String "foo" |
\-------------------/     /->\--------------/
                          |
/-------------------\     \--------------------------\
|Symbol table: `ref'|                                |
|                   |     /---------------------\    |
|Scalar-------------+---->| Reference to scalar |----/
\-------------------/     \---------------------/

>    print $$ref;

And from the above diagrams, we see why it prints `foo' rather than
`baz'.

>would print 'baz'. After all, $ref is a reference to $var, and the local
>makes $var get a local _value_. Without the local, the program prints
>'baz', but with the local, the program prints 'foo', as if local produces
>the new variable, instead of a new value.
>
>I asked about this on IRC, and uri gave me an explaination from the
>implementation side; how it works with SVs and such. But I don't
>find that acceptable, as SVs don't exist on the language level; they
>are implementation details, and a next version of Perl might do it
>differently.

Is talking about symbol tables too much on the implementation side? I
can't really make up my mind about that -- but I will say that the way
it works now makes sense to me (it's the way I would have expected local
and hard references to work).

>I think that one of the following is true:
>
>    1)  This behaviour is explained in the manual, and I just don't
>        understand the manual.
>    2)  The documentation is incomplete.
>    2a) The documentation is wrong.
>    3)  It's a bug.
>    3a) It's a bug and will be fixed in the next release.
>    4)  Yeah, it's a case of the implementation surfacing on the
>        language level, but we don't really care.
>    5)  We are Larry. Resistance is futile. You will be assimilated.

I'm inclined to choose 2 or 2a. I can't really decide which. I have
trouble parsing those sections of the manual you posted -- which I'd say
is a strong argument for both 2 _and_ 2a.

>I really hope for 3a), as that will make my 'deferred_interpolation'
>module much more useful. ;-)

-dlc


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

Date: Sun, 24 Sep 2000 14:23:43 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: regexp woes w/ Text-BibTeX
Message-Id: <39ce0bf8.2799944@news.newsguy.com>

John Hunter <jdhunter@nitace.bsd.uchicago.edu> wrote:

>sub texsafe {
>  my $arg = shift;
>  #quote any nonquoted special chars
>  my $special_chars = '%$#&_';
>  $arg =~s/([^\\])([$special_chars])/$1\\$2/g;  #this is the problematic line
>  $arg =~ s/([^\\])\"([^"]*)([^\\])\"/$1``$2$3''/g; #fix double quotes
>  return $arg;
>}

I can't reproduce your problem.  Can you post a complete
program, with sample data, that demonstrates it?

I do think your regular expressions could be improved with
negative look-behind.  As it is, they don't work at the
beginning of a string, and they don't work if you have two
special characters in a row (maybe that's the problem you're
having?).  These are better:

    $arg =~ s/(?<!\\)([$special_chars])/\\$1/g;
    $arg =~ s/(?<!\\)"([^"]*)(?<!\\)"/``$1''/g;

I'd also have made the previous line

    my $special_chars = quotemeta '%$#&_';

but that doesn't seem to make any difference.  I don't
understand why $# doesn't get interpolated into the character
class.  Another mysterious difference between regular
expressions and double-quoted strings.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: 24 Sep 2000 17:05:05 GMT
From: daniel@chetlin.com (Daniel Chetlin)
Subject: Re: regexp woes w/ Text-BibTeX
Message-Id: <8qlc81011qb@news1.newsguy.com>

On Sun, 24 Sep 2000 14:23:43 GMT, Keith Calvert Ivey <kcivey@cpcug.org> wrote:
>John Hunter <jdhunter@nitace.bsd.uchicago.edu> wrote:
[snip]
>>  my $special_chars = '%$#&_';
[snip]
>    $arg =~ s/(?<!\\)([$special_chars])/\\$1/g;
>    $arg =~ s/(?<!\\)"([^"]*)(?<!\\)"/``$1''/g;
>
>I'd also have made the previous line
>
>    my $special_chars = quotemeta '%$#&_';
>
>but that doesn't seem to make any difference.  I don't
>understand why $# doesn't get interpolated into the character
>class.  Another mysterious difference between regular
>expressions and double-quoted strings.

Hate to contradict the man fourth from the top in the positive half of
my killfile, but:

  my $special_chars = '%$#&_';
  my $double_quoted = "$special_chars";
  print $double_quoted,"\n";
  __END__
  %$#&_

I think you're confused, because Perl never does two-deep interpolation
unless you do something fancy.

-dlc


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

Date: Sun, 24 Sep 2000 19:36:17 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: regexp woes w/ Text-BibTeX
Message-Id: <39cf5454.606249@news.newsguy.com>

I wrote:

>These are better:
>
>    $arg =~ s/(?<!\\)([$special_chars])/\\$1/g;
>    $arg =~ s/(?<!\\)"([^"]*)(?<!\\)"/``$1''/g;

Those still won't handle unescaped special characters preceded
by escaped backslashes, but then the original code ignores the
possibility of escaped backslashes entirely (and doesn't attempt
to escape unescaped backslashes).

In fact, there is no real solution to the problem.  Once you've
put yourself into a position where you have a partially escaped
string, there's no way to know which characters need to be
escaped.  Should the sequence '\&', for example, be converted to
'\\\&' or left alone?

John Hunter needs to solve the problem earlier.  Get the string
in a completely unescaped form, and then escape all the
characters that need escaping.  Either that, or get it in a
completely escaped form and leave it alone.  Partial escaping
will only lead to frustration and errors.

>I'd also have made the previous line
>
>    my $special_chars = quotemeta '%$#&_';
>
>but that doesn't seem to make any difference.  I don't
>understand why $# doesn't get interpolated into the character
>class.  Another mysterious difference between regular
>expressions and double-quoted strings.

As Daniel Chetlin has gently pointed out, I was talking complete
rubbish here.  Variables within variables are of course not
interpolated.  Perhaps it was too early on a Sunday morning to
be posting.

The quotemeta() doesn't hurt, but for a string being
interpolated into a character class it's only necessary if the
characters include \ or ] (except at the beginning) or - (except
at the beginning or end) or ^ (at the beginning) -- I think.
Maybe there are some other possibilities.  That's why I'd use
quotemeta().

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Sun, 24 Sep 2000 15:36:19 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Regular Expression for matching with email addresses
Message-Id: <slrn8ss7rg.445.tjla@thislove.dyndns.org>

I was shocked! How could ohhhhhhme@my-deja.com <ohhhhhhme@my-deja.com>
say such a terrible thing:
>Best e-mail regex I ever seen is by Jim Smyser
>and looks like this:
>
>m@.*[=|:|>|<|"|\s|(]([\w\-]+\@.*?\w.*?\..*?)
>[:|>|<|"|\s|\?|\&|,|)]@

It's not that good. It doesn't match my other email address which looks
like this:

my.email@somewhere.com

nor:

someone@i.have.a.long.host.com

Also having those repeated '|' characters in the character classes is
not very efficient. Plus it's kind of ugly using '@' as the delimiter
when you are trying to match email addresses don't you think?

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
QOTD:
	"It was so cold last winter that I saw a lawyer with his
	hands in his own pockets."


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

Date: 24 Sep 2000 19:30:38 GMT
From: rsc@snipe.scd.ucar.edu (Bob Campbell)
Subject: safe2 test problem
Message-Id: <8qlkou$3q5$1@ncar.ucar.edu>

I've just compiled perl 5.005_02 on my Sparc 4, Solaris 7, with the
SunPRO compilers, v5, and I'm getting an error in the safe2 test
when I run 'make test'.  

The error I get is:
lib/safe2..........Use of uninitialized value at (eval 6) line 7.
Use of uninitialized value at (eval 6) line 3.
FAILED at test 10

So, to what degree should I be concerned about this?  The documentation
doesn't seem to say much about how to go about fixing whatever causes
certain tests to fail, and I can't find much on perldoc.com.  Nor does
it say anywhere how concerned I should be about certain tests.

If there's a 'Compiling Perl' FAQ out there, I've apparently missed it,
but if it exists, I'd appreciate a pointer to it.
 
Thanks,
--
Bob Campbell                    Unix System Administrator
Scientific Computing Division   National Center for Atmospheric Research
rsc@ucar.edu                    (303) 497-1815



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

Date: Sun, 24 Sep 2000 21:10:12 GMT
From: hiroshiishii@my-deja.com
Subject: Re: Testing file for directory: doesn't work
Message-Id: <8qlqja$fs3$1@nnrp1.deja.com>

Thanks for the advice, Bob.

I found this example in Perl Cookbook, which worked fine.

#!/usr/bin/perl -w
@ARGV = qw(.) unless @ARGV;
use File::Find;
find sub { print $File::Find::name, -d && '/', "\n" }, @ARGV;

Realized how poweful File::Find is!

-Hiroshi

In article <39CD71EC.A06510DF@rochester.rr.com>,
  Bob Walton <bwalton@rochester.rr.com> wrote:
> hiroshiishii@my-deja.com wrote:
> >
> > Hi all:
> >
> > I am programming to process certain files from the entire directory.
> > I came up with the following recursive subroutine.
> >
> > When I test a file for directory in the line 18 below, test failes.
> > Because $file doesn't have a complete PATH.  (I started perl from my
> > local subdirectory.)
> >
> > QUESTION: How can I make this test work and call this sub
recursively?
> >
> > T.I.A.
> >
> > -Hiroshi
> >
> > #!/usr/local/bin/perl5 -w
> > #use strict;
> > # This lists all files including subdirectories.
> >
> > print "Which directory? \n";
> > $start_dir = <STDIN>;
> > chomp $start_dir;
> > search($start_dir);
> >
> > #***********
> >  sub search
> > #***********
> > {
> >         my $dir = shift;
> >         opendir(DIR, $dir) or die "Cannot opendir $dir:$!";
> >         while (my $file = readdir DIR)
> >         {
> >                 next if ($file eq "." || $file eq "..");
> >                 if (-d $file) {
> >                 ############# (Line 18:)
> >                         search($file);
> >                         next;
> >                 }
> >                 print "$file\n";
> >         }
> >         closedir(DIR);
> > }
> ...
> You should consider what happens to your global filehandle variable
DIR
> when you call your routine recursively (hint: it gets clobbered).
Then
> you should consider the File::Find module, which should take care of
all
> that for you.
> --
> Bob Walton
>


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


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

Date: Sun, 24 Sep 2000 20:09:24 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: The best tutorial?
Message-Id: <39CE5F87.18B96CD2@rochester.rr.com>

Bob Walton wrote:
> 
> Giulio Agostini wrote:
> >
> > Hi, I'd like to teach myself Perl.
> > What's the best place to start? Maybe a free online tutorial?
> >
> > Thanks a lot.
> > Ciao, Giulio
> ...
> 
> The best place to start is with the book "Learning Perl" by Randall

Correction:  Randal Schwartz's first name has only one "l".  Sorry,
Randal.

> Schwartz, Tom Christiansen, and Larry Wall.
> 
>     http://www.oreilly.com
> 
> If you would like to try on-line tutorials, see:
> 
>     http://www.perl.com/reference/query.cgi?tutorials
> 
> And, of course, don't forget the wealth of info that's already on your
> hard drive if you have installed Perl.  At your command prompt, type:
> 
>     perldoc perldoc
> --
> Bob Walton


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

Date: 24 Sep 2000 20:44:44 GMT
From: abigail@foad.org (Abigail)
Subject: Re: The best tutorial?
Message-Id: <slrn8sspri.lo9.abigail@alexandra.foad.org>

Bob Walton (bwalton@rochester.rr.com) wrote on MMDLXXXI September
MCMXCIII in <URL:news:39CE5F87.18B96CD2@rochester.rr.com>:
"" Bob Walton wrote:
"" > 
"" > Giulio Agostini wrote:
"" > >
"" > > Hi, I'd like to teach myself Perl.
"" > > What's the best place to start? Maybe a free online tutorial?
"" > >
"" > > Thanks a lot.
"" > > Ciao, Giulio
"" > ...
"" > 
"" > The best place to start is with the book "Learning Perl" by Randall
"" 
"" Correction:  Randal Schwartz's first name has only one "l".  Sorry,
"" Randal.
"" 
"" > Schwartz, Tom Christiansen, and Larry Wall.


Learning Perl only has 2 authors, and Larry isn't one of them.



Abigail
-- 
perl -wlpe '}$_=$.;{' file  # Count the number of lines.
#    A flying kingfisher.
#    A kingfisher above
#    the pool. A dove flies.


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

Date: Sun, 24 Sep 2000 18:58:27 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: vertical text renderer
Message-Id: <x7k8c1borv.fsf@home.sysarch.com>

>>>>> "G" == Godzilla!  <godzilla@stomp.stomp.tokyo> writes:

  G> Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
  G> UofD: University of Duh! ¦ ENIAC Hard Wiring Pro

like i said, a mail order degree. you must have graduated summa stupid
loudmouth.


hey moronzilla,

just acknowledge you totally blew this one (among all the others you
have blown). the OP asked for a GIF with vertical text. A GIF!!! can you
read that, 

	A GIF!!

not html.

so you answer was nothing close to what he asked for. that reflects on
your incredible lack of comprehension shown here on a regular basis.

you can't back out of this with any slithering excuse. you posted an
html answer to a request for a GIF.

now, for a challenge, write a solution in perl4 to generate that gif
with no outside code. given a string of text, generate a GIF with the
text displayed vertically. go ahead, show off your incredible coding
skills. let's see you do that. otherwise, just shut the fuck up and
learn some reading comprehension skills.

a final reminder:

	HTML is not the same as GIF.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sun, 24 Sep 2000 12:21:14 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: vertical text renderer
Message-Id: <39CE542A.F931F9ED@stomp.stomp.tokyo>

Uri Butthead messed his diapers and screamed:
 
> > Godzilla! wrote:
 
>   G> Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
>   G> UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
 
> like i said, a mail order degree. you must have graduated summa stupid
> loudmouth.
 
> hey moronzilla,
 
> just acknowledge you totally blew this one (among all the others you
> have blown). the OP asked for a GIF with vertical text. A GIF!!! can you
> read that,
 
>         A GIF!!
 
> not html.
 
> so you answer was nothing close to what he asked for. that reflects on
> your incredible lack of comprehension shown here on a regular basis.
 
> you can't back out of this with any slithering excuse. you posted an
> html answer to a request for a GIF.
 
> now, for a challenge, write a solution in perl4 to generate that gif
> with no outside code. given a string of text, generate a GIF with the
> text displayed vertically. go ahead, show off your incredible coding
> skills. let's see you do that. otherwise, just shut the fuck up and
> learn some reading comprehension skills.
 
> a final reminder:
 
>         HTML is not the same as GIF.
 



*maniacal laughter*

Your high degree of illiteracy and lack of
reading comprehension skills, a statement
which is duality oxymoronic, your ignorance
sho nuff leads to your making some very
comical statements.

You claim to be an MIT graduate?

*more maniacal laughter*


Godzilla!
-- 
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class


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

Date: Sun, 24 Sep 2000 19:32:35 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: vertical text renderer
Message-Id: <x7em29bn6z.fsf@home.sysarch.com>

>>>>> "G" == Godzilla!  <godzilla@stomp.stomp.tokyo> writes:

  G> skills, a statement which is duality oxymoronic, your ignorance sho
                                  ^^^^^^^^^^^^^^^^^^ 

some high quality english right there. which comic book did you order
your degree from?

ignorance? the OP asked for a GIF. you posted some dumbass html
answer. simple correct/incorrect situation and you were incorrect. you
read the problem wrong. you didn't answer it. that is a sign of not
comprehending the request. you can't interpret that in any other way.

  G> You claim to be an MIT graduate?

i don't need to claim it. they do. check their records. you couldn't
even get a job there as a janitor. those jobs have requirements for
common sense.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sun, 24 Sep 2000 12:44:38 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: vertical text renderer
Message-Id: <39CE59A6.446E81BC@stomp.stomp.tokyo>

Uri Butthead, green with envy, hissed:

> > Godzilla! quips:
 
> > skills, a statement which is duality oxymoronic, your ignorance sho
                                   ^^^^^^^^^^^^^^^^^^
 
> some high quality english right there. which comic book did you order
> your degree from?
 
> ignorance? the OP asked for a GIF. you posted some dumbass html
> answer. simple correct/incorrect situation and you were incorrect. you
> read the problem wrong. you didn't answer it. that is a sign of not
> comprehending the request. you can't interpret that in any other way.
 
> > You claim to be an MIT graduate?
 
> i don't need to claim it. they do. check their records. you couldn't
> even get a job there as a janitor. those jobs have requirements for
> common sense.



*snaps her fingers*

Ahhh.. shucks. This boy is so ignorant, he missed
my "an MIT" Socratic Irony. What a spoil sport.
Suppose I will have to use a night crawler as
bait for this live one.


-- 
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class


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

Date: Sun, 24 Sep 2000 19:53:44 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: vertical text renderer
Message-Id: <x7bsxdbm7q.fsf@home.sysarch.com>

>>>>> "G" == Godzilla!  <godzilla@stomp.stomp.tokyo> writes:

  >> > skills, a statement which is duality oxymoronic, your ignorance sho
                                    ^^^^^^^^^^^^^^^^^^

you haven't addressed the above stupidity and the main issue of not
answering the OP. what about that html vs. gif stuff. deal with that and
nothing else first. try it for a change.

uri
 
-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sun, 24 Sep 2000 13:09:46 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: vertical text renderer
Message-Id: <39CE5F8A.3F73DC38@stomp.stomp.tokyo>

Uri Guttman slobbers, genuflects and begs:
 
> > Godzilla! writes well over his head:
 
> > skills, a statement which is duality oxymoronic, your ignorance sho
                                                     ^^^^^^^^^^^^^^
 
> you haven't addressed the above stupidity and the main issue of not
> answering the OP. what about that html vs. gif stuff. deal with that and
> nothing else first. try it for a change.



Change your dirty diaper first. You smell
something God Awful!

*pinches her nose, nasal voice*

ewww... worse than anything my girl ever made
in her diapers. ewww... ewww...


Godzilla!
-- 
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class


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

Date: Sun, 24 Sep 2000 19:48:34 GMT
From: Alex Hart <news@#nospam#althepal.com>
Subject: when is a DBM worth it
Message-Id: <mUsz5.10913$T6.482638@typhoon2.ba-dsg.net>

I'm writing a program where each user has several setting. The number of
fields varies, but is always less than 100 or so. Is the overhead
associated with a database worth it for this many fields? Will a flat
file be more efficient? I'm hoping someone who understands these isues
can help shed some light on it for me.

Bottom line : Is there a minimum number of fields or complexity before a
DBM is worth using.

Thanks already.

- Alex



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

Date: Sun, 24 Sep 2000 19:11:03 GMT
From: gerrit_griebel@my-deja.com
Subject: Re: www.perl.com won't come in on my computer....
Message-Id: <8qljjr$8f1$1@nnrp1.deja.com>


> I have a weird problem that I'm not sure of the source.  It could be
> my DSL's problem or my Mac's problem.  For some reason, when I'm
> working on my Mac in MacOS, I can't get www.perl.com to come up in
> either Netscape or Internet Explorer.  I'm on SWBell's DSL (evil
> bastards) and MacOS8.1 (no flames please).

I have problem with Linux, DSL and Netscape and
running vmware and IE I have the same behavior.
I tried lynx and w3m: the same. I tried wget and
got this:

$ wget www.perl.com
--20:53:09--  http://www.perl.com:80/
           => `index.html'
Connecting to www.perl.com:80... connected!
HTTP request sent, awaiting response... 302 Found
Location: http://www.perl.com/pub [following]
--20:53:10--  http://www.perl.com:80/pub
           => `pub'
    0K ->

20:53:11 (1.05 KB/s) - `pub' saved [14]

The file pub then contains the line:

REFER TO: <br>

Strange...
Gerrit



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


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