[18182] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 350 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 24 18:07:23 2001

Date: Sat, 24 Feb 2001 15: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)
Message-Id: <983055911-v10-i350@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 24 Feb 2001     Volume: 10 Number: 350

Today's topics:
    Re: File Writing Error / Where are the Buffers? <bkennedy99@Home.com>
        Linux Planet Example not working. Anyone got it to work <abcd@ntlworld.com>
        Mysql and Perl <vivekvp@spliced.com>
        passing filehandles/filenames between Perl scripts <donotreply@interbulletin.bogus>
    Re: Perl and Java applet <xu@redbird.co.uk>
        perl newbie question <matthias.reis@gmx.de>
    Re: perl newbie question <bart.lateur@skynet.be>
    Re: Perl on a shell account: how to use UNIX commands i (Martien Verbruggen)
        Perl parser <jkrohn@students.uiuc.edu>
    Re: Perl parser <bwalton@rochester.rr.com>
    Re: Problem: Perl cgi calling Excel via OLE on Win2000 <bart.lateur@skynet.be>
    Re: regex help needed <cryofan@msn.com>
    Re: select question <uri@sysarch.com>
    Re: select question <jdpepin@optonline.net>
        splice question <jdpepin@optonline.net>
    Re: splice question <rick.delaney@home.com>
    Re: splice question <jdpepin@optonline.net>
        Substitute on filehandle (Johan Johansson)
    Re: Substitute on filehandle <uri@sysarch.com>
    Re: Why two different class concepts? <iltzu@sci.invalid>
    Re: XS has broken my brain (Ilya Zakharevich)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 24 Feb 2001 21:54:28 GMT
From: "Ben Kennedy" <bkennedy99@Home.com>
Subject: Re: File Writing Error / Where are the Buffers?
Message-Id: <o4Wl6.11302$Bf3.1710278@news1.rdc2.pa.home.com>


"Brett Young" <youngb@uclink.berkeley.edu> wrote in message
news:976819$g10$1@agate.berkeley.edu...

> When Perl runs under CGI, where are the contents temporarily buffered?
Does
> Perl create temp files?

This is really up to the module you are using, not Perl.  If you are using
CGI.pm, the documentation (perldoc CGI to see it) says it it tries "tmp" in
the user's home directory, then what is in the environmental variable
TMPDIR, then /usr/tmp, /var/tmp, c:\temp, /tmp, and a few others.  Hope this
helps

--Ben Kennedy




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

Date: Sat, 24 Feb 2001 21:38:56 -0000
From: "Chile" <abcd@ntlworld.com>
Subject: Linux Planet Example not working. Anyone got it to work?
Message-Id: <OBVl6.21221$5n4.458322@news6-win.server.ntlworld.com>

Hi,

I just tried out Linux planets tutorial at

http://www.linuxplanet.com/linuxplanet/tutorials/1046/1/

and successfully completed the setting up of db etc.. but when i run the
script given below i get this error:

-----------

Add and Read Guestbook Entries
Content-type: text/html
Software error:
Can't call method "do" on an undefined value at
/home/httpd/cgi-bin/guestbook.pl line 68.
For help, please send mail to the webmaster (root@localhost), giving this
error message and the time and date of the error.

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


In order to get the script to work i had to remove the -Tw after
#!/usr/bin/perl as it gave errors and i had to take out use strict; as it
also gave errors. so i don't know if this is causing the problem.

if anyone knows how to get this working it would be great

thanks for any help
T

------------ original ---------


#!/usr/bin/perl -Tw

use strict;
$| = 1;

use CGI::Carp "fatalsToBrowser";
use CGI ":all";
use DBI;

my $serverName = "localhost";
my $serverPort = "3306";
my $serverUser = "guestbook";
my $serverPass = "guestbook";
my $serverDb = "guestbook";
my $serverTabl = "guestbook";

print
     header,
     start_html("SQL Guestbook"),
     h1("Add and Read Guestbook Entries");
if(my $error = check_form()) {
     show_form($error);
     print end_html;
} else {
     if(my $error = insert_entry()) {
          show_form($error);
     } else {
          show_entries();
     }
     print end_html;
}

sub show_form {
     my $error = shift;
     print hr;
     if($error) { print $error, hr; }
     print
          start_form,
     table(map
          Tr(td($_->[0]), td(textfield($_->[1],"",undef,60))),
          ["Name", "name"],
          ["Age", "age"],
          ["E-Mail Address", "email"],
          ["Web Site Address", "website"],
          ["Comments", "comments"],
          ),
     submit,
     end_form,
     hr;
}

sub check_form() {
     return "You didn't enter anything..." unless param();
     return "Please enter a name" unless param("name");
     return "Please enter your e-mail address" unless param("email");
     return;
}

sub insert_entry {
     my ($dbh, $success, $name, $age, $email, $website, $comments,$time);

     $dbh = DBI->connect("DBI:mysql:database=$server
Db;host=$serverName;port=$serverPort",$serverUser,$serverPass);
     $name = param("name");
     $age = param("age");
     $email = param("email");
     $website = param("website");
     $comments = param("comments");
     $time = time;
     $success = $dbh->do("INSERT INTO
               $serverTabl(name,age,email,website,comments,time)
               VALUES(?,?,?,?,?,?)", undef, $name, $age, $email, $website,
$comments, $time);
     $dbh->disconnect;
     if($success != 1) {
          return "Sorry, the database was unable to add your entry.
               Please try again later.";
     } else {
          return;
     }
}

sub show_entries {
     my ($dbh, $sth, @row);

     $dbh =
DBI->connect("DBI:mysql:database=$serverDb;host=$serverName;port=$serverPort
",$serverUser,$serverPass);
     $sth = $dbh->prepare("SELECT name,age,email,website,comments,time
               FROM $serverTabl ORDER BY time");
     $sth->execute;
     print "Existing Entries",hr;
     while(@row = $sth->fetchrow_array) {
          $row[5] = scalar(localtime($row[5]));
          print "Name: ", $row[0], br;
          print "Age: ", $row[1], br;
          print "E-Mail Address: ", $row[2], br;
          print "Web Site Address: ", $row[3], br;
          print "Comments: ", $row[4], br;
          print "Added on ", $row[5], hr;
     }
     $sth->finish;
     $dbh->disconnect;
}






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

Date: Sat, 24 Feb 2001 21:49:02 GMT
From: "Victor Prasad" <vivekvp@spliced.com>
Subject: Mysql and Perl
Message-Id: <i%Vl6.290505$f36.10877307@news20.bellglobal.com>

Hello,

I am trying to take a web form with different fields and have them insert
into a mysql database with one script.  The point of the script is to be
able to use it for any form.  The problem is the script runs with out error
on the web page - but does not insert.  What is wrong?
When I do a perl xx.cgi - it runs - no error - except there is not data..
help?

When I try to debug it - I get this before it runs:

media5: {1002} % perl -d xx.cgi
Default die handler restored.

Loading DB routines from perl5db.pl version 1.07
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(ww.cgi:13):      my $dbh;
ld.so.1: perl: fatal: relocation error: file
/usr/local/lib/perl5/site_perl/5.005/sun4-solaris/auto/Term/ReadKey/ReadKey.
so: symbol perl_get_sv: referenced symbol not found
Killed
-----------------------------
Here is the script:
#!/usr/bin/perl
#create.plx

use warnings;
use strict;
use DBI;
use CGI;

#####################
# Declare variables #
#####################

my $dbh;
my $buffer;
my $pair;
my $value;
my @pairs;
my $name;
my %FORM;
my $FORM;
my $row;

#Logging Enabled
### Remove any old trace files
unlink 'dbitrace.log' if -e 'dbitrace.log';

#################
# Get the input #
#################

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

####################################################
# Split the name-value pairs passed to the script. #
####################################################


@pairs = split(/&/, $buffer);

print "Content-type: text/html\n\n";
print "<html>";


### Open DB ###
$dbh=DBI->connect('dbi:mysql:xxxx','xxxx','xxxx') || die
 "Error: $DBI::errstr \n";
print "<BR> DBI error: $DBI::errstr <BR>";

my $stmt_1 = q{INSERT INTO wwinfo ( };
my $stmt_2 = q{  VALUES ( };

my @vals;

print "<br> @pairs \n";

for ( @pairs ) {
 my ($col, $val) = split /=/;
 $stmt_1 .= "$col,";  # Build up statement
 $stmt_2 .= "$val,";

 # Transform the value of the keyword.  This should be done by
 # using the CGI module instead of this way

 $val    =~ tr/+/ /;
 $val    =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

 # Save the original value in a hash
 $FORM{$name} = $value;

 # Default the specified value, if it was not entered.
 $val = 0 unless $val;
 print "<BR> col: $col, val: $val";

 # Save the list of values for the execute() below
 push @vals, $val;

 }

 die "empty form" unless $stmt_1 =~ /,$/;
 chop($stmt_1);   # Remove trailing commas
 chop($stmt_2);
 $stmt_1 .= " )";
 $stmt_2 .= " )";

# A little debug print we can remove later
   print "<br>INSERT statement: <br> $stmt_1$stmt_2\n";


   #  INSERT
### Set trace output to a file at level 2 and prepare()
DBI->trace( 2, 'dbitrace.log' );


   # Now prepare and execute the whole thing:
      my $sth = $dbh->prepare("$stmt_1$stmt_2") || die "prepare:
$DBI::errstr";

 my $rv = $sth->execute(@vals);

   # Check the return value from execute().

 print "<BR>\n";


$dbh->disconnect || die "Failed to disconnect \n";
--------------------------------------------------------

The Output:


buffer contents:
carea=123&cnumber=1234123&harea=123&hnumber=1231234&first_name=email%40email
 .com&first_name=John&last_name=Dope&street_1=123+House&city=Placeville&selec
t_state=Alabama&state=AL&zip=12345&country=United+States&flags1=1&birth_date
_mon=01&birth_date_day=19&birth_date_year=1981&Sex=0&Marital=S

DBI error:

carea=123 cnumber=1234123 harea=123 hnumber=1231234
first_name=email%40email.com first_name=John last_name=Dope
street_1=123+House
city=Placeville select_state=Alabama state=AL zip=12345
country=United+States flags1=1 birth_date_mon=01 birth_date_day=19
birth_date_year=1981 Sex=0
Marital=S
col: carea, val: 123
col: cnumber, val: 1234123
col: harea, val: 123
col: hnumber, val: 1231234
col: first_name, val: email@email.com
col: first_name, val: John
col: last_name, val: Dope
col: street_1, val: 123 House
col: city, val: Placeville
col: select_state, val: Alabama
col: state, val: AL
col: zip, val: 12345
col: country, val: United States
col: flags1, val: 1
col: birth_date_mon, val: 01
col: birth_date_day, val: 19
col: birth_date_year, val: 1981
col: Sex, val: 0
col: Marital, val: S
INSERT statement:
INSERT INTO wwinfo (
carea,cnumber,harea,hnumber,first_name,first_name,last_name,street_1,city,se
lect_state,state,zip,country,flags1,birth_date_mon,birth_date_day,birth_date
_year,Sex,Marital
) VALUES

123,1234123,123,1231234,email%40email.com,John,Dope,123+House,Placeville,Ala
bama,AL,12345,United+States,1,01,19,1981,0,S )

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

The dbitrace:

    DBI 1.13-nothread dispatch trace level set to 2
    -> prepare for DBD::mysql::db (DBI::db=HASH(0x1ef918)~0x1ef900 'INSERT
INTO wwinfo

carea,cnumber,harea,hnumber,first_name,first_name,last_name,street_1,city,se
lect_state,state,zip,country,flags1,birth_date_mon,birth_date_day,birth_date
_year,Sex,Marital )  VALUES

123,1234123,123,1231234,email%40email.com,John,Dope,123+House,Placeville,Ala
bama,AL,12345,United+States,1,01,19,1981,0,S )')
Setting mysql_use_result to 0
    <- prepare= DBI::st=HASH(0x15a870) at ww.cgi line 110.
    -> execute for DBD::mysql::st (DBI::st=HASH(0x15a870)~0x1f69cc '123'
'1234123' '123' '1231234' 'email@email.com' 'John' 'Dope' '123 House'
'Placeville' 'Alabama' 'AL' '12345' 'United States' '1' '01' '19' '1981' 0
'S')
    -> DESTROY for DBD::mysql::st (DBI::st=HASH(0x1f69cc)~INNER)
    <- DESTROY= undef at unknown location!
    -> DESTROY for DBD::mysql::db (DBI::db=HASH(0x1ef900)~INNER)
    IMPLICIT ROLLBACK ON DESTROY of database handle that is still connected!
Rollback ineffective while AutoCommit is on error 15 recorded: Rollback
ineffective while AutoCommit is on
imp_dbh->svsock: 1f9220
    <- DESTROY= undef at unknown location!
    -> DBI::END
    -> disconnect_all for DBD::mysql::dr (DBI::dr=HASH(0x17c420)~0x1ef8d0)
    <- disconnect_all= '' at DBI.pm line 424.
    <- DBI::END complete
    -> DESTROY in DBD::_::common for DBD::mysql::dr
(DBI::dr=HASH(0x1ef8d0)~INNER)
    <- DESTROY= undef during global destruction.





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

Date: Sat, 24 Feb 2001 18:29:33 +0000
From: Dan Shedd <donotreply@interbulletin.bogus>
Subject: passing filehandles/filenames between Perl scripts
Message-Id: <3A97FD8D.6F23FDE5@interbulletin.com>

I have an application to allow a user to upload photos to a server and at the same time post data about that picture to a database.  He/she fills out a form (HTML), which then calls a perl script.  This first script generates an HTML page to allow the user to confirm his/her entries prior to posting the data to the database.  If accepted, the action for this generated HTML page is to call a second perl script which will upload the file and post the description to an Access file vie Win32:oDBC. 
My problem occurs when transferring the filename between the two scripts.  WHile the 'name' carries over, for some reason the read statement doesn't work.  Put the file upload code in the first perl script and it workds fine.  So I was wondering that is getting lost betwene the two scripts.

Below is a sample of what I am trying to do;

first html doc;
<HTML>
<HEAD>
<title>Upload File</title>
</HEAD>
<BODY>
<H1><CENTER>Please Upload Your Data Files</CENTER></H1>

<FORM enctype="multipart/form-data" ACTION="one.pl" METHOD="POST">
<TABLE BORDER=0 WIDTH="100%">
<TR>
<TD>
Data filename:
</TD>
<TD>
<INPUT TYPE="FILE" NAME="filename" SIZE="35">
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="SUBMIT" VALUE="Upload File">
</TD>
<TD ALIGN=RIGHT>
<INPUT TYPE="RESET" VALUE="Reset">
</TD>
</TR>
</TABLE>
</FORM>

</body>
</html>

one.pl:

use CGI 'param'; # use CGI parameter to get dynamic info
$filename = param('filename');
print "<form enctype=\"multipart/form-data\" action = \"three.pl\"
method = \"post\">\n";
print "<input type = \"hidden\" name = \"filename\" value =
\"$filename\">\n";
print "<input type = \"submit\">\n";
print "</form>";
print "</p>\n";



two.pl:

use CGI 'param'; # use CGI parameter to get dynamic info
$filename = param('filename');
&head;
#####

#prepare to transfer picture file to server
$DestinationDir = "c:/inetpub/wwwroot/db_dir/pictures"; # no trailing
slash please
$filename =~ m/^.*(\\|\/)(.*)/; # remove the path string
$file = $2;

# read in the file
open(OUTFILE,">$DestinationDir\/$file");
binmode OUTFILE; # binmode is for windows only. Ignored by unix
while ($bytesread = read($filename,$buffer,1024)) {
print OUTFILE $buffer;
$fsize += $bytesread; # $fsize will return the size of the file
uploaded in bytes
 }
close (OUTFILE);

#####
appreciate any explanation as to why filename doesn't convey thru this
transaction

tia
dan




_______________________________________________
Submitted via WebNewsReader of http://www.interbulletin.com



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

Date: Sat, 24 Feb 2001 21:42:03 -0000
From: "xu palo" <xu@redbird.co.uk>
Subject: Re: Perl and Java applet
Message-Id: <9799c1$mds$1@newsg1.svr.pol.co.uk>

Thanks Jim for your help.

I had a look at java.sun.com but could not find

anything on the subject. What I am trying to do

is quite simplistic and it could just be my dodgy

code that is the problem.

Returning a page with a (code fragment)


print "<APPLET CODE=some.class>";

is not working, so I have gone for a different approach

with javascript instead. But even so, should that line

above work? Should some.class fire up on the client

browser? I am trying out some interesting text effects

which can be achieved quite nicely with some.class.

xu

"Jim" <jdlwrightNOSPAM@yahoo.com> wrote in message
news:c5xl6.125517$Ch.23314082@newsrump.sjc.telocity.net...
> yes, open a socket on port 80 in your applet to the URL of your cgi
script,
> then you can pass
> messages to it as if they were form variables.
> pretty sure you can find this stuff at java.sun.com by searching for
> something like sockets, CGI
>
> Jim
>
> Xu wrote in message <9749hi$4am$1@newsg1.svr.pol.co.uk>...
> >Is it possible for a Perl CGI script to respond to a client browser
request
> >for a page  with a Java applet embedded in its <APPLET> tag?
> >.
> >
> >
>
>




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

Date: Sat, 24 Feb 2001 21:33:17 +0100
From: "Matthias Reis" <matthias.reis@gmx.de>
Subject: perl newbie question
Message-Id: <9795ft$3r8$04$1@news.t-online.com>

hello,

I'd like to include a perl file in another perl file. I tried that with
require "/path/file.pl", but the variables from "/path/file.pl" don't seem to be in the scope
of the main file. Can anyone tell me how I get the variables in the scope
of my main file?

Matthias


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

Date: Sat, 24 Feb 2001 22:12:50 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: perl newbie question
Message-Id: <2ccg9tkv1eu34ci873v1e5fvlib87kupiu@4ax.com>

Matthias Reis wrote:

>I'd like to include a perl file in another perl file. I tried that with
>require "/path/file.pl", but the variables from "/path/file.pl" don't seem to be in the scope
>of the main file. Can anyone tell me how I get the variables in the scope
>of my main file?

By using global variables. In oither words: any variables declared with
"my" will NOT be visible from within any other files. So don't do that.

You may have package related problems, but I doubt that. Anyway: if you
want to access variables from another package, you have to fully qualify
them, so that @foo in package Flintstone::Fred can be accessed from
anywhere by using the name @Flintstone::Fred::foo.

-- 
	Bart.


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

Date: Sun, 25 Feb 2001 09:09:33 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Perl on a shell account: how to use UNIX commands in a perl script?
Message-Id: <slrn99gc8t.eoa.mgjv@martien.heliotrope.home>

On Sat, 24 Feb 2001 14:18:46 +0100,
	Alan J. Flavell <flavell@mail.cern.ch> wrote:
> On Sat, 24 Feb 2001, Martien Verbruggen wrote:
> 
>> [Please, in the future, post your reply _after_ the suitably trimmed
>> text you reply to.
> 
> Opinions may of course differ on this topic, but wouldn't it be better
> to persuade the hon. Usenaut, as a first priority, to post accurate
> information, before persuading them to abandon this remarkably
> accurate indicator of usenet bogosity?

That's what I, maybe rather brusquely, tried to do later in the article,
by referring to the documentation that should have been consulted. :)

I tend to keep general remarks separate from remarks about content.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | I used to have a Heisenbergmobile.
Commercial Dynamics Pty. Ltd.   | Every time I looked at the
NSW, Australia                  | speedometer, I got lost.


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

Date: Sat, 24 Feb 2001 13:53:25 -0600
From: jason f krohn <jkrohn@students.uiuc.edu>
Subject: Perl parser
Message-Id: <Pine.GSO.4.10.10102241352170.25109-100000@ux8.cso.uiuc.edu>

Can someone post the code of a parser fro perl.  It's been awhile and i
acidently deleted mine.  In case im calling it the wrog name it takes the
formdata out of a url and puts it in an associative array.  Thanks

Jason Krohn
http://www.krohnman.com



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

Date: Sat, 24 Feb 2001 23:01:23 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Perl parser
Message-Id: <3A983DAE.747FA6DD@rochester.rr.com>

jason f krohn wrote:
> 
> Can someone post the code of a parser fro perl.  It's been awhile and i
> acidently deleted mine.  In case im calling it the wrog name it takes the
> formdata out of a url and puts it in an associative array.  Thanks
> 
> Jason Krohn
> http://www.krohnman.com
Sounds to me like you should look at the docs for the CGI module.  The
params function should get you what you need with no further ado.
-- 
Bob Walton


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

Date: Sat, 24 Feb 2001 22:20:06 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Problem: Perl cgi calling Excel via OLE on Win2000
Message-Id: <vncg9tse911emn3ve9kic2cud4l0ev6ut2@4ax.com>

Dave Fisher wrote:

>I've been doing this for serveral years on a Win98 platform, and I
>just want to port the function to a new computer.  Any chance you know
>how to help me?

I think you might have a user privilege problem. Win2k might not allow
the user, as who the CGI script is running, to launch Excel. Good
server.

I STILL don't get it. Why on earth do you want to use CGI to open an
Excel window on your server? Or, do you think that you can use Perl only
for CGI scripts?

Oh, and no, I don't know how you might get around it. I'm still too
green WRT Win2k to solve that. I don't even know if there is even a
concept like suid on Win2k.

-- 
	Bart.


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

Date: Sat, 24 Feb 2001 08:56:13 -0600
From: "cryofan" <cryofan@msn.com>
Subject: Re: regex help needed
Message-Id: <e3uk9KnnAHA.235@cpmsnbbsa09>

By the way, this entire idea is, ahem, my intellectual property.

"cryofan" <cryofan@msn.com> wrote in message
news:eN7ZXDnnAHA.340@cpmsnbbsa09...
>
>
> Thanks for replies. I have basically fixed the problem. One thing I was
> doing wrong was the split; I changed it all-- got much better results. My
> new split obviates the need to smash the characters in front of the
"http".
> My new string-end-smasher is  $array1[$num_words] =~ s/>.*$/$blank/;
> One person commented that the problem is that the asterisk above stands
for
> zero or more, and that the problem was that it was taking only the zero.
> Well, I don't think that is the case (maybe I misunderstood) b/c it is
> greedy, and takes as many as possible. The above code does do the job--it
> smashes the end of the string---everything inclusive and after the >, till
> the end.
>
> I still have a one-off problem somewhere, but that will be easy.
>
> BTW, this code is for my senior project (BS  in CS), a data mining
tool/bot
> that will access financial news web pages and count words of interest such
> as "bull, "bears",  "recession", "rates", "rise", "falling", and so forth,
> count the number of occurences and store that info along with the time,
and
> then parse a web page that gives near-real-time stock market data such as
> Dow Jones average, etc, and store that along with the time, and then puts
> all this data on a web page so that the viewer can see if the number of
> words of interest (how many time bull, bear, recession, etc) has any
effect
> on the stock market stats.
> I am trying to quanitfy and analyse stock market psychology.
>
> This bot runs off a free website, and it doesn't offer the HTTP module
that
> lets me auto-parse URLS, so I have to parse the URLs of the news stories
> myself.
>
>
> $blank="";
> @array1= split(/href=/,$content);
> $num_words = 0;$num_links=0;
> while($num_words <= @array1)
> {
>   #if($array1[$num_words]
>
=~/href\=http\:\/\/biz\.yahoo\.com\/rb\/[0-9]*\/[a-zA-Z0-9_]*\.html\>\<b\>[a
> -zA-Z0-9_]*/i)
>
#href=http://biz.yahoo.com/rb/010222/business_stocks_earnings_dc_2.html><b>T
> ech
>   if($array1[$num_words] =~/^http\:\/\/biz\.yahoo\.com\/rb\/.*/)
>      {
>   #      sleep(1);
>         #print $array1[$num_words];
>         #$array1[$num_words] =~ s/^[a-zA-Z0-9<>_.\.\=\\n]*href=//s;
>         $array1[$num_words] =~ s/>.*$/$blank/;
>         $somestring= $array1[$num_words];
>         $array2[$num_links]=$somestring;$num_links++;
>
>
>       #  print $array1[$num_words];
>     #print $somestring;
>
>      }
>
>    $num_words++;
>
> }
>  print "The total number of links is ", $num_links-1;
>
>  while($num_links >0){
>   sleep(1);
>   print "\n",  "link number", $num_links, "\n";
>   print "\n";
>    print $array2[$num_links-1];
>
>
>   $num_links--;
>
>
>
> "cryofan" <cryofan@msn.com> wrote in message
> news:OLBNHphnAHA.327@cpmsnbbsa09...
> > I am trying to kill the end of a string stored in an array.
> > This is what the string looks like:
> >
>
http://biz.yahoo.com/rb/010223/business_spieker_merger_dc_5.html><b>Equityma
> > rket
> > .</small><p><a
> >
> >
> > The string is stored in array1[$num_words].
> >
> > why doesn't this code work?
> >
> >  $array1[$num_words] =~ s/\>\<b\>.$//;
> > (note that I do have a hard-to-see period after "\>\<b\>" and before the
> > "$", which should represent everything after the "><b>." until the
> newline.)
> > What I want to do is get rid of everything after the "html". But it is
not
> > working. I have tried many other more complicated substitution regexes
> with
> > no success. I was able to get rid of everything before the "http" with
no
> > problem, but something weird is going on at the end.
> >
> > Also, why won't this work?
> >
> >  $array1[$num_words] =~ s/\>\<b\>[a-zA-Z0-9]*//;
> >
> >
> >
> > TIA
> >
> >
>
>




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

Date: Sat, 24 Feb 2001 22:06:15 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: select question
Message-Id: <x7hf1jhh2g.fsf@home.sysarch.com>

>>>>> "JP" == Joseph Pepin <jdpepin@optonline.net> writes:

  JP> I've got an array of numbers (actually x, y coordinates for a
  JP> jointed line).  I want a select statement to return to me the
  JP> first four numbers but only remove only the first two. From my
  JP> reading of TFM, this should work:

  JP> @a = (1, 2, 3, 4, 5, 6);

  JP> @b = select @a, 0, 4, $a[2], $a[3];

huh??? that shouldn't even parse (but i won't try).

select is related to I/O and not to arrays. there is a 1 arg and a 4 arg
select call and neither does anything like what you are trying. what do
you want? you might be looking for splice instead.

  JP> Now, when I try:

  JP> @b = select @a, 0, 4, $a[2] + 0, $a[3] + 0;

did you really try that? i doubt it. post real code and not something
you think you have tried.

  JP> I get @b = (1, 2, 3, 4), which is what I wanted.  Why the difference?

  JP> Of course, there are other ways to do this.

correct ways would be nice to try.

uri

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


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

Date: Sat, 24 Feb 2001 22:12:14 GMT
From: "Joseph Pepin" <jdpepin@optonline.net>
Subject: Re: select question
Message-Id: <2lWl6.7708$Vj5.1547286@news02.optonline.net>

Sorry, I typed this in from memory, and where I have 'select' I should have
put 'splice'.  Some more info: I get the same thing on both Perl 5.6.0 on
Solaris 2.6, and ActiveState 623.

"Uri Guttman" <uri@sysarch.com> wrote in message
news:x7hf1jhh2g.fsf@home.sysarch.com...
> >>>>> "JP" == Joseph Pepin <jdpepin@optonline.net> writes:
>
>   JP> I've got an array of numbers (actually x, y coordinates for a
>   JP> jointed line).  I want a select statement to return to me the
>   JP> first four numbers but only remove only the first two. From my
>   JP> reading of TFM, this should work:
>
>   JP> @a = (1, 2, 3, 4, 5, 6);
>
>   JP> @b = select @a, 0, 4, $a[2], $a[3];
>
> huh??? that shouldn't even parse (but i won't try).
>
> select is related to I/O and not to arrays. there is a 1 arg and a 4 arg
> select call and neither does anything like what you are trying. what do
> you want? you might be looking for splice instead.
>
>   JP> Now, when I try:
>
>   JP> @b = select @a, 0, 4, $a[2] + 0, $a[3] + 0;
>
> did you really try that? i doubt it. post real code and not something
> you think you have tried.
>
>   JP> I get @b = (1, 2, 3, 4), which is what I wanted.  Why the
difference?
>
>   JP> Of course, there are other ways to do this.
>
> correct ways would be nice to try.
>
> uri
>
> --
> Uri Guttman  ---------  uri@sysarch.com  ----------
http://www.sysarch.com
> SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX
Consulting
> The Perl Books Page  -----------
http://www.sysarch.com/cgi-bin/perl_books
> The Best Search Engine on the Net  ----------
http://www.northernlight.com




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

Date: Sat, 24 Feb 2001 21:14:45 GMT
From: "Joseph Pepin" <jdpepin@optonline.net>
Subject: splice question
Message-Id: <9vVl6.7529$Vj5.1483672@news02.optonline.net>

(Bah - I'm having a senior moment; 'select' should have been 'splice'.)

I've got an array of numbers (actually x, y coordinates for a jointed line).
I want a splice statement to return to me the first four numbers but only
remove only the first two. From my reading of TFM, this should work:

@a = (1, 2, 3, 4, 5, 6);

@b = splice @a, 0, 4, $a[2], $a[3];

However, what I get in @b is (1, 2, undef, undef).  @a is left with (3, 4,
5, 6), what I wanted. Shouldn't @b be (1, 2, 3, 4) ?

Now, when I try:

@b = splice @a, 0, 4, $a[2] + 0, $a[3] + 0;

I get @b = (1, 2, 3, 4), which is what I wanted.  Why the difference?

Of course, there are other ways to do this.






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

Date: Sat, 24 Feb 2001 21:36:02 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: splice question
Message-Id: <3A982C86.F855A0E8@home.com>

[posted & mailed]

Joseph Pepin wrote:
> 
> @a = (1, 2, 3, 4, 5, 6);
> 
> @b = splice @a, 0, 4, $a[2], $a[3];
> 
> However, what I get in @b is (1, 2, undef, undef).  @a is left with (3, 4,
> 5, 6), what I wanted. Shouldn't @b be (1, 2, 3, 4) ?

Yup, and it is in 5.005_03 and up.  What version are you using?

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sat, 24 Feb 2001 21:55:41 GMT
From: "Joseph Pepin" <jdpepin@optonline.net>
Subject: Re: splice question
Message-Id: <x5Wl6.7692$Vj5.1529479@news02.optonline.net>

5.6.0. The same thing happens on both Solaris (built from scratch) and
ActiveState 623.

"Rick Delaney" <rick.delaney@home.com> wrote in message
news:3A982C86.F855A0E8@home.com...
> [posted & mailed]
>
> Joseph Pepin wrote:
> >
> > @a = (1, 2, 3, 4, 5, 6);
> >
> > @b = splice @a, 0, 4, $a[2], $a[3];
> >
> > However, what I get in @b is (1, 2, undef, undef).  @a is left with (3,
4,
> > 5, 6), what I wanted. Shouldn't @b be (1, 2, 3, 4) ?
>
> Yup, and it is in 5.005_03 and up.  What version are you using?
>
> --
> Rick Delaney
> rick.delaney@home.com




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

Date: 24 Feb 2001 20:51:35 GMT
From: johanj@aristotle.algonet.se (Johan Johansson)
Subject: Substitute on filehandle
Message-Id: <9796sn$2hk$1@zingo.tninet.se>

Hi !

Im trying to build a script that opens a textfile as a filehandle and goes
through all the lines in that textfile and uses the substitute command to
exchange a word to another one in the file. 

Can someone give me a short example as hint to solve the problem ?

I suppose i should open the filehandle writeable, but shall i open another
filehandle for the nmput  ?

like 

open(INFILE,"<$my_original_file");
open(OUTFILE,">>$my_output_file");

and then ? a while loop ? on what shall i use the substitue ?

/Johan






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

Date: Sat, 24 Feb 2001 22:02:58 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Substitute on filehandle
Message-Id: <x7lmqvhh83.fsf@home.sysarch.com>

>>>>> "JJ" == Johan Johansson <johanj@aristotle.algonet.se> writes:

  JJ> Hi !
  JJ> Im trying to build a script that opens a textfile as a filehandle and goes
  JJ> through all the lines in that textfile and uses the substitute command to
  JJ> exchange a word to another one in the file. 

  JJ> Can someone give me a short example as hint to solve the problem ?

  JJ> I suppose i should open the filehandle writeable, but shall i open another
  JJ> filehandle for the nmput  ?

  JJ> open(INFILE,"<$my_original_file");
  JJ> open(OUTFILE,">>$my_output_file");


perl -ip.bak -e 's/old/new/'

uri

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


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

Date: 24 Feb 2001 19:06:16 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Why two different class concepts?
Message-Id: <983040043.12421@itz.pp.sci.fi>

In article <3AC1EBB9@MailAndNews.com>, Daniel Pfeiffer wrote:
>Yesterday there was a bit of discussion about overload vs. tie.  In perldoc
>overload we read:
>
>       The value for `"="' is a reference to a function with
>       three arguments, i.e., it looks like the other values in
>       `use overload'. However, it does not overload the Perl
>       assignment operator. This would go against Camel hair.
>
>Apparently allowing a normal class to control assignment is bad, while the
>very same thing realised through "tie" is all right.  This doesn't make
>sense!

The difference is between the variable and its value/contents.  When
you use overload, you're creating a special value.  When you tie a
variable, you make the variable itself magical.

Assignment moves the value of one variable into another.  It therefore
makes perfect sense that you can't overload it (since the value isn't
really affected, it's just moved around) and that it will not copy any
tie magic the original variable may have had (since the magic is not
part of the value, but tied (sorry) to the variable).

It's quite possible to store an overloaded value in a tied variable.


>I am thinking about a programme, which rather than doing some
>expensive calculations internally, would let a much better suited
>external programme do them.  Now this programme could also store= External->new(5);  # $foo contains an external value 5
  my $bar = 4;                 # $bar contains an ordinary value 4
  my $baz = $foo + $bar;       # $baz contains an external value 9

  $foo = 23;                   # $foo contains an ordinary value 23
  $baz = $foo - $bar;          # $baz contains an ordinary value 19
  $foo = External->new($baz);  # $foo contains an external value 19

There.  No need to mess with tied variables.  You just need to accept
that making an external value out of an ordinary one always requires a
method call.  This is how it should be.

--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"And, should you resort to sticking a martini olive up their nose,
 implacable universal laws require that they'll _like_ that sort of
 thing."  -- Graydon in r.a.sf.c

Please ignore Godzilla and its pseudonyms - do not feed the troll.


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

Date: 24 Feb 2001 19:34:50 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: XS has broken my brain
Message-Id: <9792cq$1e$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to David Lloyd 
<david@freemm.org>],
who wrote in article <3A97D900.59C563F8@freemm.org>:
> TYPEMAP
> module_struct *		MODULE_SUBPACKAGE_OBJ
> 
> INPUT
> MODULE_SUBPACKAGE_OBJ
>     $var = ($type) SvIV((SV *)SvRV($arg));
> 
> OUTPUT
> MODULE_SUBPACKAGE_OBJ
> 	sv_setref_pv($arg, "Module::SubPackage", (void *) $var);

So basically it is a sped-up T_PTROBJ, without type checks on input, right?

Did you debug your stuff with T_PTROBJ first?

> Error: No INPUT definition for type 'module_struct *', typekind
> 'MODULE_SUBPACKAGE_OBJ' found in Module.xs, line xxx

Insert some debugging statements into xsubpp around this message.
When you have a fix, please communicate it to p5p...  THe wildest
guess: check your whitespace in 'typemap'.

Ilya


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

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

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


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


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