[22553] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4774 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 28 06:05:44 2003

Date: Fri, 28 Mar 2003 03:05:11 -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           Fri, 28 Mar 2003     Volume: 10 Number: 4774

Today's topics:
        Binary Distribution of Perl (soudamini sreepada)
    Re: CGI.pm or roll-your-own? <usenet@delete.orange-triangle.net>
    Re: CGI.pm or roll-your-own? <tassilo.parseval@rwth-aachen.de>
    Re: CGI.pm or roll-your-own? <kkeller-spammmm@wombat.san-francisco.ca.us>
    Re: how do you correctly accomplish $$var_name? <abigail@abigail.nl>
    Re: how do you correctly accomplish $$var_name? (Helgi Briem)
    Re: How to use class in one file? <tassilo.parseval@rwth-aachen.de>
    Re: How to use class in one file? (Anno Siegel)
    Re: How to use class in one file? <pengtaoli@hotmail.com>
        IO::FILE undedined (Ali)
    Re: IO::FILE undedined (Anno Siegel)
        multi-char pattern with other patterns <istink@real.bad.com>
        namespace with do "filename" <ericw@nospam.ku.edu>
        pattern matching xyz <istink@real.bad.com>
    Re: pattern matching xyz <me@verizon.invalid>
    Re: pattern matching xyz <uri@stemsystems.com>
    Re: pattern matching xyz <Jodyman@hotmail.com>
    Re: pattern matching (Philip Lees)
    Re: Perl and C++ (Helgi Briem)
        Perl modules. <phil.latio@f-in-stupid.co.uk>
    Re: Perl modules. <josef.moellers@fujitsu-siemens.com>
    Re: perl multi line substitution (Tad McClellan)
        Perl String Manipulation esantosa@student.bond.edu.au
    Re: Perl String Manipulation <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Perl String Manipulation <usenet@NOSPAM.matthewb.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 28 Mar 2003 03:04:46 -0800
From: mini@cse.iitb.ac.in (soudamini sreepada)
Subject: Binary Distribution of Perl
Message-Id: <c63c14b3.0303280304.756ac8a5@posting.google.com>

Hi,

We are installing Perl 6.5.1 Build 631 version on Suse Linux 7.0,
OS/390 box. The binary distribution for the above 
specification is not available. We built the source code and 
installed it. I will be glad if any one let me know if there is any
automated tool available to create a binary distribution out of it.

Thanks.


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

Date: Fri, 28 Mar 2003 06:16:43 GMT
From: Edwin Horneij <usenet@delete.orange-triangle.net>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <fNRga.238422$3D1.126800@sccrnsc01>

The reason beginners don't like to use CGI.pm is because, for a 
beginner, the documentation is incomprehensible.

Also, if the beginner is coming from a background in a specialized web 
scripting language like PHP, CGI support is built into the language. 
Someone like that thinks of external modules as something to use for 
highly specialized purposes, but thinks of CGI as core functionality.

I'm still a beginner, so trust me on this.

---
Ed Horneij



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

Date: 28 Mar 2003 06:39:50 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <b60qnm$dbh$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Edwin Horneij:

> The reason beginners don't like to use CGI.pm is because, for a 
> beginner, the documentation is incomprehensible.
> 
> Also, if the beginner is coming from a background in a specialized web 
> scripting language like PHP, CGI support is built into the language. 
> Someone like that thinks of external modules as something to use for 
> highly specialized purposes, but thinks of CGI as core functionality.

That's odd. They should quickly realize that it is not a feature in the
Perl-core but why do they deduce from this that hand-rolling a solution
is more adequate than using a module?

As a side note: One could argue that it is in fact a feature of the core
since CGI.pm is a standard module and therefore to be found in any not
too archaic Perl distribution.

I guess these poor PHP-chaps must be really confused when using a
language like C. Will they also try to program without including any
headers from the standard-libs because they would assume that printing a
character to the screen should be in the core? Also, how do they define
core? A lot of the Perl-core (strictures, warnings etc.) is in separate
modules just as 95% of the C core is only accessible through external
headers.

I really don't think that PHP's way of organizing should serve as a good
example and any good PHP programmer does well to quickly accept the
conventions of the language he uses. Otherwise he'll remain...err, a PHP
programmer.

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: Thu, 27 Mar 2003 23:35:18 -0800
From: Keith Keller <kkeller-spammmm@wombat.san-francisco.ca.us>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <mvt06b.d85.ln@goaway.wombat.san-francisco.ca.us>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

In article <fNRga.238422$3D1.126800@sccrnsc01>, Edwin Horneij wrote:
> The reason beginners don't like to use CGI.pm is because, for a 
> beginner, the documentation is incomprehensible.

When I was a beginner all those many years ago, and CGI.pm
first started replacing cgi-lib.pl, I was so incredibly happy
that there was finally a module with clear documentation and
an easy programming style.

Also, there are a great many number of web sites and dead-tree
books that supplement the primary documentation that comes with
CGI.pm.

> Also, if the beginner is coming from a background in a specialized web 
> scripting language like PHP, CGI support is built into the language. 
> Someone like that thinks of external modules as something to use for 
> highly specialized purposes, but thinks of CGI as core functionality.

Okay, so the PHP-to-Perl programmer has to learn something new.
What a concept!  The better-suited programmers will adjust to
the new style rather easily.

> I'm still a beginner, so trust me on this.

Well, as a no-longer-beginner, trust us when we say that rolling
your own CGI functionality is nontrivial.  Just because Perl does
it differently from PHP is no reason to roll your own Perl
implementation.  And if the documentation is too confusing for
a programmer to use CGI.pm, then certainly that programmer should
not be rolling his own CGI solution!

- --keith

- -- 
kkeller-mmmspam@wombat.san-francisco.ca.us
(try just my userid to email me)
public key:  http://wombat.san-francisco.ca.us/kkeller/kkeller.asc
alt.os.linux.slackware FAQ:  http://wombat.san-francisco.ca.us/cgi-bin/fom

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAj6D+y4ACgkQhVcNCxZ5ID8GvwCglHOq9Nr85OOQgrtmUSZgIlxD
u60AnjQ6MBeK0Q4Hj2kIqFPiuRey66dA
=C3g1
-----END PGP SIGNATURE-----


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

Date: 28 Mar 2003 08:06:07 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: how do you correctly accomplish $$var_name?
Message-Id: <slrnb880jf.lrb.abigail@alexandra.abigail.nl>

Hammy (ericschultz@wisc.edu) wrote on MMMCDXCVI September MCMXCIII in
<URL:news:9b2bc55c.0303272025.3c3e7ee7@posting.google.com>:
//  I remember doing this at one point but I've forgotten. I'm trying to
//  figure out how to accomplish $$var_name correctly. (in other words if
//  $var_name="name" then you'd get $name)I know if you do this, it can
//  cause problems and there's a better way to accomplish the same thing.
//  Thanks for any help you can provide.


    $foo = "bar";
    $bar = "xyzzy";
    print $$foo;
    __END__
    xyzzy


Abigail
-- 
use   lib sub {($\) = split /\./ => pop; print $"};
eval "use Just" || eval "use another" || eval "use Perl" || eval "use Hacker";


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

Date: Fri, 28 Mar 2003 10:23:24 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: how do you correctly accomplish $$var_name?
Message-Id: <3e8421d3.4228501673@news.cis.dfn.de>

On 27 Mar 2003 20:25:25 -0800, ericschultz@wisc.edu (Hammy)
wrote:

>I remember doing this at one point but I've forgotten. I'm trying to
>figure out how to accomplish $$var_name correctly. (in other words if
>$var_name="name" then you'd get $name)I know if you do this, it can
>cause problems and there's a better way to accomplish the same thing.
>Thanks for any help you can provide.

perldoc -q "How can I use a variable as a variable name?"

Use a hash instead.

my %hash;
my %hash{'name'} = 'value';
-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


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

Date: 28 Mar 2003 06:12:16 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: How to use class in one file?
Message-Id: <b60p40$cll$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Franklin Lee:

> I want to define one clase using package, then use it in the same file.
> Program prototype like below:
> **********************************************************************
> BEGIN{
> package mypackage;
> 
> BEGIN{

I don't think nested BEGIN blocks work. What should they achieve,
anyway?

> use Exporter;
> @ISA = { Exporter };

Now you assign a reference to an anonymous hash (with only a key) to the
first element of @ISA. That's not right either. Since you are working
with classes and objects, you probably wont need Exporter.

> 
> use strict;
> 
> #define variable
> 
> #define functions
> sub new;
> sub abc;

Forward declarations aren't of much use for methods. Drop them.

> }
> sub new{
> ...
> }
> sub abc{
> ...
> }
> 
> 1;
> }
> 
> #main
> package main;
> use mypackage;
> my $a=new mypackage;
> $a->abc;
> *********************************************************************
> Perl always tell me that no mypackage.pm can use. But I don't want to
> ceate one file mypackage.pm. I want to create some classes in one file
> and use them like C++.

It's much easier actually:

    package mypackage;

    sub new {
        my $class = shift;
        return bless { } => $class;
    }
    sub abc {
        my $self = shift;
        ...
    }

    package main;

    my $obj = mypackage->new;
    $obj->abc;

There is no need for use()ing mypackage (that only works for packages
that are to be found in a dedicated file) in the main-package since it's
all in one file. But make sure that the main package is always the last
portion so that the other packages have been set up properly before,
otherwise perl wont reckognize them.

> Who can tell me how to do it and the reason? And where can find refence?

I don't know where multiple packages in one file is described in the
perldocs. I can only find examples (for instance 'perldoc perlbot) that
make use of it but no explanations. Try 'perldoc perlmod'. Flicking
through it suggests that it could be in there.

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: 28 Mar 2003 09:49:20 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to use class in one file?
Message-Id: <b615r0$sfb$1@mamenchi.zrz.TU-Berlin.DE>

Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote in comp.lang.perl.misc:
> Also sprach Franklin Lee:
> 
> > I want to define one clase using package, then use it in the same file.
> > Program prototype like below:
> > **********************************************************************
> > BEGIN{
> > package mypackage;
> > 
> > BEGIN{
> 
> I don't think nested BEGIN blocks work. What should they achieve,
> anyway?

They do work.  The inner BEGIN executes when the outer one is compiled,
then the outer one executes, so

    BEGIN {
        print "1\n";
        BEGIN {
            print "2\n";
        }
    }

first prints "2", then "1".  I haven't seen a situation where explicit
nesting of BEGIN makes sense, but it happens implicitly all the time
when a module is used that contains a BEGIN block.

[snip analysis and solution]

Anno


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

Date: Fri, 28 Mar 2003 17:39:37 +0800
From: "Franklin Lee" <pengtaoli@hotmail.com>
Subject: Re: How to use class in one file?
Message-Id: <b61591$nkh@netnews.proxy.lucent.com>

Thank you, Parseval.

It works well!

Franklin




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

Date: 28 Mar 2003 02:27:39 -0800
From: hazal@web.de (Ali)
Subject: IO::FILE undedined
Message-Id: <11bdd8f.0303280227.712a47a9@posting.google.com>

Hallo,

ich habe in einem Script folgende Code unter anderem:


39 my $out = IO::File->new(">$output");
40 foreach $_ (@help_arr1) {
41 print $out $help_arr1[$i]."\t".$help_arr3[$i];
42 $i++;
43 }
44 $out->close;

wenn ich meine script auf meinen Rechner ausführe funktioniert der
Script(Auf dem installiert: ActiveState 5.8.0 Build 804). Auf einem
anderen(Installiert ActiveState 5.6) fuktioniert der Script leider
nicht. Habe folgende Fehler.

Can't use an undefined value as a symbol reference at "script.pl" line
41.

Ist die Ursache wirklich die Version Unterschied, oder mache ich was
anderes falsch?

Gruss
Hazal


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

Date: 28 Mar 2003 10:46:22 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: IO::FILE undedined
Message-Id: <b6195u$4vj$1@mamenchi.zrz.TU-Berlin.DE>

Ali <hazal@web.de> wrote in comp.lang.perl.misc:
> Hallo,
> 
> ich habe in einem Script folgende Code unter anderem:
> 
> 
> 39 my $out = IO::File->new(">$output");

You should always check the result of a file open.

    my $out = IO::File->new(">$output") or die "Can't create output: $!";

> 40 foreach $_ (@help_arr1) {
> 41 print $out $help_arr1[$i]."\t".$help_arr3[$i];
> 42 $i++;
> 43 }
> 44 $out->close;
> 
> wenn ich meine script auf meinen Rechner ausführe funktioniert der
> Script(Auf dem installiert: ActiveState 5.8.0 Build 804). Auf einem
> anderen(Installiert ActiveState 5.6) fuktioniert der Script leider
> nicht. Habe folgende Fehler.
> 
> Can't use an undefined value as a symbol reference at "script.pl" line
> 41.

Looks like IO::File->new failed to deliver an object, for whatever
reason.

> Ist die Ursache wirklich die Version Unterschied, oder mache ich was
> anderes falsch?

IO::File was only delivered with 5.8.0.  It should work with earlier
versions (> 5.006_001) if you install it.

Anno


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

Date: Fri, 28 Mar 2003 01:12:03 -0500
From: istink <istink@real.bad.com>
Subject: multi-char pattern with other patterns
Message-Id: <3E83E7B3.7DABD1B4@real.bad.com>

I want to do this:
"hello - world" ==> "hello-world"
"hello                  -      world" ==> "hello-world"
"hello - world_good-bye world save ^%^&^&^me" ==>
"hello-world_good-bye_world_save_me"


with one line of code.

here's what I have:

foreach $line (@ARGV) {
    if ($line =~ / /){
        $orig=$line;
        ($mod=$line) =~ s/ /_/g; #space to underscore
        $mod =~ s|[^_ -[:alnum:]]||g;
        $mod =~ s|_-_|-|g;

        print "$orig ==> $mod\n";
    }
}


that's a mouth full.


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

Date: Fri, 28 Mar 2003 07:00:16 GMT
From: Eric Wilhelm <ericw@nospam.ku.edu>
Subject: namespace with do "filename"
Message-Id: <pan.2003.03.28.00.00.16.503494.1661@nospam.ku.edu>

I have a while loop which loads a data structure.  It has gotten somewhat
long due to the conditionals and minor operations which have been added,
but it needs to be used in several programs (single-purpose prototypish
scripts).

I would like to keep it in one place for maintenance, consistency, etc.
But it doesn't seem like it would lend itself to being a module.  All of
the variables being read and loaded are global, so I thought I could just
save it to a file like /usr/local/bin/dataloader.pl and call it into the main
scripts with do like so:

# setup per-script items here ($filename="such and such")

# the while loop used to be here
do "/usr/local/bin/dataloader.pl"

# continue

This works fine, but I'm wondering if it is going to lead me into trouble
later.  Comments?

Thanks,
Eric


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

Date: Fri, 28 Mar 2003 00:06:32 -0500
From: istink <istink@real.bad.com>
Subject: pattern matching xyz
Message-Id: <3E83D858.BA3D9BA7@real.bad.com>

I'm learning pattern matching.
Is there a better way to do this. say I want to convert spaces to
underscore.
As you can see there's probably too many = assigments. Is there a more
lazy way to do this?

$orig="hello world"; <== say this is comming from somewhere and I dont
want to mess it up.

$this=$orig;
$this=~s/ /_/g;

how would I put those two lines together?


-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----


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

Date: Fri, 28 Mar 2003 05:32:46 GMT
From: "dw" <me@verizon.invalid>
Subject: Re: pattern matching xyz
Message-Id: <28Rga.25276$SX.24010@nwrdny03.gnilink.net>


"istink" <istink@real.bad.com> wrote in message
news:3E83D858.BA3D9BA7@real.bad.com...
> $orig="hello world"; <== say this is comming from somewhere and I dont
> want to mess it up.
>
> $this=$orig;
> $this=~s/ /_/g;
>
> how would I put those two lines together?
>

($this = $orig) =~ s/ /_/g;






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

Date: Fri, 28 Mar 2003 05:34:01 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: pattern matching xyz
Message-Id: <x7d6kc5a2e.fsf@mail.sysarch.com>

>>>>> "i" == istink  <istink@real.bad.com> writes:

  i> I'm learning pattern matching.

first, try learning how to not post multiple times.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 28 Mar 2003 05:51:51 GMT
From: "Jodyman" <Jodyman@hotmail.com>
Subject: Re: pattern matching xyz
Message-Id: <XpRga.23170$jA2.2071803@newsread2.prod.itd.earthlink.net>


"istink" <istink@real.bad.com> wrote in message
news:3E83D858.BA3D9BA7@real.bad.com...
> I'm learning pattern matching.
> Is there a better way to do this. say I want to convert spaces to
> underscore.
> As you can see there's probably too many = assigments. Is there a more
> lazy way to do this?
>
> $orig="hello world"; <== say this is comming from somewhere and I dont
> want to mess it up.
>
> $this=$orig;
> $this=~s/ /_/g;
>
> how would I put those two lines together?

#!c:\perl\bin\perl
use strict;
use warnings;
use diagnostics;

my $original = "hello out there big world";
my $converted;

($converted = $original) =~ tr/ /_/;
#or
#($converted = $original) =~ s/ /_/g;
#or
#($converted = $original) =~ y/ /_/;

print "Original: $original\n";
print "Converted: $converted\n";






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

Date: Fri, 28 Mar 2003 09:31:25 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: pattern matching
Message-Id: <3e841628.70094203@news.grnet.gr>

On Thu, 27 Mar 2003 23:58:21 -0500, istink <istink@real.bad.com>
wrote:

>I'm learning pattern matching.
>Is there a better way to do this. say I want to convert spaces to
>underscore.
>As you can see there's probably too many = assigments. Is there a more
>lazy way to do this?
>
>$orig="hello world"; <== say this is comming from somewhere and I dont
>want to mess it up.
>
>$this=$orig;
>$this=~s/ /_/g;
>
>how would I put those two lines together?

( $this=$orig ) =~s/ /_/g;

Phil
-- 
Ignore coming events if you wish to send me e-mail


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

Date: Fri, 28 Mar 2003 09:59:44 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Perl and C++
Message-Id: <3e841cef.4227249343@news.cis.dfn.de>

On Thu, 27 Mar 2003 22:10:25 -0500, Benjamin Goldberg
<goldbb2@earthlink.net> wrote:

>Joe Creaney wrote:
>> No Just wanted to make a comment.  I realy don't think 
>> there is a way to use C++ object syntax in perl.
>
>You could write a source filter.

He could try winkling his frobnitzer.
-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


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

Date: Fri, 28 Mar 2003 10:13:16 GMT
From: "Phil Latio" <phil.latio@f-in-stupid.co.uk>
Subject: Perl modules.
Message-Id: <0fVga.4230146$zx5.637712@news.easynews.com>

I am reading a page from CGI Programming with Perl, Second Edition By
Gunther Birznieks, Scott Guelich, Shishir Gundavaram.

It has the code for two files:
UserTracker.pm
query_track.cgi

Where do you put the UserTracker.pm? I've read elsewhere that you are
suppose to install Perl modules using command line (make, etc) but that
doesn't seem right. How could I then distribute this program to anyone who
doesn't have shell access?

This is probably pretty basic stuff though not sure if this is a technically
a Perl or CGI question. I'll stick it here and have the fire extinguisher
ready.

Cheers

Phil







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

Date: Fri, 28 Mar 2003 11:30:32 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: Perl modules.
Message-Id: <3E842448.3D991C42@fujitsu-siemens.com>

Phil Latio wrote:
> =

> I am reading a page from CGI Programming with Perl, Second Edition By
> Gunther Birznieks, Scott Guelich, Shishir Gundavaram.
> =

> It has the code for two files:
> UserTracker.pm
> query_track.cgi
> =

> Where do you put the UserTracker.pm?

In any directory included in the @INC array.

> I've read elsewhere that you are
> suppose to install Perl modules using command line (make, etc) but that=

> doesn't seem right.

Indeed, you would use make etc if you need to construct the module
before installing it (although, strictly speaking, you could also
install it with a Makefile).

> How could I then distribute this program to anyone who
> doesn't have shell access?

How do you distribute the cgi script to anyone who does not have a shell
account.

TMTOWTDI:
1. install the .pm in the same directory as the .cgi and append "." to
@INC, if it's not already there.
2. request installation of the .pm in whatever directory the web hoster
provides for this purpose.
3. include the .pm in the .cgi itself: replace the line "use
UserTracker;" with the contents of Usertracker.pm.

Josef
-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: Thu, 27 Mar 2003 22:28:24 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: perl multi line substitution
Message-Id: <slrnb87jr8.1uq.tadmc@magna.augustmail.com>


[ Please do not top-post ]


boxsource <chris@thecyberpunk.com> wrote:
> Benjamin Goldberg wrote:

>> Perldoc perlrun
>> describes the -0 option,

>>    perl -00 -p -e "s/<tr[^>]*>\n\t*<\/tr>/I FOUND IT/g" test.txt

> Thanks a lot it works great. I didn't realize that that was how perl 
> handled input data


Then you must have been using the -p switch without having read
the documentation for what the -p switch does?



There's a larger lesson to be learned here than what switches
do what...


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


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

Date: 27 Mar 2003 23:27:18 -0800
From: esantosa@student.bond.edu.au
Subject: Perl String Manipulation
Message-Id: <894a4768.0303272327.5d874173@posting.google.com>

I have already defined this in Perl

my $text = "erica";
my $var = "\$text";

Now, I want to be able to print $var and process $text interpolate
string at the same time, therefore the output that I expect from

print "$var" -> is "erica";

But currently the output for print "$var" -> is "$text";

Any suggestion??

Erica.


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

Date: Fri, 28 Mar 2003 07:40:01 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Perl String Manipulation
Message-Id: <Xns934C574F191F3elhber1lidotechnet@62.89.127.66>

esantosa@student.bond.edu.au wrote:


> I have already defined this in Perl
> 
> my $text = "erica";
> my $var = "\$text";
> 
> Now, I want to be able to print $var and process $text interpolate
> string at the same time, therefore the output that I expect from
> 
> print "$var" -> is "erica";
> 
> But currently the output for print "$var" -> is "$text";
> 
> Any suggestion??


One suggestion is - don't do that! :-)


Why not use $var as a key in a hash?


my %hash;
$hash{$var} = $text;


And now all you have to do is print $hash{$var} instead of just $var.


For more on this topic check these out:


http://perl.plover.com/varvarname.html
http://perl.plover.com/varvarname2.html
http://perl.plover.com/varvarname3.html


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: Fri, 28 Mar 2003 08:51:03 +0000
From: Matthew Browning <usenet@NOSPAM.matthewb.org>
Subject: Re: Perl String Manipulation
Message-Id: <pan.2003.03.28.08.51.02.401669.453@NOSPAM.matthewb.org>

On Fri, 28 Mar 2003 07:27:18 +0000, esantosa wrote:

> I have already defined this in Perl
> 
> my $text = "erica";
> my $var = "\$text";
> 
> Now, I want to be able to print $var and process $text interpolate
> string at the same time, therefore the output that I expect from
> 
> print "$var" -> is "erica";
> 
> But currently the output for print "$var" -> is "$text";
> 
> Any suggestion??
> 

Your choices are two:

1. Omit the slash from your assignment to $var which, in this context,
escapes the interpolation.

2. If you are trying to take a reference, put the slash before the quotes
and dereference it to print, thus

my $text = "erica";
my $var = \"name is $text";

print "$$var";


[MB]


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

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


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