[23910] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6112 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 11 09:05:47 2004

Date: Wed, 11 Feb 2004 06:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 11 Feb 2004     Volume: 10 Number: 6112

Today's topics:
    Re: Anyone using Berkley XML DB w/Perl (of course)...? <paul.marquess@btinternet.com>
    Re: automatically send http header <thomas.deschepper.ecol@sintjozefscollege.be>
    Re: Comparing a string to filenames in a directory (nj_perl_newbie)
    Re: how to convert a string to an escaped string <nospam@bigpond.com>
    Re: how to convert a string to an escaped string <noreply@gunnar.cc>
    Re: Launching an .exe <bart.lateur@pandora.be>
    Re: Perl script into a Windows Service (Cosmic Cruizer)
    Re: Perl usage these days? <bobx@linuxmail.org>
    Re: Perl usage these days? <bobx@linuxmail.org>
    Re: Perl usage these days? <ian.cass@mblox.com>
        RFC: utils.pm <tore@aursand.no>
    Re: RFC: utils.pm <tassilo.parseval@rwth-aachen.de>
        Search and replace string <ajay_kumarsingh@yahoo.com>
    Re: Search and replace string <noreply@gunnar.cc>
    Re: Why is Perl losing ground? <tore@aursand.no>
    Re: Why is Perl losing ground? thumb_42@yahoo.com
    Re: Why is Perl losing ground? <ian.cass@mblox.com>
    Re: Why is Perl losing ground? (Randal L. Schwartz)
    Re: Why references?? <nobull@mail.com>
    Re: Why references?? <nobull@mail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 11 Feb 2004 12:58:59 -0000
From: "Paul Marquess" <paul.marquess@btinternet.com>
Subject: Re: Anyone using Berkley XML DB w/Perl (of course)...?
Message-Id: <c0d8um$15fjos$1@ID-211855.news.uni-berlin.de>

"Ben Morrow" <usenet@morrow.me.uk> wrote in message
news:c0ap5d$95u$1@wisteria.csv.warwick.ac.uk...
>
> "Paul Marquess" <paul.marquess@btinternet.com> wrote:
> > "Ben Morrow" <usenet@morrow.me.uk> wrote in message
> > news:c097lg$ajg$2@wisteria.csv.warwick.ac.uk...
> > >
> > > Vetle Roeim <vetro@online.no> wrote:
> > > > * ceo@nospan.on.net
> > > >   You're not going to find it on CPAN,  unfortunately. To install
it, I
> > > >   downloaded the source code, compiled it, and then installed the
Perl
> > > >   module from dbxml-1.2.0/src/perl.
> > >
> > > Having taken a look at that: bleech.
> >
> > Thanks for the constructive feedback Ben. :-)
>
> Sorry, that was a little rude... :(.
>
> > Seriously though, I'd be interested to hear in a bit more detail what
you,
> > and anoyone else in this thread, think about the current interface, both
> > good and bad.  To date, this is the first negative feedback I've
received.
> >
> > > Is it *quite* necessary to
> > > trample on that many different (including top-level and pragmatic)
> > > namespaces?
> >
> > Yes. There are quite a few objects exposed by the dbxml interface. If
you
> > want those C++ objects to map to Perl objects, you need a namespace for
> > each.
>
> Yes, but you don't need to give them the same names as the C++ classes
> had.

I assume your issue isn't really that I've used the same names as the C++
classes, but that I've put them in a top-level namespace? Ignoring namespace
issues for a moment, reusing the C++ class names seems to make perfect
sense.

> What happens if someone's using another XML module as well (not
> at all unlikely), and that happened to also define the package
> XmlDocument?
>
> Indeed, the C++ classes are all in the namespace DbXml, which will
> keep them from conflicting with any other XmlDocument class people
> might be using. I would have given the classes names like
> DB::XML::Container, and kept all the names below DB::XML, or
> something.

There is always a problem of clashing namespaces, and I accept that by using
quite a few top-level names I'm increasing that possibility. I'm not
convinced
it's as big a problem as you make out, but I'll have a think about this
one - my preferred choice would be to go for DbXml:: as the common prefix
for all the class names.

> > I didn't think I was reusing any  pragmatic namespaces - which are you
> > thinking of?
>
> std::exception. All lower-case top-level namespaces are reserved for
> pragmata.

Indeed it is.

> The whole exception-handling logic seems unnecessarily
> complex: what's wrong with
>
>     package DB::XML::Exception;
>
>     our @EXPORT = qw/catch/;
>
>     sub catch {
>         my $type = shift;
>         UNIVERSAL::isa($@, __PACKAGE__) and $@->{type} eq $type
>             and return $@;
>         return;
>     }
>
>     package main;
>
>     eval {
>         ...
>     }
>     if (my $e = catch 'DbException') {
>         ...
>     }

Ignoring the hoops I may have jumped through to implement my version of
"catch",  from an end users point of view, that looks very like what I've
already implemented.

One thing on my todo list is to provide a shortcut to get at the exception
string. I'll probably do it by overloading the stringification operator.

     eval {
         ...
     };

     if (my $e = catch XmlException) {
         print "got this exception $e\n";
     }

> or
>
>     if (ref $@ and $a->isa(DB::XML::X::DbDeadlock)) {

Personally, I hate that syntax in user code, although it should already work
with my current
interface. :-)

> or even
>
>     if ($@ and $!{EDEADLK}) {
>
> , which I at least find much more Perlish? The mapping seems pretty
> clear:
>
> DbDeadlockException          EDEADLK
> DbException                  is never thrown
> DbLockNotGrantedException    EWOULDBLOCK
> DbRunRecoveryException       EINVAL
>
> etc. XmlException could probably just throw a string.

If I was going to go down that route, I'd rip out the exception handling
interface and use return codes instead.

> I realise this means you can't just get the typemap to do all the work
> :).

Quite so :-)

> > > And is it really necessary to have the interface be so C++ish?
> >
> > Well it is an interface to a C++ library after all  :-)
>
> True... your BerkeleyDB module, though, provides a much more Perl-ish
> interface to the C db libraries.

I think there are a couple of  reasons for the difference in the interfaces
I created. The first is simply down to the fact that the native dbxml
interface is C++, while Berkeley DB is C.

The other reason I've deliberately kept close to the C++ interface was to
future proof myself. The dbxml library is still quite young and has already
changed a couple of times --  I don't want to paint myself into any corner
with interface decisions.

cheers
Paul




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

Date: Wed, 11 Feb 2004 13:37:52 +0100
From: Thomas Deschepper <thomas.deschepper.ecol@sintjozefscollege.be>
Subject: Re: automatically send http header
Message-Id: <c0d7mv$ah6$1@news.worldonline.be>

[Tuesday 10 February 2004 00:06]Alex Shi (chpshi@stonix.com) wrote:

> With php you don't need to explicitly send http header before
> print or echo. However in perl you need it. Even with mod_perl
> you have to issue following before any http output
> 
> print "Content-type: text/plain\n\n";
> 
> I am just wondering if it possible to add a command in Apache
> configuration so that we don't need the line of sending header
> in perl script?
> 
> Thanks in advance!
> 
> Alex Shi
> 
> 

I think this can be achieved by using CGI.pm


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

Date: 11 Feb 2004 05:30:06 -0800
From: aotoole@optonline.net (nj_perl_newbie)
Subject: Re: Comparing a string to filenames in a directory
Message-Id: <d7fb9254.0402110530.11e075c7@posting.google.com>

Okay, thank you all for your suggestions.  I realise that I reposted a
couple of the same syntax errors and I apologize if that caused any
confusion.

Tintin: I was thanking Jurgen for his quick feedback, at the time he
was the only person who replied to my post.

Ricky: thanks for your help  this looks like a nice suggestion

Tad, I have not yet read the posting guidlines, I will search for them
today.  My original question wasn't really about the syntax of the
program.  I know that I had a few random ;s, I was originally asking
how one would approach this problem using Perl's text processing
features.

Thank you all of your sugestions, I will play with this some more
today.


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

Date: Tue, 10 Feb 2004 23:28:48 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: how to convert a string to an escaped string
Message-Id: <c0danb$14spr6$2@ID-202028.news.uni-berlin.de>

Gunnar Hjalmarsson wrote:

> Lowell Kirsh wrote:
>> Very funny...
> 
> Glad you think so. Don't top post, btw.
> 
>> How about a perl function that can convert a string to
>> another string in which special chars are represented as escaped
>> versions of themselves...
> 
> Yes, there is such a function.
> 
>      perldoc -f quotemeta
> 
> Why didn't you just look it up instead of posting here?

Thats a stupid statement.

This group reeks of arrogance. People ask legitmate questions and are
"baited" by the regulars.

gtoomey


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

Date: Wed, 11 Feb 2004 14:52:12 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: how to convert a string to an escaped string
Message-Id: <c0dc7d$15m6f7$1@ID-184292.news.uni-berlin.de>

Gregory Toomey wrote:
> Gunnar Hjalmarsson wrote:
>> Lowell Kirsh wrote:
>>> How about a perl function that can convert a string to another
>>> string in which special chars are represented as escaped 
>>> versions of themselves...
>> 
>> Yes, there is such a function.
>> 
>> perldoc -f quotemeta
>> 
>> Why didn't you just look it up instead of posting here?
> 
> Thats a stupid statement.
> 
> This group reeks of arrogance. People ask legitmate questions and
> are "baited" by the regulars.

First: My limited Perl knowledge doesn't qualify me to be called a
"regular".

Since OP wondered if there is a function in Perl that escapes special
characters, the natural first step should reasonably have been to look
in perldoc perlfunc. If he had done so, he would most likely have
found it.

Asking hundreds of people for help with looking up things in the
documentation is not a legitimate step, at least not when the answer
can be as easily found as in this case. Pointing out that is neither
stupid nor arrogant.

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



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

Date: Wed, 11 Feb 2004 11:27:31 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Launching an .exe
Message-Id: <n14k20hd9loinp5dpim2v1421ht8a72gbf@4ax.com>

lmm <> wrote:

>So I guess I need a way to launch the exe and then have the
>Perl script move forward.

Use Win32::Process, as Ben Morrow already said, or, if you don't mind a
window popping up shortly (not sure if it always happens), use the
"start" launching program with system():

	     system start => '"C:\\Program Files\\SonicWALL\\SonicWALL
Global VPN Client\\SWGVpnClient.exe"' ;     

The quotes in the argument string are necessary if  the path contains
spaces.

-- 
	Bart.


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

Date: Wed, 11 Feb 2004 13:58:26 GMT
From: XXjbhuntxx@white-star.com (Cosmic Cruizer)
Subject: Re: Perl script into a Windows Service
Message-Id: <Xns948C3CC549710ccruizermydejacom@64.164.98.50>

"Kevin Sproule" <kevinsproule@hotmail.com> wrote in
<D_uVb.25464$tP1.18372@fed1read07>: 

>
>Here are some generalized instructions that I use all the time to setup
>Perl scripts as services under Windows NT 4.0, 2000, XP, and 2003:
>
>Copy the INSTSRV.EXE and SRVANY.EXE files to C:\WINNT\SYSTEM32.
>
>Run: INSTSRV Service_Name C:\WINNT\SYSTEM32\SRVANY.EXE
>(This registers the service.)  Service_name
>
>Set the "Logon As" to Local System Account in the service properties.
>
>Run: REGEDIT
>Follow the chain:
> HKEY_LOCAL_MACHINE
>    SYSTEM
>       CurrentControlSet
>          Services
>             Service_Name
>
>Add the KEY: Parameters
>Select (highlight)  Parameters
>Add the String Value: Application
>   String: C:\PERL\bin\perl.exe     ( your path to the perl.exe program
>   ) 
>Add the String Value: AppParameters
>   String: C:\some_dir\perl_script.pl   ( your path to the perl script
>   to be 
>run )
>Exit the Registry Editor.
>Start the Service_Name service.
>
>In the event that you want to remove the Service_Name service, stop the
>service and run:
> INSTSRV Service_Name REMOVE
>
>I hope this helps.
>
>Kevin Sproule
>
>
>

WOW... Talk about easy. Thanks.


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

Date: Wed, 11 Feb 2004 06:57:55 -0500
From: Robert <bobx@linuxmail.org>
Subject: Re: Perl usage these days?
Message-Id: <VeadnVoyDoFehbfdRVn-vg@adelphia.com>

thumb_42@yahoo.com wrote:
<snip>
> It's kind of funny I went to one of suns java conventions. Got into
> conversations with people and sometimes when I'd say (somewhat shyly, this
> was a flipping java convention afterall) that my main project was in perl,
> the reaction was a hushed 'cool', I got the impression some of the
> developers there would actually perfer perl.
> 
> Jamie
> 
That is is the what my Java instructor said when he asked us if we did 
any programming. I said "Perl" and he said "Cool".


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

Date: Wed, 11 Feb 2004 07:01:24 -0500
From: Robert <bobx@linuxmail.org>
Subject: Re: Perl usage these days?
Message-Id: <w-ydnUDA5PwJhLfdRVn-uQ@adelphia.com>

thumb_42@yahoo.com wrote:

> Just a curious question:
> 
> What is perl being used for these days?
> 
> Seems almost everything web related I see is PHP or Java. (mostly PHP)
> 
> My own experience is that Perl is wonderful for batch processing, command
> line stuff, cron and specialized servers but compared to what is available
> today, really doesn't seem suitable for serious web applications anymore.
> 
> So... what are people doing with it? is it still alive? Do people actually
> get paid to work in perl, or is it strictly a labor of love?
> 
> (Yes, I know these are FAQ's, but times change, I'm curious about what
> people think these days)
> 
> Jamie
I am a newbie at Perl. I chose Perl because I didn't want to worry about 
enforced white space and the headaches that brings. I took it as a 
challenge to write clear code. Also Perl seems to have every library 
that I could ever use. I use it for my websites for admining my Windows 
and Linux boxes and just scripting in general. It is my "do all" 
language. If I need to do something outside the scope of Perl I turn to 
Java but that has been a rarity.

Take it from a newbie: "Perl is very cool"  : )


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

Date: Wed, 11 Feb 2004 12:30:23 GMT
From: "Ian Cass" <ian.cass@mblox.com>
Subject: Re: Perl usage these days?
Message-Id: <zfpWb.1914$JA3.17577178@news-text.cableinet.net>

thumb_42@yahoo.com wrote:
> Just a curious question:

> So... what are people doing with it? is it still alive? Do people
> actually get paid to work in perl, or is it strictly a labor of love?

I get paid to write Perl on Linux. I write SMS protocol drivers, servers &
parsers. I can write stuff in Perl in a fraction of the time that it takes
our Java team to get something written. The end result is always smaller,
tighter, faster and more efficient than the Java version.

---
Ian Cass




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

Date: Wed, 11 Feb 2004 13:29:56 +0100
From: Tore Aursand <tore@aursand.no>
Subject: RFC: utils.pm
Message-Id: <pan.2004.02.11.12.29.44.907197@aursand.no>

Hi!

Please excuse my English.  It's only my secondary language. :)

Over the time as a Perl programmer, I've gathered small bits of code here
and there.  The last few weeks I've tried to structure all this code and
put in a module which I - so far - call 'utils.pm'.  Thus, in my scripts,
I tend to begin like this:

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

The name could - of course - have been more propriate (if possible), but
to me 'utils' seems like a good one. :)

The main question is:  Although I know that the Perl core should stick to
a minimum, why isn't a module like this included?  It covers most of the
traps that newbies encounters, and it offers experienced programmers to be
even more lazy when programming.

Information about the module's functions:

  STRINGS
    ltrim( $value ) - Removes leading whitespace from a string.
    rtrim( $value ) - Removes trailing whitespace from a string.
    trim( $value ) - Combines ltrim() and rtrim().
    squish( $value ) - Removes (all the) whitespace from a string.
    split_csv( $value ) - Easy CSV splitting. (*)
    random_string( $length ) - Generates a random string $length
                               characters long.

  CASTING
    as_string( $value, [$default] ) - Always returns a defined value,
                                      optionally $default if $value
                                      isn't defined.
    as_int( $value ) - Always returns $value as an integer.
    as_decimal( $value, [$decimals] ) - Always returns $value as a
                                        decimal number with $decimals
                                        numbers after the decimal point.
    as_boolean( $value ) - Always returns $value as a boolena value (ie.
                           TRUE/1 or FALSE/0).
    as_date( $value ) - Always returns $value as a date (YYYY-MM-DD).
    as_time( $value ) - Always returns $value as a time (HH:MM:SS).
    as_datetime( $value ) - Always returns $value as a datetime (which
                            means combining as_date() and as_time()).

  VALIDATION
    Each of the CASTING functions also have a is_* function, which returns
    TRUE/1 or FALSE/0 depending on wether the input argument conforms to
    the datatype.

  NUMBERS
    round( $value ) - Rounds a number to the nearest integer.
    random_number( $min, $max ) - Returns a random number in the range
                                  $min to $max.
    format_number( $value, $separator ) - Formats a number with a given
                                          separator; 1234 becomes 1,234.

  ARRAYS
    unique( $arrayref ) - Returns only the unique elements in $array.
    intersection( $arrayref1, $arrayref2 ) - Computes the intersection
                                             of two array references.
    union( $arrayref1, $arrayref2 ) - Computes the union of two array
                                      references.
    shuffle( $arrayref ) - Returns the elements shuffled randomly.

  DATES
    now_year()
    now_month()
    now_day() - These three returns current the year, month and day.
    now_date() - Combines the three above.
    now_hour()
    now_minute()
    now_seconds() - These three returns the current hour, minute and
                    second.
    now_time() - Combines the three above.
    now() - Combines now_date() and now_time(); 'YYYY-MM-DD hh:mm:ss'.
    is_leap_year( $year ) - Returns TRUE/1 if $year is a leap year.
    day_of_week( $date ) - Returns the day of the week for $date.
    day_of_year( $date ) - Returns the day of the year for $date.
    days_in_month( $year, $month ) - Returns the number of days in the
                                     given year/month.
    days_in_year( $year ) - Returns 365 or 366 depending on wether the
                            year is a leap year or not.

(*) These methods could possibly generate warnings/info about standalone
    modules which one should preferrably use.

Well.  These are the majority of the functions I've gathered.  There are a
few more, but never mind them for now.  All the functions are written in
pure Perl, so no modules - of course - or "anything else" is required.

I find these functions very valuable when programming.  Whenever I need to
check if a date from the user is valid, I just:

  unless ( is_date($date) ) {
      # Error
  }

I could also combine them.  Let's say that the user has misunderstood the
"input the current date" question and also entered the current time;

  my $date = '2004-02-11 12:34:56'; # example input
     $date = as_date( $date ); # $date is now '2004-02-11'
  unless ( is_date($date) ) {
      # Error
  }

Stupid examples, but...

This is a RFC - Request For Comment - so I want to hear what you all
thing?  Should this be a "swiss army" module in the Perl core?  I think
so.

Just my 0.5 cents. :)


-- 
Tore Aursand <tore@aursand.no>
"Time only seems to matter when it's running out." -- Peter Strup


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

Date: 11 Feb 2004 14:02:48 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: RFC: utils.pm
Message-Id: <c0dcm8$29r$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Tore Aursand:

> Please excuse my English.  It's only my secondary language. :)
> 
> Over the time as a Perl programmer, I've gathered small bits of code here
> and there.  The last few weeks I've tried to structure all this code and
> put in a module which I - so far - call 'utils.pm'.  Thus, in my scripts,
> I tend to begin like this:
> 
>   #!/usr/bin/perl
>   #
>   use strict;
>   use warnings;
>   use utils;
> 
> The name could - of course - have been more propriate (if possible), but
> to me 'utils' seems like a good one. :)
> 
> The main question is:  Although I know that the Perl core should stick to
> a minimum, why isn't a module like this included?  It covers most of the
> traps that newbies encounters, and it offers experienced programmers to be
> even more lazy when programming.

I think it defeats a little bit the purpose of a Perl distribution as an
all-purpose means. Some of the functions you suggest would be totally
meaningless to me. Mostly the date-related functions. Within the past
three years I didn't have to deal with dates more than, say, three times
or so. I'd be slightly taken aback to find them in the Perl core while
at the same time not finding the functionality that I use on a daily
base and for which I had to write my own code/use a module (such as
playing back MP3s).

Also, I'd find the availability of such micro-functions in the core
offending. Maybe it's because I suffer more from hubris than others, but
I really like to reinvent these small wheels in my programs each time.
No matter how insignificant the task can be, there's always room for
slight variations in the eventual solution.

Not to forget that I think that these utility functions would have a bad
effect on beginners. I learnt a lot of my Perl because I had to ltrim
whitespaces myself. First I used a combination of 'substr' and 'index',
('rindex' for an rtrim). Then I learnt about regexpes. And so on.

The real reasons though for not including them is indeed the size
argument. A recent Perl distribution is really big and the amount of
code in it (that has to be maintained) scary.

Finally, this would make Perl look so PHPish. It hurts on the eyes. Perl
does not have something like a class library such as Ruby. Since in Ruby
everything is an object, you automatically have namespaces such as
String or so. That means that you don't have to add string-specific
functions into the CORE:: namespace and so you keep the amount of
pollution low.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Wed, 11 Feb 2004 17:15:57 +0530
From: Ajay <ajay_kumarsingh@yahoo.com>
Subject: Search and replace string
Message-Id: <402A15F5.1F20D07B@yahoo.com>

Hi All,
I've to search and replace the value of strings from a file.
The first string "giccip" can have multiple instances but i have to replace it's
value from the first instance only.
In the file "gicc" appear as follows, and it appears in the last of that line:

giccip=0x0a0600b0

The second string "STC1NSAP" has only one instance and i have to replace it's
value. It's on its own line

STC1NSAP=32.32.32.32.32.32.32.32.32.32.32.32.32.32.32.32.32.32.32.32

Here is my perl script
I'm on solaris

#!/usr/local/bin/perl -w 
###########################################################
## This script changes the giccip address 
## and STC1NSAP addresses in odd_persist file
###########################################################

#use warning;
#use strict;

my $FALSE = 0;
my $TRUE  = 1;
my $FOUND = $FALSE;
my $odd11dir = "odd11";
my $odd11file = "odd11/odd_persist";
my $slot11ip = "0x0a0600b0";
my $STC1NSAP12 = "32.32.32.32.32.32.32.32.32.32.32.32.32.32.32.32.32.32.32.32";

### check if the script is run from the correct directory
### check if odd_persist files exist in odd1 & odd12 dirs

if (! -e $odd11dir)
{
    die("directory $odd11dir not found \n");
}
if ( ! -e $odd11file )
{
    die("$odd11file file doesn't exist \n");
}

### open odd11/persist file and replace first giccip address with correct value
### and replace STC1NSAP Address
open(ODD11, $odd11file) || die("can't open $odd11file : $!\n");

@lines = <ODD11>;# Read it into an array
foreach $line (@lines)
{
    if ($line =~ /giccip/ && $FOUND == $FALSE )
    {
        #search for first giccip and replace it's value with new value
	##### how to replace ???
        $FOUND = $TRUE;
        print ($line);
    }
    if ($line =~ /STC1NSAP/)
    {
	# How to replace ??
        print ($line);
    }
}
if ( $FOUND == $FALSE )
{
    die("Can't find giccip");
}
close(ODD11);# Close the file


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

Date: Wed, 11 Feb 2004 12:55:18 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Search and replace string
Message-Id: <c0d5c5$159kbn$1@ID-184292.news.uni-berlin.de>

Ajay wrote:
> I've to search and replace the value of strings from a file.

http://www.perldoc.com/perl5.8.0/pod/perlop.html#s-PATTERN-REPLACEMENT-egimosx

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



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

Date: Wed, 11 Feb 2004 12:25:13 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Why is Perl losing ground?
Message-Id: <pan.2004.02.11.11.19.23.189524@aursand.no>

On Wed, 11 Feb 2004 08:45:59 +0000, Bart Lateur wrote:
>> I really don't understand this argument:  What do you actually mean
>> with "isolation between clients"?

> It means that if you mess things up in one client's setup, it'll affect
> everybody.

No, it doesn't.  mod_perl settings can be set differently for different
users.  It can be set differently for different directories/locations, and
it can be - of course - set differently for different virtual hosts.

This has, however, something to do with the Apache configuration, and has
nothing to do with Perl as a programming language.


-- 
Tore Aursand <tore@aursand.no>
"When you love someone, all your saved-up wishes start coming out." --
 Elizabeth Bowen


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

Date: Wed, 11 Feb 2004 12:22:35 GMT
From: thumb_42@yahoo.com
Subject: Re: Why is Perl losing ground?
Message-Id: <f8pWb.147089$U%5.670653@attbi_s03>

David Dyer-Bennet <dd-b@dd-b.net> wrote:
 
> mod_php is usable in a shard hosting environment.  mod_perl
> essentially is not; at least that seems to be the consensus of most of
> the places selling shared hosting, and reading about it, it does seem
> that you don't have adequate isolation between virtual users in
> mod_perl. 

I agree with you.

I think enough people have had issues with mod_perl to say that mod_perl is
a highly specific application of perl. I gave up on it years ago, maybe it's
improved since then, but when I used it I had many issues, one was
impossible to track down, (Berkely DBM causing the web server to
periodically segfault). Others involved memory leaks surrounding DBI..

Yes, maybe these problems were caused by something I did, or something
burried deep within some module some place that I was using, probably
nothing to do with mod_perl.. either way, those issues don't creep in with
PHP or java. (well, actually they do with java but those are mostly threading
issues that are relatively easy to avoid with care.)

Perl advocates can try and argue this is not the case, but it won't help.
Perl *is* loosing webspace ground to PHP in the webspace, that is reality as
we know it today. 


Jamie


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

Date: Wed, 11 Feb 2004 12:32:16 GMT
From: "Ian Cass" <ian.cass@mblox.com>
Subject: Re: Why is Perl losing ground?
Message-Id: <khpWb.1917$GR2.17019087@news-text.cableinet.net>

thumb_42@yahoo.com wrote:
> David Dyer-Bennet <dd-b@dd-b.net> wrote:

> Perl advocates can try and argue this is not the case, but it won't
> help. Perl *is* loosing webspace ground to PHP in the webspace, that
> is reality as we know it today.

Which is a *big* shame. I'd choose www.apache-asp.org over PHP any day of
the week.

--
Ian Cass




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

Date: Wed, 11 Feb 2004 12:22:21 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Why is Perl losing ground?
Message-Id: <fa8c45d770ab9f600581004e4a8ae6e7@news.teranews.com>

>>>>> "Ben" == Ben Morrow <usenet@morrow.me.uk> writes:

Ben> PHP is great for what it was designed for: a simple way to put a small
Ben> amount of scripting into a basically static HTML page. It's been
Ben> stretched *waay* beyond that now, though, and needs the same sort of
Ben> major rewrite/rethink that happened perl4->perl5. (FWIW I have heard
Ben> from friends who actually use the language :) that the PHP folks are
Ben> doing something along these lines now).

That would be consistent with my claim that PHP simply trails Perl
by five years in all manners of speaking, but badly.

Or, as I've said on more than one occasion:

        PHP - training wheels without the bicycle

Now that we have Apache::Template (and EmbPerl before that), there's
really no reason to learn PHP, except when that's the only choice you
have for other defining reasons.

print "Just another Perl hacker,"
-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 11 Feb 2004 13:16:15 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Why references??
Message-Id: <u965edoixs.fsf@wcl-l.bham.ac.uk>

"Ala Qumsieh" <xxala_qumsiehxx@xxyahooxx.com> writes:

> "Carlton Brown" <carltonbrown@hotmail.com> wrote in message
> news:aa611a32.0402101057.417e0a49@posting.google.com...
> 
> > It's also a convenient way to shortcut to lower branches of complex
> > structures.
> 
> > $bactrianus_ref =
> \%{$kingdom{animalia}{chordata}{mammalia}{artiodactylae}{camelidae}{camelus}
> {bactrianus}};
> 
> Why are you de-referencing your reference, and then referencing it again?

In order to autovivify and/or as an assertion that I'm expecting a hash.

> You don't need to do that.

Except when you do.  Doing so when you don't need to is rarely a
problem.  Not doing so when you do need to can produce many an obsure
bug.
 
>     $bactrianus_ref =
> $kingdom{animalia}{chordata}{mammalia}{artiodactylae}{camelidae}{camelus}{ba
> ctrianus};

That will set $bactrianus_ref to undef if there's no such bactrianus
in the camelus hash. Sometimes that _is_ what you want.  Often it is not.

> > Then you can quickly [...] set attributes:
> > $batctrian_ref->{hump_count} = 2;

If $batctrian_ref was undef this will create a new anonymous ref and
not attach it to the camelus hash.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 11 Feb 2004 13:37:37 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Why references??
Message-Id: <u91xp1ohy6.fsf@wcl-l.bham.ac.uk>

Ben Morrow <usenet@morrow.me.uk> writes:

> You haven't made the distinction in your mind between 'variables' and
> 'values'.

And the distinction you have made, while perfectly valid in isolation,
is not the same as the conventinal Perl nomenclature used in the
standards docs and by most people here.

> sub hash {
>     my %h = (a => 'b');
>     return \%h;
> }
> 
> my $h = hash;
> 
> then the *variable* %h is lexically scoped to the sub. It never gets
> out, as in there is nowhere else in the program where %h refers to the
> same data. The value, i.e. the hash (the HV), is refcounted like all
> Perl values.

The thing you call "value" is more conventinally called "variable" in Perl.

The thing you call "variable" is more conventinally called "variable
name" or "lexical binding" or "pad entry" (or in the case of package
variables "symbol table (stash) entry").  

The term "lexical variable" or "package variable" can be used to refer
to the composite concept of the variable and it's pad/stash entry.  

Many people use "global variable" as a synomym for "package variable"
but I diapprove of this because it leads people to draw false inferences.

> The distinction is an important dichotomy in Perl (indeed, in all
> compiled languages): variables are lexical, values dynamic; variables
> are created at compile-time, values at run-time. my acts on variables,
> local on values; this is the source of the differences between them.

It is important, as you say, to understand the disticution between
these entities.  It is also a good idea to use (in public) the same
nomenclature as other people (even if your nomenclature seems more
logical).

Oh, and by the way, pad entries are lexical, stash entries are not
lexical.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

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


Administrivia:

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

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

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

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

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


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


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