[19910] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2105 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 9 18:10:46 2001

Date: Fri, 9 Nov 2001 15:10:16 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1005347416-v10-i2105@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 9 Nov 2001     Volume: 10 Number: 2105

Today's topics:
        Issues when developing on windows systems and running o <no_spam.yet_another_apprentice@hotmail.com>
    Re: Issues when developing on windows systems and runni <no@email.com>
    Re: Issues when developing on windows systems and runni (John J. Trammell)
    Re: Issues when developing on windows systems and runni <no_spam.yet_another_apprentice@hotmail.com>
    Re: Issues when developing on windows systems and runni (John J. Trammell)
    Re: Issues when developing on windows systems and runni <no_spam.yet_another_apprentice@hotmail.com>
    Re: Need Some Help <mbudash@sonic.net>
    Re: Need Some Help <jeff@vpservices.com>
    Re: Need Some Help <jeff@vpservices.com>
    Re: nested foreach - how to speed up or optimize ? <gregory@pharmag.pl>
        Perl or Php user group /club in Toronto, Canada (Eniac)
    Re: Perl or Php user group /club in Toronto, Canada <uri@stemsystems.com>
    Re: Perl or Php user group /club in Toronto, Canada <comdog@panix.com>
        Perl vs. Active Perl bjohnsto@whiledefined.net
    Re: Perl vs. Active Perl (Malcolm Dew-Jones)
    Re: quick question about real-time display of print out (Carl)
    Re: repeated string (Houda Araj)
    Re: Return from subroutine behaving unexpectedly nobull@mail.com
    Re: Shift Operators - newbie <krahnj@acm.org>
        Substitutions (Anya Miretsky)
    Re: Substitutions <mbudash@sonic.net>
    Re: Substitutions <Laocoon@eudoramail.com>
    Re: Substitutions (Tad McClellan)
    Re: Trying to call a Perl script from Perl (Richard J. Rauenzahn)
    Re: VVP: Variable = system command <wwonko@rdwarf.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 9 Nov 2001 22:15:57 +0100
From: "Bob Rock" <no_spam.yet_another_apprentice@hotmail.com>
Subject: Issues when developing on windows systems and running on linux boxes????
Message-Id: <9shhfl$13k3p8$1@ID-98646.news.dfncis.de>

Hello,
I'm new to perl and was wondering if developing on win32 systems and then
running code on linux systems can cause certain issues to arise. I was
thinking specifically to newlines where on win32 systems they are composed
of two characters (a carriage return and a newline) while on linux machines
they are just made up by a single newline character. Thank you.


Regards,
Bob Rock







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

Date: Fri, 9 Nov 2001 21:41:33 -0000
From: "Brian Wakem" <no@email.com>
Subject: Re: Issues when developing on windows systems and running on linux boxes????
Message-Id: <j4YG7.4165$qf.815932@news2-win.server.ntlworld.com>


"Bob Rock" <no_spam.yet_another_apprentice@hotmail.com> wrote in message
news:9shhfl$13k3p8$1@ID-98646.news.dfncis.de...
> Hello,
> I'm new to perl and was wondering if developing on win32 systems and then
> running code on linux systems can cause certain issues to arise. I was
> thinking specifically to newlines where on win32 systems they are composed
> of two characters (a carriage return and a newline) while on linux
machines
> they are just made up by a single newline character. Thank you.
>
>
> Regards,
> Bob Rock

No problems really.  I develop and test all of my scripts (for a large
commercial website) on WinME and then run them on a Linux webserver.  I've
never had any problems.

--
Brian




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

Date: Fri, 9 Nov 2001 15:46:56 -0600
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: Issues when developing on windows systems and running on linux boxes????
Message-Id: <slrn9uojnu.n7r.trammell@haqq.el-swifto.com>

On Fri, 9 Nov 2001 22:15:57 +0100, Bob Rock wrote:
> Hello,
> I'm new to perl and was wondering if developing on win32 systems and then
> running code on linux systems can cause certain issues to arise. I was
> thinking specifically to newlines where on win32 systems they are composed
> of two characters (a carriage return and a newline) while on linux machines
> they are just made up by a single newline character. Thank you.
> 
Yes, that situation can cause problems, if people are careless.

-- 
[M]en become civilized, not in proportion to their willingness to believe,
but in proportion to their willingness to doubt.            - H.L. Mencken


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

Date: Fri, 9 Nov 2001 23:10:30 +0100
From: "Bob Rock" <no_spam.yet_another_apprentice@hotmail.com>
Subject: Re: Issues when developing on windows systems and running on linux boxes????
Message-Id: <9shkm6$1412q2$1@ID-98646.news.dfncis.de>

>
> Yes, that situation can cause problems, if people are careless.
>

And what can be done? Is there a text editor for win32 systems to convert
"win32" newlines (carriage return + newline characters) in "linux" newlines
(only a newline character)? Thank you.


Regards,
Bob Rock




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

Date: Fri, 9 Nov 2001 16:38:53 -0600
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: Issues when developing on windows systems and running on linux boxes????
Message-Id: <slrn9uompb.nqr.trammell@haqq.el-swifto.com>

On Fri, 9 Nov 2001 23:10:30 +0100, Bob Rock wrote:
> >
> > Yes, that situation can cause problems, if people are careless.
> >
> 
> And what can be done? Is there a text editor for win32 systems to convert
> "win32" newlines (carriage return + newline characters) in "linux" newlines
> (only a newline character)? Thank you.
> 
I don't know what Win32 offers, but I've been able to clean up scripts
on *nix with something like:

 perl -pi -e 's(\r)()' foo.pl

In particular I've seen POD get confused ("=cut" and "=cut\r") and
shebang options get toasted.

-- 
Power corrupts, but intermittent power corrupts absolutely.
                              - Jeff Bell, in the Monastery


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

Date: Fri, 9 Nov 2001 23:47:07 +0100
From: "Bob Rock" <no_spam.yet_another_apprentice@hotmail.com>
Subject: Re: Issues when developing on windows systems and running on linux boxes????
Message-Id: <9shmqj$138clu$1@ID-98646.news.dfncis.de>

> >
> > And what can be done? Is there a text editor for win32 systems to
convert
> > "win32" newlines (carriage return + newline characters) in "linux"
newlines
> > (only a newline character)? Thank you.
> >

Found. UltraEdit-32 does the job. Thx.


Regards,
Bob Rock






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

Date: Fri, 09 Nov 2001 20:12:13 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Need Some Help
Message-Id: <mbudash-40E57C.12121909112001@news.sonic.net>

In article <9sg7o4$36e$1@slb7.atl.mindspring.net>, "Sophie Anderson" 
<saUSAFirst@yahoo.com> wrote:

> db1.txt has fields:
> bNumber bName bPhone
> 
> db2.txt has fields:
> bNumber ISBN returnDate
> 
> db3.txt has fields:
> ISBN Author Title Publisher Cost Year
> 
> I need to read all files so that when I type "Enter the borrower
> number: " all fields from all 3 fields are displayed.
> I could do this pretty easily in C/C++ but my boss want it in Perl
> claiming that Perl can handle files better.
> At www.perl.com I learned how to open/close files, put each line
> (record) into arrays, split the line into fields, etc. Also Perl uses
> regular expression to match field/record.
> 
> My questions:
> How do read 3 files together?
 
(i hope jeff zucker is reading this)
 
i was going to recommend using jeff's DBD::AnyData, so i thought i'd 
better put some code together to test before i put it out there. 
however...
 
i cannot seem to get it to "work" for me. (don't worry, i'll explain 
"doesn't work" below.) here's the code:
 
#!/usr/bin/perl

use DBI;
use DBD::AnyData;
use strict;

my $dbh = DBI->connect('dbi:AnyData(RaiseError=>1):');

$dbh->func('borrowers', 'Tab', 'borrowers', 'ad_catalog');
$dbh->func('lends', 'Tab', 'lends', 'ad_catalog');
$dbh->func('ISBNs', 'Tab', 'ISBNs', 'ad_catalog');

my $sth = $dbh->prepare(q{
    SELECT b.bNumber, bName, bPhone, l.ISBN, title, author, returnDate
      FROM lends l, borrowers b, ISBNs i
     WHERE l.bNumber=b.bNumber and i.ISBN=l.ISBN
    });

$sth->execute();

while (my $row = $sth->fetchrow_arrayref) {
        #my @row = @$row;
        my $therow = join "\t", @$row[0..$#$row];
        print "$therow\n";
}

when running this code i get the following error:

DBD::AnyData::db prepare failed: Parse error near .bNumber, bName, 
bPhone, l.ISBN, title, author, returnDate FROM lends l, borrowers b, 
ISBNs i WHERE l.bNumber=b.bNumber and i.ISBN=l.ISBN at 
/usr/lib/perl5/site_perl/5.6.0/DBD/AnyData.pm line 126.

seems like it don't-a like-a thee [standard?] sql aliasing syntax i'm 
using...

what am i missing? or does this module (or perhaps SQL::Statement) not 
support sql aliasing?

tia-
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Fri, 09 Nov 2001 14:28:20 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Need Some Help
Message-Id: <3BEC5884.5147CD48@vpservices.com>

[posted and mailed]

Michael Budash wrote:
> 
> In article <9sg7o4$36e$1@slb7.atl.mindspring.net>, "Sophie Anderson"
> <saUSAFirst@yahoo.com> wrote:
> 
> > I need to read all files so that when I type "Enter the borrower
> > number: " all fields from all 3 fields are displayed.
> 
> (i hope jeff zucker is reading this)

I wasn't (because "Need Some Help" didn't catch my eye as a database
problem :-), but thanks for the email pointer.

> DBD::AnyData::db prepare failed: Parse error near .bNumber, bName,
> bPhone, l.ISBN, title, author, returnDate FROM lends l, borrowers b,
> ISBNs i WHERE l.bNumber=b.bNumber and i.ISBN=l.ISBN at
> /usr/lib/perl5/site_perl/5.6.0/DBD/AnyData.pm line 126.
> 
> what am i missing? or does this module (or perhaps SQL::Statement) not
> support sql aliasing?

The current SQL::Statement doesn't support either aliasing or
multi-table joins.  The new SQL::Statement (I should have it out in the
next few weeks) does support mutlti-table joins.  In the meantime, the
non-SQL AnyData.pm is the easiest way to do it.  The script below uses
data from the DATA section of the script itself but data from files (in
almost any format) could also be used just by changing the one line
where @db is defined):

#!/usr/local/binperl -w
use strict;
use AnyData;
my @db = split /\n\n/, join('',<DATA>);
my @table = map { adTie( 'CSV', [$_] ) } @db;
while (my $row0 = each %{$table[0]}) {
    my $row1 = $table[1]->{ $row0->{bNumber} };
    my $row2 = $table[2]->{ $row1->{ISBN}    };
    print join( ', ', (
        $row0->{bNumber}, $row0->{bName}, $row0->{bPhone},
        $row1->{ISBN}, $row1->{returnDate},
        $row2->{Author}, $row2->{Title}, $row2->{Publisher},
        $row2->{Cost}, $row2->{Year},
    )),"\n";
}
__DATA__
bNumber,bName,bPhone
1,Hamlet,666-6666

bNumber,ISBN,returnDate
1,000-000,2001-11-09

ISBN,Author,Title,Publisher,Cost,Year
000-000,Shakespeare,Hamlet,McGraw,$12,1608

Note that the joins literally use the foreign key as the *key* to the
tied hash for the joined table.  Also note that if this was coming from
files rather than the DATA section, none of the three tables would be
slurped into memory -- only a row at a time for the first table and only
the relevant rows (one row at a time) from the joined tables.  Also note
that this script assumes a one-to-one relationship between the tables
but slight adjustments would allow it to do many-to-many or other kinds
of relationships as well.  The script is a little longer than it needs
to be for clarity :-).

-- 
Jeff



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

Date: Fri, 09 Nov 2001 14:41:27 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Need Some Help
Message-Id: <3BEC5B97.4942A27E@vpservices.com>

Jeff Zucker wrote:
> 
> #!/usr/local/binperl -w

Obviously, that's missing a slash.  I *did* cut and paste after testing,
but since I was testing with cperl mode in emacs, it didn't care what
path to perl was on the shebang :-).

--
Jeff



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

Date: Fri, 9 Nov 2001 20:12:47 +0100
From: "Grzegorz Goryszewski" <gregory@pharmag.pl>
Subject: Re: nested foreach - how to speed up or optimize ?
Message-Id: <9shklt$9oi$1@news.tpi.pl>

DQoiSm9lIFNjaGFlZmVyIiA8am9lK3VzZW5ldEBzdW5zdGFyc3lzLmNvbT4gd3JvdGUgaW4gbWVz
c2FnZSBuZXdzOm0zcHU2cm44dXEuZnNmQG11bW9ua2FuLnN1bnN0YXJzeXMuY29tLi4uDQo+IERp
ZCB5b3UgKnRyeSogQW5ubydzIHN1Z2dlc3Rpb24/ICBZb3UgaGF2ZSB0aHJlZSBoYXNoZXMgd2l0
aA0KPiB0d28gY29uZGl0aW9uczoNCj4gDQo+ICAgJXpha29uY3ogJ3Mga2V5IGlzICVyb3Nwb2N6
ICdzIGtleQ0KPiAgICV1c2VyICAgICdzIGtleSBpcyAlemFrb25jeiAncyB2YWx1ZS0+WzJdDQo+
IA0KPiBUaGF0IGxvb2tzIGxpa2UgYSBzaW5nbGUgbG9vcCBvdmVyICdrZXlzICVyb3pwb2N6JyB0
byBtZSAodW50ZXN0ZWQpOg0KDQpUaGFua3MgZm9yIHN1Z2dlc3Rpb25zLCBidXQgdGhlIHByb2Js
ZW0gaXMgdGhhdCBJIGhhdmUgdG8gbWF0Y2ggb25seSB0aGUgc2FtZSBrZXkgdmFsdWVzIGZyb20g
JXpha29uY3ogYW5kICVyb3pwb2N6IGluc3RlYWQgb2YNCmV2ZXJ5LiBTbyBpbiAlemFrb25jeiBt
YXkgYmUgbW9yZSBrZXlzIHRoYW4gaW4gJXJvenBvY3ouICBNeSBwb2ludCBpcyB0byBkbyBzb21l
dGhpbmcgbGlrZSBpbm5lciBqb2luIGluIHNxbCB0ZXJtIG9uIGtleXMgdmFsdWVzLg0KVGhlIHNv
bHV0aW9uIEkndmUgcHJvdmlkZWQgd29ya3MgZmluZSBmb3IgbWUgOikuIFJlZ2FyZHMuDQoNCg0K
ICAgIEdyemVnb3J6IEdvcnlzemV3c2tpDQoNCg0KDQo=



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

Date: 9 Nov 2001 11:09:52 -0800
From: eniacjia@yahoo.com (Eniac)
Subject: Perl or Php user group /club in Toronto, Canada
Message-Id: <39387153.0111091109.212e92f@posting.google.com>

Hello All:

Who can tell me if there are any user group or club about Perl/Php in
Tronto area in Canada. I wish I can join such clubs to exchange idear
and share knowledges.

Thank you in advance


Eniac


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

Date: Fri, 09 Nov 2001 19:17:16 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Perl or Php user group /club in Toronto, Canada
Message-Id: <x7y9lfrbws.fsf@home.sysarch.com>

>>>>> "E" == Eniac  <eniacjia@yahoo.com> writes:

  E> Who can tell me if there are any user group or club about Perl/Php in
  E> Tronto area in Canada. I wish I can join such clubs to exchange idear
  E> and share knowledges.

join the toronto perl mongers:

	http://www.willcam.com/tpm/

	Perl@canada.com

go to pm.org for other perl monger groups worldwide.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 09 Nov 2001 15:10:14 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: Perl or Php user group /club in Toronto, Canada
Message-Id: <comdog-52E6D9.15101409112001@news.panix.com>

In article <39387153.0111091109.212e92f@posting.google.com>, 
eniacjia@yahoo.com (Eniac) wrote:

> Who can tell me if there are any user group or club about Perl/Php in
> Tronto area in Canada. I wish I can join such clubs to exchange idear
> and share knowledges.

   in this case, http://toronto.pm.org/

    for anyone else, you can start at http://www.pm.org

-- 
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html



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

Date: 9 Nov 2001 21:38:50 GMT
From: bjohnsto@whiledefined.net
Subject: Perl vs. Active Perl
Message-Id: <9shida$au0$1@news.xmission.com>

I was wondering what the difference if there is any between these two.  
Reason I ask is I would like to be able to monitor/admin some of my more
mundane functions from a linux workstation, like account creation across
multiple platorms for one. I was looking at the libwin32 modules but it 
states that it needs Active Perl.  They have the packages I need, but 
wanted to know the difference between the two before I rip out my current 
version and install another one.  Also, am I correct in thinking that 
these modules will not run on a linux system but have to be run from 
a windows box?  Thanks for the help folks.

Brett

-- 
If today were half as good as tomorrow is supposed to be, it would
probably be twice as good as yesterday was.
			-- Norman Augustine


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

Date: 9 Nov 2001 14:49:35 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Perl vs. Active Perl
Message-Id: <3bec5d7f@news.victoria.tc.ca>

bjohnsto@whiledefined.net wrote:
: I was wondering what the difference if there is any between these two.  
: Reason I ask is I would like to be able to monitor/admin some of my more
: mundane functions from a linux workstation, like account creation across
: multiple platorms for one. I was looking at the libwin32 modules but it 
: states that it needs Active Perl.  They have the packages I need, but 
: wanted to know the difference between the two before I rip out my current 
: version and install another one.  Also, am I correct in thinking that 
: these modules will not run on a linux system but have to be run from 
: a windows box?  Thanks for the help folks.


By "Active Perl" you probably mean "ActiveState Perl"  which is just the
version of perl that runs on windows.  It is provided by ActiveState (a
company).  It is exactly the same as any other perl, except that they have
to make various small changes to get the unix version to compile and run
on windows.

As for libwin32, I would guess that it only runs on windows because it
provides access to the windows operating system (which needs windows eh?).

The bottom line is that if you wish to use the functions in libwin32 you
probably need to run perl on a windows PC (which is normally done by
installing the perl distribution provided by ActiveState). 



--
Want to access the command line of your CGI account?  Need to debug your
installed CGI scripts?  Transfer and edit files right from your browser? 

What you need is "ispy.cgi" - visit http://nisoftware.com/ispy.cgi


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

Date: 9 Nov 2001 11:39:18 -0800
From: carl_ivar@yahoo.com (Carl)
Subject: Re: quick question about real-time display of print output
Message-Id: <274af38.0111091139.45d4a2a1@posting.google.com>

Yep, that's it.  Thanks for your help.

Carl


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

Date: 9 Nov 2001 12:58:12 -0800
From: houda.araj@cogmedia.com (Houda Araj)
Subject: Re: repeated string
Message-Id: <7d0055df.0111091258.bbf1b79@posting.google.com>

> Are you sure you mean *all* repeated strings?
No, I may say better repeated words, repeated phrases.   

Suppose a text 

Your words text appear on search result pages for the keywords you
buy, and can be by language and country. So, to reach toy collector of
tin toys you might buy word text the keywords toy collector toys.

toy collector (repeated twice verbatim)
word text (repeated plural and singular)  
toys is repeated


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

Date: 09 Nov 2001 19:17:58 +0000
From: nobull@mail.com
Subject: Re: Return from subroutine behaving unexpectedly
Message-Id: <u9hes3pxcp.fsf@wcl-l.bham.ac.uk>

"Andrew Harton" <andrew_harton@agilent.com> writes:

> I'm hoping someone can shed some light on this..

Please produce a small but complete script that actually compiles and
runs and which illustrates the symptoms.

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


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

Date: Fri, 09 Nov 2001 22:28:25 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Shift Operators - newbie
Message-Id: <3BEC588A.5759C742@acm.org>

Jessica Bull wrote:
> 
> I am trying to parse through someone else's code because modifications need
> to be made to the script.  I am having trouble understanding how the shift
> operator works.  In laymens terms I mean...i have the Programming Perl's
> interpretation on it.    The examples given are:
> 
> 1 << 4;  # Returns 16
> 32 >> 4; # Returns 2
> 
> The portion I am parsing through is:
> if($#remotetcsbpfiles>>0){@xferlist=buildxferlist(@remotetcsbpfiles)};
> 
> The logic of how it is getting the return value is primarily what I am
> looking for.  I appreciate the help.

$ perl -le'@x=qw(a b c d);while(pop @x){ if ($#x>>0){print"TRUE:
$#x"}else{print"FALSE: $#x"}}'
TRUE: 2
TRUE: 1
FALSE: 0
TRUE: -1


@xferlist=buildxferlist(@remotetcsbpfiles)  will only run if
@remotetcsbpfiles has zero or two or more elements, if it has only one
element it will not.  Is this really what you want?




John
-- 
use Perl;
program
fulfillment


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

Date: 9 Nov 2001 12:08:35 -0800
From: anyam_99@yahoo.com (Anya Miretsky)
Subject: Substitutions
Message-Id: <1e0c6f7a.0111091208.572aefa7@posting.google.com>

Sorry to keep asking such dumb questions but...

For some reason when I try to perform a substitution I get a string
returned to me with either nothing in it or a 1?? I can't get Perl to
return the initial string with the substitions that I ask for.

For example I tried some simple code from my book that went like:

$t = "this is a test";
$t = s/test/quiz/;
print "$t\n";

And nothing prints? Isn't this supposed to return "this is a quiz"?


If there is another list for beginner Perl questions where I could
post please let me know.

Thanks in advance.

Anya


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

Date: Fri, 09 Nov 2001 20:18:51 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Substitutions
Message-Id: <mbudash-01C050.12185709112001@news.sonic.net>

In article <1e0c6f7a.0111091208.572aefa7@posting.google.com>, 
anyam_99@yahoo.com (Anya Miretsky) wrote:

> Sorry to keep asking such dumb questions but...
> 
> For some reason when I try to perform a substitution I get a string
> returned to me with either nothing in it or a 1?? I can't get Perl to
> return the initial string with the substitions that I ask for.
> 
> For example I tried some simple code from my book that went like:
> 
> $t = "this is a test";
> $t = s/test/quiz/;

use =~, not =

> print "$t\n";
> 
> And nothing prints? Isn't this supposed to return "this is a quiz"?

hth-
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Fri, 9 Nov 2001 21:57:36 +0100
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: Substitutions
Message-Id: <Xns9154DF64365D3Laocooneudoramailcom@62.153.159.134>

perldoc perlsyn
perldoc perlre

$a =~ s/b/c/;


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

Date: Fri, 09 Nov 2001 21:17:21 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Substitutions
Message-Id: <slrn9uofcr.o0l.tadmc@tadmc26.august.net>

Anya Miretsky <anyam_99@yahoo.com> wrote:

>For some reason when I try to perform a substitution I get a string
>returned to me with either nothing in it or a 1?? I can't get Perl to
>return the initial string with the substitions that I ask for.


Have you read the docs on what a s/// is supposed to return?


>For example I tried some simple code from my book that went like:
>
>$t = "this is a test";
>$t = s/test/quiz/;


s/// is operating on the $_ variable there.

You use the binding operator (=~) to tell it to work on some other variable:

   $t =~ s/test/quiz/;


>print "$t\n";
>
>And nothing prints? 
     ^^^^^^^


Enable warnings and something will print.

You should have warnings enabled all of the time anyway.


>If there is another list for beginner Perl questions where I could
>post please let me know.


   http://lists.perl.org/showlist.cgi?name=beginners


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


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

Date: 9 Nov 2001 21:05:11 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: Trying to call a Perl script from Perl
Message-Id: <1005339911.101531@hpvablab.cup.hp.com>


[posted & emailed]


ajohnson_no_spam@purplemountain.net writes:
>This is probably a newbie question...
>
>I have a Perl CGI script that I call from my web page.  As a security 
>measure, I would like to be able to leave that Perl CGI script and call 
>another Perl CGI script when cookies aren't set correctly.  But I can't 
>figure out how to redirect the control to another Perl CGI script.
>
>I'm using the CGI.pm and DBI modules.
>
>I've tried "do" and "exec" but with no luck, My code looks something like:
>
>==============================================================
>SWITCH: {
>if (cookie('user') ne 'test') {do login.pl; last SWITCH;}
>
>(more SWITCH statements)
>}
>===============================================================
>
>Thanks so much for any help.
>Amy

Consider using the redirect function in the CGI module to redirect the
browser to the login page rather than trying to exec the login perl
script.

Read the docs closely, though, regarding this function:

        The redirect() function redirects the browser to a different
        URL.  If you use redirection like this, you should not print out
        a header as well.                                  ^^^

Rich
-- 
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant     | I speak for me,     |   19055 Pruneridge Ave. 
Development Alliances Lab|            *not* HP |                MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014


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

Date: Fri, 9 Nov 2001 18:41:54 +0000 (UTC)
From: Louis Erickson <wwonko@rdwarf.com>
Subject: Re: VVP: Variable = system command
Message-Id: <9sh81i$irq$1@holly.rdwarf.com>


[ Untangled top posting.  Please post AFTER other replies. ]

: tadmc@augustmail.com (Tad McClellan) wrote...
:> vivekvp <vivekvp@spliced.com> wrote:
:> >
:> >$last=system("tail test.txt")
:> >
:> >and have the variable $last filled with the last lines of the file
:> >'test.txt'.

[ snipped standard very good advice about:
    perl -w
    use strict;
    checking results from open
    filehandles being in all capital letters

Go do those things first.]

:> >any help?
:> 
:> You can get help by reading the documentation for the functions
:> that you use!
:> 
:>    perldoc -f system
:> 
:> tells you how to capture an external program's output.
:> 
:> You must have missed it, try reading it again.

vivekvp <vivekvp@spliced.com> wrote:
: I guess system is used for returning success or failure of a system
: call.  Not for displaying data.

system actually does run the program.  If the program has output,
you should see it on your terminal.  As you have learned, the result
of system is the success or failure of the program, not the output
of the text.

The next thing to learn is to read very carefully, and follow all the
references the manual pages give in to other sections of the manual.

The interesting part of perldoc -f system is:

               ... This is not what you
               want to use to capture the output from a command,
               for that you should use merely backticks or
               `qx//', as described in the section on "`STRING`"
               in the perlop manpage.

That should send you off to read the perlop documentation:

	perldoc perlop

In that section, search for `STRING` (/`STRING` in my pager, may be
different in yours.)  It should be around halfway through.  Go read
it now.  I'll wait right here.

One thing the documentation notes is that if you assign the value to
a scalar variable (like you do in your code) you'll get all the
results of the program run as one long string, with carriage returns
in it.  You can use regexps to split that apart, or you can capture
the output in array context instead of scalar, like this:

my @lines = ();

@lines = `tail file.txt`;

After that point, @lines will contain the output from your program, one
line per array element.

Hope that helps.



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

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


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