[22195] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4416 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 16 18:05:55 2003

Date: Thu, 16 Jan 2003 15:05:07 -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           Thu, 16 Jan 2003     Volume: 10 Number: 4416

Today's topics:
        ANNOUNCE: CGI::Widget::Tabs v. 1.06 <NO.koos.JUNK.pol.MAIL@raketnet.nl>
    Re: Day of the month redirection <rgarciasuarez@free.fr>
        Equivalent of /g for unpack? (jtd)
    Re: how to Install tar ball perl 5.8 to replace 5.6.1 i <rgarciasuarez@free.fr>
    Re: Outputting a binary file to the browser (AG)
    Re: Outputting a binary file to the browser <bongie@gmx.net>
    Re: Outputting a binary file to the browser <bongie@gmx.net>
    Re: Outputting a binary file to the browser <tassilo.parseval@post.rwth-aachen.de>
        perl hashes seems to slow down (nayeem)
        Perl Module for "compressing" text (f u cn rd ths...) <ethan@draupnir.gso.saic.com>
    Re: Question about high performance spidering in perl (Tad McClellan)
        Recreating a MIME::Lite object <me@privacy.net>
    Re: Recreating a MIME::Lite object <mbudash@sonic.net>
    Re: regex newbie (Sara)
    Re: Suggestion: sub mysort(&?@) or (& @) <occitan@esperanto.org>
    Re: sysopen problem <neil@alaweb.com>
    Re: variable interpolation inside a regex (Tad McClellan)
    Re: variable interpolation inside a regex (Walter Roberson)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 16 Jan 2003 22:55:43 +0100
From: Koos Pol <NO.koos.JUNK.pol.MAIL@raketnet.nl>
Subject: ANNOUNCE: CGI::Widget::Tabs v. 1.06
Message-Id: <b079ov$la3fb$1@ID-171888.news.dfncis.de>


Announcement for CGI::Widget::Tabs, version 1.06
The changes for this version are:

- Minor interface change as promised in the 1.05 release:
  $h->raw_text(STRING) has been superseded by
  $h->raw(BOOLEAN). For a background of the reason, see the
  BUGS section in the documentation of the 1.05 release. For
  the current workings, see the documentation in this release
  for the methods $h->text() and $h->raw().

- Dropped the "use warnings" to support Perl <= 5.005.
  But CGI::Widget::Tabs pretends to be warning free all
  together.

Enclosed is the README for reference.


Best regards,
Koos Pol



CGI::Widget::Tabs
=================



DESCRIPTION

CGI::Widget::Tabs lets you simulate tab widgets in HTML. You
could benefit from a tab widget if you want to serve only one
page. Depending on the tab selected you fetch and display the
underlying data. There are two main reasons for taking this
approach:

1. For the end user not to be directed to YAL or YAP (yet another
link / yet another page), but keep it all together: The single
point of entry paradigm.

2. As a consequence the end user deals with a more consistent and
integrated GUI. This will give a better "situational awareness"
within the application.

3. For the Perl hacker to handle multiple related data sources
within the same script environment.

As an example the following tabs could be used on a web page for
someone's spotting hobby:

      __________      __________      __________
     /  Planes  \    /  Trains  \    / Classics \
------------------------------------------------------
         _________
        /  Bikes  \
------------------------

As you can see, the headings wrap at three and a small
indentation is added to the start of the next row. The nice thing
about CGI::Widget::Tabs is that the tabs know their internal
state. So you can ask a tab for instance which heading has been
clicked by the user. This way you get instant feedback.



DOCUMENTATION

The documentation is included in the module. You can read it's
manpage after installation with `perldoc CGI::Widget::Tabs'. If
you prefer you can read the documentation before installation
with `perldoc ./Tabs.pm'



DEPENDENCIES

- CGI, CGI::Minimal or another CGI "object broker"
  with the param() method and with similar behaviour
- HTML::Entities
- URI
- A CSS style sheet for the tabs markup



INSTALLATION

To install this module type the following:

perl Makefile.PL
make
make test
make install



DOWNLOAD

You can download CGI::Widget::Tabs from CPAN at
http://cpan.perl.org. The latest version is always available from
the CGI::Widget::Tabs homepage at:
http://users.raketnet.nl/koos_pol/en/Tabs/index.html



COPYRIGHT AND LICENCE

Copyright (c) 2003 Koos Pol. All rights reserved.

This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.



CHANGES

These changes are against the previous version.  For a complete
history log, see the file 'CHANGES' in the distribution.

1.06 (2003-01-16)
-----------------
    - Minor interface change as promised in the 1.05 release:
      $h->raw_text(STRING) has been superseded by
      $h->raw(BOOLEAN). For a background of the reason, see the
      BUGS section in the documentation of the 1.05 release. For
      the current workings, see the documentation in this release
      for the methods $h->text() and $h->raw().

    - Dropped the "use warnings" to support Perl <= 5.005.
      But CGI::Widget::Tabs pretends to be warning free all
      together.


-- 
KP
koos _ pol @ raketnet nl


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

Date: 16 Jan 2003 21:07:11 GMT
From: Rafael Garcia-Suarez <rgarciasuarez@free.fr>
Subject: Re: Day of the month redirection
Message-Id: <slrnb2e7lp.p8.rgarciasuarez@dat.local>

brian d foy wrote in comp.lang.perl.misc :
> 
> i have always found it easier to have a static URL which returns
> the right data rather than redirecting every request.  just update
> the page (or link to the right page) depending on the day, using
> your favorite scheduling utility.

Not only is it easier, it also avoids the cost of forking a CGI program
and sending an external redirect.

Well-crafted apache configuration can also do this.


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

Date: 16 Jan 2003 14:17:46 -0800
From: adwser@hotmail.com (jtd)
Subject: Equivalent of /g for unpack?
Message-Id: <c57c103.0301161417.44d85c26@posting.google.com>

Is there a way of emulating the /g regexp modifier for unpack? I have
a binary file where bit encodings depend on the result of the previous
bits. A slightly messy hack is to take small substrings of the binary
file (which fits in memory) and use unpack on that substring, but if
there's an idiomatic way of doing this, I'd love to know.

Thanks in advance!
jtd


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

Date: 16 Jan 2003 21:07:12 GMT
From: Rafael Garcia-Suarez <rgarciasuarez@free.fr>
Subject: Re: how to Install tar ball perl 5.8 to replace 5.6.1 in Redhat ??
Message-Id: <slrnb2e7qt.p8.rgarciasuarez@dat.local>

Tassilo v. Parseval wrote in comp.lang.perl.misc :
> 
> If you want to install it by compiling perl yourself, simply do so
> without removing the old perl from your machine. You can have as many
> Perl distributions living happily next to each other on the same computer. 
> 
> Grab the tarball, extract and read INSTALL. The install script will
> later ask you where it should put this perl. I have both Perl5.8.0 and
> 5.5.3 somewhere under /usr/opt. After that put some symlinks into the path
> (something like /usr/bin/perl580 and /usr/bin/perldoc580) that point to
> the real path.

Personally I prefer /usr/local (that's the default).

If you don't specify -Uinstallusrbinperl on the Configure command-line,
the installation process will also install the newest perl as
/usr/bin/perl. That's usually harmless since the perl binary is also
installed as 'perlX.Y.Z' next to 'perl'.


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

Date: 16 Jan 2003 12:48:12 -0800
From: ag269@columbia.edu (AG)
Subject: Re: Outputting a binary file to the browser
Message-Id: <6c4429bb.0301161248.46c0c2ff@posting.google.com>

tony@svanstrom.com (Tony L. Svanstrom) wrote in message news:<1fovhv9.1whhfybqkl0l2N%tony@svanstrom.com>...
> Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote:
> 
> > I don't know the content-type for rar though, application/rar perhaps.
> 
>  application/x-rar-compressed

Thank you Tassilo and Tony,

all the relevant headers are there, I just omitted  them in my post.

Unfortunately, the problem persists, and it's driving me crazy since
everything works perfectly with PHP readfile().

I really dont know what the problem might be. And the script does work
in console

I post my entire script again. Im using MSIE, the server is Apache.

#!/usr/bin/perl -w

use MIME::Types();
 
$file="crosstable.rar";

($media_type) = MIME::Types::by_suffix($file);

$length=length($file);
$|=1;
open(FILE,$file);

 
print "Content-Type: ".$media_type. "\n";
print "Cache-Control: no-cache \n";
print "Content-Length: $length \n";
print "Content-Disposition: attachment; filename=".$file."\n";
binmode(FILE);
binmode(STDOUT);

my $buf;
print STDOUT $buf while read FILE, $buf, 4092;

close(FILE);
close STDOUT;


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

Date: Thu, 16 Jan 2003 22:09:55 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: Outputting a binary file to the browser
Message-Id: <1095562.nOP7QF9lTu@nyoga.dubu.de>

AG wrote:
> $file="crosstable.rar";
> 
> ($media_type) = MIME::Types::by_suffix($file);
> 
> $length=length($file);

This should be
        $length = -s $file;

(length($file) will of course be 14. :))

Ciao,
        Harald
-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
My brain is not thread safe.
                -- Xho in comp.lang.perl.misc


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

Date: Thu, 16 Jan 2003 22:15:15 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: Outputting a binary file to the browser
Message-Id: <4970301.SnK9upR6vo@nyoga.dubu.de>

Harald H.-J. Bongartz wrote:
> AG wrote:
>> $file="crosstable.rar";
>> 
>> ($media_type) = MIME::Types::by_suffix($file);
>> 
>> $length=length($file);
> 
> This should be
>         $length = -s $file;

 ...and, of course, checking for errors would be nice, here and for the
open() call later:

        $length = -s $file or die "cannot stat $file: $!";
        ...
        open (FILE, $file) or die "cannot open $file: $!";

(maybe combined with "use CGI::Carp qw(fatalsToBrowser);" or other means
of telling the user, too, that something went wrong)

Ciao,
        Harald
-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Interesting Error Messages #4:
Press Esc key to reboot Universe, or any other key to continue... 



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

Date: 16 Jan 2003 22:10:28 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Outputting a binary file to the browser
Message-Id: <b07akk$2ls$1@nets3.rz.RWTH-Aachen.DE>

Also sprach AG:

> tony@svanstrom.com (Tony L. Svanstrom) wrote in message news:<1fovhv9.1whhfybqkl0l2N%tony@svanstrom.com>...
>> Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote:
>> 
>> > I don't know the content-type for rar though, application/rar perhaps.
>> 
>>  application/x-rar-compressed
> 
> Thank you Tassilo and Tony,
> 
> all the relevant headers are there, I just omitted  them in my post.
> 
> Unfortunately, the problem persists, and it's driving me crazy since
> everything works perfectly with PHP readfile().
> 
> I really dont know what the problem might be. And the script does work
> in console
> 
> I post my entire script again. Im using MSIE, the server is Apache.
> 
> #!/usr/bin/perl -w
> 
> use MIME::Types();
>  
> $file="crosstable.rar";
> 
> ($media_type) = MIME::Types::by_suffix($file);
> 
> $length=length($file);

This computes the length of the string $file. You want

    $length = -s $file;
    
> $|=1;
> open(FILE,$file);

Error checking would be good:

    open FILE, $file or die horribly;
    
> print "Content-Type: ".$media_type. "\n";
> print "Cache-Control: no-cache \n";
> print "Content-Length: $length \n";
> print "Content-Disposition: attachment; filename=".$file."\n";
> binmode(FILE);
> binmode(STDOUT);

The header must be separated from the data with a newline. Therefore:

    print "Content-Disposition: attachment; filename=$file\n\n";
                                                          ^^^^
                                                        two of them!

Also, Perl variables (that is, scalars and arrays) interpolate nicely
within double quotish strings so there is no need to use explicit
concatenation with the dot operator.

> my $buf;
> print STDOUT $buf while read FILE, $buf, 4092;

4092 is ok, but using a number which is the power of 2 is slightly less
wasteful: 4096 is more common.

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: 16 Jan 2003 11:33:20 -0800
From: nayeem@ntlworld.com (nayeem)
Subject: perl hashes seems to slow down
Message-Id: <50e1bf38.0301161133.1af1539e@posting.google.com>

fellow japhs,
ive been using perl hashes for a recent project, but it seems for some
reason it gives a speed issue when i am browsing through the hash.
the hash is roughly the following structure :

$rs = {'SUGGESTED_WORDS' => [
   {'NAME' => '...'},
   {'NAME' => '...'},
   {'NAME' => '...'},
   {'NAME' => '...'},
   ...
]
};

so its a hashref of a listref of a hashref. obviously this top hashref
is much bigger and has other elements then 'suggested_words'. i am
only quoting an extract from the hash.

when i try to browse through the hash and say add one more field in
the SUGGESTED_WORDS list eg using a code as below :

=1= for (my $i=0;$i<scalar(@{$rs->{SUGGESTED_WORDS}});$i++) {
=2=    my $word = $rs->{SUGGESTED_WORDS}->[$i];
=3=    my $the_word = $rs->{SUGGESTED_WORDS}->[$i]->{WORD};
=4=    $word->{URL} = "abc";
=5= }

now questions:
1) if i change line =3= to be 
   my $the_word = $word->{WORD}
the system becomes extremely slow in making this simple assignment...
anyone knows why this happens? is it a bug built-into perl? or am i
missing something obvious?

2) if i change line =4= to be 
   $rs->{SUGGESTED_WORDS}->[$i]->{URL} = "abc"
the assignment never happens. again, anyone knows what reason lies
behind this?

3) i am a bit concerned about use of hashes in general. the
application i am writing is very mission critical in that it requires
very fast response time, if there is any way i can improve on the
speed by replacing hash with something else or anything i would very
much like to know more on that since i am using a very large hash that
actually has a massive XML output in it.

any comments/suggestions/ideas/criticisms would be most appreciated.

nayeem


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

Date: 16 Jan 2003 13:17:14 -0800
From: Ethan Brown <ethan@draupnir.gso.saic.com>
Subject: Perl Module for "compressing" text (f u cn rd ths...)
Message-Id: <vrof6gn6at.fsf@draupnir.gso.saic.com>

Hi Group!

Does anyone know of a module to "compress" text, e.g.
"If you can read this you can have a job as a perl programmer"
=>
"f u cn rd ths u cn hv a jb as a prl prgrmmr"

Thanks,

--Ethan Brown (ethan@NOSPAMethanbrown.org)
--Keyboards: "The Fabulous Pelicans" (www.pelicans.com)
--In a band?  Use http://www.WheresTheGig.com for free.



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

Date: Thu, 16 Jan 2003 13:51:12 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Question about high performance spidering in perl
Message-Id: <slrnb2e39g.fhn.tadmc@magna.augustmail.com>

Extended Partition <extendedpartition@NOSPAM.yahoo.com> wrote:

> To be honest when I accepted this project I was
> under the assumption that I was facing a few weeks worth of work. Now
> I realize it'll be more like several months if I'm lucky.


I hope it wasn't a fixed-price bid.  :-)


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


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

Date: Fri, 17 Jan 2003 07:52:26 +1100
From: "Tintin" <me@privacy.net>
Subject: Recreating a MIME::Lite object
Message-Id: <b0762d$llu9r$1@ID-172104.news.dfncis.de>

This might be a silly question, but here goes.

I'm using MIME::Lite to send out emails with attachments, and now have a
requirement to create the mail and store it in a file for accessing at a
later date.

So I store the mail using something similar to:

my $msg = MIME::Lite->new(
                 From     =>'me@myhost.com',
                 To       =>'you@yourhost.com',
                 Cc       =>'some@other.com, some@more.com',
                 Subject  =>'Helloooooo, nurse!',
                 Type     =>'image/gif',
                 Encoding =>'base64',
                 Path     =>'hellonurse.gif'
		 );

my $mail = $msg->as_string;

open FILE, ">mail" or die "Can not write to mail $!\n";
print FILE $mail;
close FILE;


Now what I'd like to do is to somehow read in the contents of the file and
recreate the MIME::Lite object.

I'm aware of the fh instance method, but that's only applicable for the
message body.

Is this possible, or can someone suggest an alternative route to take?









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

Date: Thu, 16 Jan 2003 22:02:16 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Recreating a MIME::Lite object
Message-Id: <mbudash-C27A55.14021516012003@typhoon.sonic.net>

In article <b0762d$llu9r$1@ID-172104.news.dfncis.de>,
 "Tintin" <me@privacy.net> wrote:

> This might be a silly question, but here goes.
> 
> I'm using MIME::Lite to send out emails with attachments, and now have a
> requirement to create the mail and store it in a file for accessing at a
> later date.
> 
> So I store the mail using something similar to:
> 
> my $msg = MIME::Lite->new(
>                  From     =>'me@myhost.com',
>                  To       =>'you@yourhost.com',
>                  Cc       =>'some@other.com, some@more.com',
>                  Subject  =>'Helloooooo, nurse!',
>                  Type     =>'image/gif',
>                  Encoding =>'base64',
>                  Path     =>'hellonurse.gif'
> 		 );
> 
> my $mail = $msg->as_string;
> 
> open FILE, ">mail" or die "Can not write to mail $!\n";
> print FILE $mail;
> close FILE;
> 
> 
> Now what I'd like to do is to somehow read in the contents of the file and
> recreate the MIME::Lite object.
> 
> I'm aware of the fh instance method, but that's only applicable for the
> message body.
> 
> Is this possible, or can someone suggest an alternative route to take?

the Storable module appears to do what you want:

#-------
use Storable;
use MIME::Lite;
my $msg = MIME::Lite->new(
                 From     =>"me\@myhost.com",
                 To       =>"you\@yourhost.com",
                 Cc       =>"some\@other.com, some@more.com",
                 Subject  =>"Helloooooo, nurse!",
                 Type     =>"image/jpeg",
                 Encoding =>"base64",
                 Path     =>"chk.jpg"
 );

store $msg, 'file';
my $msgcopy = retrieve('file');
#-------

hth-


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

Date: 16 Jan 2003 13:36:39 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: regex newbie
Message-Id: <776e0325.0301161336.401b4048@posting.google.com>

Jens Hoehne <hazelbigfoot@gmx.net> wrote in message news:<3E26DD2D.8CBFB56C@gmx.net>...
> edwardquick@hotmail.com wrote:
> > 
>  [...]
> >  And also point me to a
> > really really good regex tutorial?
> 
> You could try out your local perldoc information:
> perldoc perlretut
> and
> perldoc perlre
> 
> There is also a book - Mastering Regular Expressions - by Jeffrey E. F.
> Friedl if you want to go really deep. 
> 
> Regards, 
> Jens

I met Jeffrey - a very nice fellow, and in fact I'd say  this is a
MUST read for potential perlistas. Honestly, you need to sharpen your
saw before you start cutting. At the very least, study the REGEX
portion of Camel. It's not that long and its very informative.

If you want to really prep yourself in REGEXes, read at least the
first 1/2 of Jeffrey's book. I've been programming Perl now for oh,
4-5 years (has it been THAT LONG!!?), and reading this book was
perhaps the most valuable time spent. I'm no regex guru, but I can
generally tweak one now to do 95% of the real work in my code (we do a
lot of form processing).. And a bonus- most of Jeffrey's examples are
IN PERL! Study them; try them out for yourself. Extend them to
examples you might encounter like the one you cited.

You really aren't writing Perl if you don't have at least a cursory
ability in Regexes. Take the time up front to learn them well- that
effort will pay for itself for your entire Perl career..

Cheers!
-Gx


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

Date: Thu, 16 Jan 2003 21:28:19 +0100
From: Daniel Pfeiffer <occitan@esperanto.org>
Subject: Re: Suggestion: sub mysort(&?@) or (& @)
Message-Id: <20030116212819.40b508d3.occitan@esperanto.org>

Daniel Pfeiffer <occitan@esperanto.org> skribis:

> it is inconsistent that functions like sort can have an optional first code
> block, while if I declare mysort(&@) it becomes mandatory.  Having to pass
> undef as first argument, when you don't want it, is ugly.  And having to put
> a comma, beacause it's not a code block is also inconsistent with sort.

> Now, if we could have a prototype like above (I don't care how, ? is as in
> regexps, ' ' is because, if it's there, it has to be followed by a space, not
> a comma, then this function would work like the original:

> @list = mysort { ... } @list;
> @list = mysort $subref @list;
> @list = mysort @list;

> The parser can already handle it, and it wouldn't break any compatibility.

Actually  grep /.../, @list  and  map "add $_ some", @list  are also
inconsistent, because the first argument is a hidden code ref.  So, there
should be no comma!  I believe the comma should be deprecated.  Then the
suggested prototype would cover those too! 

coralament / best Grötens / liebe Grüße / best regards / elkorajn salutojn
Daniel Pfeiffer

-- GPL 3: take the wind out of Palladium's sails! --
 ------
  -- My other stuff here too, sawfish, make.pl...: --
   ------
    -- http://dapfy.bei.t-online.de/ --


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

Date: Thu, 16 Jan 2003 14:39:51 -0600
From: "Neil Trenholm" <neil@alaweb.com>
Subject: Re: sysopen problem
Message-Id: <v2e64gjadhak1c@corp.supernews.com>

"Ben Morrow" <mauzo@ux-ma160-16.csv.warwick.ac.uk> wrote in message
news:b06rer$h2o$1@wisteria.csv.warwick.ac.uk...
> "Neil Trenholm" <neil@alaweb.com> wrote:
> >I've read many of your insightful posts and find them most helpful ! They
> >also seem less picky or elitist than _some_ of the regular, knowledgable
> >posters - whose usual and regular answer is RTFM or 'perdoc XXX'.
>
> Now that is more than a little unfair. I would certainly not put myself
into
> the above category, but those who are very rarely just tell someone to
RTFM
> without telling them which of the (as you say) very many FMs to read. You
> really should not bet upset by a 'perldoc *' reply: noone is being rude,
or
> implying you're stupid. or anything (well, not necessarily); just assuming
> that you want the correct answer to your question. The manuals go over the
> answers rather better than someones quickly-composed reply will (as I
found not
> long ago, when I thought I'd give a 'helpful' answer and missed something
> important: a perldoc -f my would have been much better... :).

I'm sorry if my statement seems more than a little unfair. It was not my
intention to knock anyone - but rather commend Anno for often going 'above
and beyond'.

I was not aiming this at any one person in particular and definitely not
your previous post, nor any in this thread. I have no problem with someone
pointing me to "perldoc -f XXX" - with little/no explanation. And as far as
implying that I am stupid ...well ... I do have stupid days - as I am sure
we all do occassionally. ;-) But I definitely don't assume that a short
answer implies my stupidity. It takes a lot to get me P'd off.

> > No matter how much we RTFM's (1000's of pages - when taking it all into
> >account) there will still be some scrap of knowledge that we don't know
 ...
> >or don't understand.
>
> Noone expects you to know all the docs by heart. They expect you to have
tried,
> and they expect you to read the docs when you're pointed in the right
> direction. If the docs are unclear (particularly the tutorial pages), I'm
quite
> sure people would be happy to explain them to you, and indeed then fix the
docs
> so they're more clear.
>
> > It's nice _not_ to get flamed for a misquote, poor
> >phrase, dropped semi-colon or other trivial matter.
>
> Misquotes are just rude.

Agreed.

> I don't think I've seen any spelling/grammar flames on this group (not
that
> I've been here long).

I've been here for a while and have seen a few (thankfully - only a few)
cases of this. But it does happen ... I've seen people "told off" because
they they typed PERL or Perl instead of perl ...and yes I know the
difference.... but the question was about the perl language and not 'the
correct spelling' ....and then it's flame war all 'round...

> Dropped semi-colon's are never trivial, and apart from anything else
indicate
> that you didn't try to run the actual code you posted, which is very
important.
> Noone can debug your code if it's got typos in.

I know - poor example ... as my earlier cut/paste of FCntl proved (error
included !) mistakes are not trivial. But sometimes a person can tell it was
a typoa (<-see?) and not actually related to the problem at hand.

>
> > I've been programming
> >for 20 years, perl for about 7 and still get butterflies posting to
cplm -
> >worried that I may drop  a character or not state the problem exactly
enough
> >or overstate the problem etc etc........
>
> Copy/paste is your friend when posting code. As for the other things,
well, if
> some people are a bit short with you just don't take it personally. It
> probably wasn't meant that way :)

Copy and paste in our friend. Agreed.  I didn't c/p because ....(c'mon Neil
justify yerself)...the script was about 400 lines and in an unfinished
package... (...poor excuse...)...so I tried to narrow it down to the buggy
portion. I think next time I will break out the buggy part to a different
short script, make sure it's still buggy (because I have fixed things doing
this before ;-o) and then post using c/p.

It was not my intention to imply that _ALL_ responders in clpm were/are
acting as rectal rings.

That said - it does seem that _some_ of the regular posters expect everyone
to 1)have the same base knowledge and 2) intuitively know what to search for
to solve the problem. As you may expect 'perldoc -f O_SVWST' produced  "No
documentation for perl function `O_SVWST' found" ... Googling O_SVWST
returned 9 results ... a recursive search of all files under /perl for the
string O_SVWST showed no files containing the string .....so I slept on it
 ... and tried again the next morning ... when actually I should have reread
the sysopen page. And had someone explain that "available via Fcntl" meant
"include this module." So I inadvertently started searching in the wrong
direction. My mistake, my fault, my problem. Thankfully you and Anno and
others pointed me in the right direction. :-)

All in all ... no matter how large or small the crowd ... a certain
percentage will be rectal rings - and I just wanted to acknowledge Anno for
NOT being one, in any of his posts that I have read.

I hope I have offended no-one .... except those that need offending every
now and then.

>
> Just my 2d.
>
> Ben

And I thank you for it !
Neil







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

Date: Thu, 16 Jan 2003 13:48:43 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: variable interpolation inside a regex
Message-Id: <slrnb2e34r.fhn.tadmc@magna.augustmail.com>

shambolic <johnston.jay@mtvne.com> wrote:
> Hi all,
> 
> is there a way of turning off variable interpolation within the
> left-hand (i.e. search) portion of s///?


Do you mean the pattern part of the operator?   s/here//

or do you mean the left side of the =~ binding operator?


> #!usr/bin/perl -w
> use strict;
> my $text = <STDIN>; # reading in text with special chars like $ or @ -
> say h@tt

say:

   my $text = 'h@tt';

and then we will know for sure what you mean.


> $text =~ s/tt/$other_text/;
> 
> i'm having a problem where perl thinks it's an array inside $text,


No you don't. The contents of $text are data, not code. Interpolation
only happens in code, so: no problem!

What makes you think that you have a problem?

What have you observed that isn't "right"?


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

my $text = 'h@tt';
my $other_text = 'XX';

$text =~ s/tt/$other_text/;
print "$text\n";
------------------------


Seems to work fine.


> wheras i want to treat it as a normal character.
> 
> grateful for any advice or assistance.


But you don't have a problem (that we can see...)


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


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

Date: 16 Jan 2003 20:00:12 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: variable interpolation inside a regex
Message-Id: <b0730c$t91$1@canopus.cc.umanitoba.ca>

In article <f333df78.0301161101.400e88d2@posting.google.com>,
shambolic <johnston.jay@mtvne.com> wrote:
:is there a way of turning off variable interpolation within the
:left-hand (i.e. search) portion of s///?

:#!usr/bin/perl -w
:use strict;
:my $text = <STDIN>; # reading in text with special chars like $ or @ - say h@tt
:$text =~ s/tt/$other_text/;

:i'm having a problem where perl thinks it's an array inside $text,
:wheras i want to treat it as a normal character.

I think you must be mistaken: perl never tries to interpolate the
string being acted upon for the s/// operator [though one could quibble
about the effect of the 'e' modifier.]

Perhaps the problem is in the $other_text variable? You haven't
defined it's value in this example. 

Or perhaps when you prepared this for posting, you simplified down
from something other than just /tt/ as the pattern? 


I have the sneaking suspicion that I should refer you to the \Q \E
interpolation modifiers.  s/\Q$bar\E/whatever/  will expand $bar but
will then quote all the non-word characters before using it as a pattern
for the substituation. 
-- 
This is not the same .sig the second time you read it.


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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


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


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