Re: Mysql interface with perl on win 2k, Someone please help !

2001-06-05 Thread Jos Boumans

You'll need to read up on DBI and install the appropriate module/driver from
cpan
(DBD-YourDriver and DBI)

here's a short guide to dbi you might want to read up at:
http://www.perl.com/pub/1999/10/DBI.html

That article also holds references to other sources, so i think that will be a
nice start.

good luck,

Jos Boumans

[EMAIL PROTECTED] wrote:

> >
> >Hi,
> >
> >Im trying to connect a perl program to a mysql database on my home computer
> >running win 2k.  I can connect, but i have no idea of how to extract the
> >information out of tables using perl. I have a book about SQL, but it never
> >mentions programming or perl. If anyone could point me to a good tutorial,
> >or give me a few pointers I would be greatly appreciative.
> >
> >
> >Thanks
> >
> >Jonathan Macpherson




Re: automatic cgi scripts?

2001-06-05 Thread Jos Boumans

Give it an entry in the crontab

man cron
man crond

that should explain functionallity for you

good luck

Jos Boumans



Sanchit Bhatnagar wrote:

> Hi,
>  Is there any way to automatically execute a cgi script in un*x on a preset delay, 
>say for ex. once every day at 0800hrs.?
>
> thanks,
> san.




Re: NEW LINE

2001-06-11 Thread Jos Boumans

That code is a bit tricky, since you're now changing the behaviour of $/
throughout the entire file

A bit safer way to do this would be the following:

open I, "yourfile.txt";#open a textfile for reading
{ local $/;#undef $/, which is essentially the
same as $/ = ''; we use the 'local' to make sure it's value get's
restored upon exiting the block
   my $in = ;   #put all of the file in $in;
   do_stuff_with($in)#do some stuff with the text in $in
}# exit loop, restore $/; NOTE: this
also resets the value of $in... if you dont want that, set the 'my $in'
above the block, rather then in it

hth,

Jos Boumans

Me wrote:

> > Can anyone send me any solution
> > to read the paragraph from a text file?
>
> To read paragraphs (delimited by one or more blank
> lines (really blank, no spaces or tabs)), change the
> record separator from its default (newline) to the
> null string ('').
>
> $/ = '';
>
> while (<>) {
> print;
> }




Re: Getting to the contents of a class..

2001-06-11 Thread Jos Boumans

What myflds probably is (if used a 'normal' contructor returning a hashref), is
a hashref

if you want to acces it, you'll need something like:

foreach my $item ( keys %{$reqrec->myflds} ) { ..}

now, if that is not working, you might want to concider posting the constructor
of your module to the list, it would make it easier for us to indicate the
problem

hth,

Jos Boumans

Ela Jarecka wrote:

>
> foreach my $item ( keys $reqrec->myflds ) {  #line 26
>  ...
> }
>
> I get an error:
> 'Can't locate object method "myflds" via package "DataReq" at makeReq line
> 26'
>
> How should I indicate that 'myflds' is a hash? I've tried putting an '%' in
> front of 'myflds' but it returned
> an error as well.




Re: AW: Getting to the contents of a class..

2001-06-11 Thread Jos Boumans

first, i'll explain a little bit about references:

they *refer* to a (anonymous) data structure, and the need thing about
them is that they behave like scalars when passed around and such.

another thing you have to understand that if you want a hash of hashes,
that is not possible:
perl keeps it's data as flat data structures and hence wouldnt be able
to tell where one list (array/hash) would end and the other would start
this is the same problem you have when passing 2 arrays to a subroutine;
they will become one array.

what you would want is the following:

either just use $self as the container for whatever is in %myflds;
my $self = \%myflds

or set the contents of $self explicitely:

my $self = {
foo => 'bar',
bar => 'quux',
};

i refer you to 2 tutorials i wrote on that subject, which can be found
here:
http://www.sharemation.com/~perl/tut

you will want to read the first tutorial (data structures) and the third
one (references)
i think they will clear up most of the confusion.

hope this helps,

Jos Boumans

Ela Jarecka wrote:

> Unfortunately, it doesn't seem to work... :-(
>
> My constructor:
>
> sub new {
>my $that = shift;
>my $class = ref($that) || $that;
>my $self = {
>   %myflds,
>};
>bless $self, $class;
>return $self;
> }
>
> Please help,
> Ela
>
> > -Ursprüngliche Nachricht-
> > Von: Jos Boumans [mailto:[EMAIL PROTECTED]]
> > Gesendet: Montag, 11. Juni 2001 12:04
> > An: Ela Jarecka
> > Cc: Beginners list (E-Mail)
> > Betreff: Re: Getting to the contents of a class..
> >
> >
> > What myflds probably is (if used a 'normal' contructor
> > returning a hashref), is
> > a hashref
> >
> > if you want to acces it, you'll need something like:
> >
> > foreach my $item ( keys %{$reqrec->myflds} ) { ..}
> >
> > now, if that is not working, you might want to concider
> > posting the constructor
> > of your module to the list, it would make it easier for us to
> > indicate the
> > problem
> >
> > hth,
> >
> > Jos Boumans
> >
> > Ela Jarecka wrote:
> >
> > >
> > > foreach my $item ( keys $reqrec->myflds ) {  #line 26
> > >  ...
> > > }
> > >
> > > I get an error:
> > > 'Can't locate object method "myflds" via package "DataReq"
> > at makeReq line
> > > 26'
> > >
> > > How should I indicate that 'myflds' is a hash? I've tried
> > putting an '%' in
> > > front of 'myflds' but it returned
> > > an error as well.
> >




Re: Calling touch ...

2001-06-12 Thread Jos Boumans

on a *nix system, any file created automatically get's a timestamp... as
far as 'touch' goes, this might well be over kill in this case.

concider the following:
open O, ">foo.txt";

this creates 'foo.txt' and opens it for writing.
now, if you dont write anything to it, that's your choice... and you'll
end up with a 0 byte file called foo.txt, properly (unix) timestamped

or, if you want to name your file after the current time, you could use
something like:
my $t = time;
open O, ">$t";

in effect, this does the same as touch, and avoids nasty system calls...

of course, if you need return values or checks, you could add an 'or die
"file not created"' or even eval it...

hope this helps

Jos Boumans


[EMAIL PROTECTED] wrote:

> I'm trying to write a script that opens a file, then matches some
> characters, and then writes the output to an HTML file on the fly.
>
> Everything works except I also want to timestamp a file with touch
> in the same perl script and that doesn't work. Touch is active as I
> can 'touch' the file on the console. But my code inside the perl
> script doesn't work.
>
> Here is the latest statements that I tried.
>
> system 'touch', 'test0612a.shtml';
>
> exec 'touch', 'test0612a.shtml';
>
> Thanks for any help,
> ~




Re: Installing new Modules problem

2001-06-12 Thread Jos Boumans


Sounds like an error somewhere during your initial installation... i recall seeing 
that happen more often on this list

you might want to concider checking the AS support pages, or mailing them your problem

hth,

Jos Boumans


[EMAIL PROTECTED] wrote:

> Hi,
>
> I did also try this but I get the same error "Failed to load PPM_DAT file"
> and then nothing seems to work even though I am in the PPM shell.
>
> Jason




Re: Problems inserting hash value in a String.

2001-06-12 Thread Jos Boumans

>From a quick look at your code, here is the problem:
'$postInputs{'$fields[2]'}'

the single quotes will confuse your mysql

you might want to concider using the following syntax, which, in general, is
cleaner:

### something from a block of code i use ###
sub set_code { # usage setcode($string,$userid,$ip):
use DBI;

my $string = shift;
my $owner = shift;
my $ip = shift;

 my $sth = $dbh->prepare_cached('INSERT INTO code VALUES (_rowid, ?, ?,
?, NOW())')
or die "Couldn't prepare statement: " . $dbh->errstr;
my $rv = $sth->execute($string, $owner, $ip) or die "Couldn't execute
statement: " . $sth->errstr;
}

at the my $sth you see how we first prepare the query (i even use
prepare_cached here, which is helpful if you execute the same query multiple
times); for every variable, we put in a ? (_rowid is an autoincrement number,
and NOW() is a timestamp)
next, we execute the $sth with the variables we want interpolated
$rv will hold the return value of the query (generally the amount of rows
affected by your query)

see perldoc DBI for more info, or read the short guide to dbi on perl.com here:
http://www.perl.com/pub/1999/10/DBI.html

hope this helps,

Jos Boumans

ciberm3 wrote:

> Hi all,
>
> I have a problem using a hash variable and I don't know where is the error.
> Let me explain it: I have a web page with a form which user must fill in
> with personal data then when the user click 'Send' button the cgi I am
> programming starts; I have a txt file containing the name of the fields of
> the form which match with the name of the fields in the table I want to
> insert data so first thing I am doing in the cgi is obtaining data typed by
> the user in the form and I store it in a hash named %postInputs; then I use
> a function to initialize an array with the fields in the text file so the
> name of the array is @fields. No I am using next function to insert data in
> the table:
>
> ...
> %postInputs = readPostInput();
> readFields(@fields);
> ...
> insertData();
> ...
> sub insertData()
> {
>
>my $base_datos = $fields[0];
>my $driver = "mysql";
>my $tabla = $fields[1];
>my $sql_inserta="INSERT INTO $tabla (dia_alta,
> mes_alta,
> anno_alta,
> $fields[2])
>   VALUES ('$mday',
>  '$mon',
>  '$year',
>  '$postInputs{'$fields[2]'}')"; #
> (*) HERE IS THE PROBLEM
>my ($dbh) = DBI->connect("DBI:$driver:table_name") || die "\nError al
> abrir la base de datos: $dbh->errstr()\n";
>$dbh->do($sql_inserta) || die "prepare: " . $dbh->errstr();
>$dbh->disconnect || warn "\nError al desconectar.\nError:
> $DBI::errstr\n";
> }
>
> Then when I execute this function, data is inserted into the table except
> the field I mark (*). If I use ...,'nombre')" it works and insert this data
> into the table.
>
> On the other hand, in the DBI->connect sentence I have another problem
> because I must use DBI->connect("DBI:$driver:table_name") and I want to use
> DBI->connect("DBI:$driver:$base_datos"). I think the problem is the same.
>
> Please, does anyone know how can I solve this problem?.
>
> Many thanks for your help.
>
> [EMAIL PROTECTED]
>
> _
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com




Re: testing on email characters

2001-06-12 Thread Jos Boumans

try this:

unless (/^[-\.\w]+$/) { print "you cheater!" }

this will check if from beginning to end of $_ it contains - . (not even sure
you need to \ the . ) or any word character (a-z A-Z and _ )

the ^ says to start at the beginning of the string... the $ says to read till
end of line...

i'm on a machine without perl here, so the string is untested...

hth,

Jos Boumans

[EMAIL PROTECTED] wrote:

> if ( $add_alias =~ /\@/ ) {
>
> right now i am testing a variable to see if it contains an \@ character. i
> would prefer to test it to see if it has anything *other* than
> a-zA-Z0-9\.\-\_
>
> can i do this with a regex like
>
> if ( $add_alias =~ /[^a-zA-Z0-9\.\-\_]/ ) {
>
> i am not certain if my search range is too broad.




Re: testing on email characters

2001-06-12 Thread Jos Boumans

Please, if you try and flame posts, get your facts straight.

1st: - is a range operator, and hence needs not be escaped when it's not
indicating a range, ie, at the beginning or end of a []
  so this regex is not 'wrong'. feel free to try it.
2nd:the regex is purposely written verbose, seeing this is a newbie list and we
want to teach them, not scare them away by hard to follow code
  on that note: ^\w might confuse, since, when used inside a range ( [] ),
means something totally different then outside it... hence, for comprehension i
teach \W instead
  (for those wondering: outside a range, ^ means 'match beginning of
string', inside a range it means 'not')

so the short version would be:
if (/[\W.-/]){ print "illegal string" }

the verbose version would be an explicit check of every character, as described
below

hope this clears things up,

Jos Boumans

PS html tags end 

Chas Owens wrote:

> On 12 Jun 2001 17:45:16 +0200, Jos Boumans wrote:
> > try this:
> >
> > unless (/^[-\.\w]+$/) { print "you cheater!" }
> >
> > this will check if from beginning to end of $_ it contains - . (not even sure
> > you need to \ the . ) or any word character (a-z A-Z and _ )
> >
> > the ^ says to start at the beginning of the string... the $ says to read till
> > end of line...
> 
>
> This regexp is a little to verbose (and wrong since - is not escaped).
> Since we want a failure if any character fails to match "a-z", "A-Z",
> "0-9", "_", "-", "." we don't need to test that the whole string is
> correct, only that any character in it is wrong:
>
> if (/[^\w.\-]/) { print "you cheater!" }
>
> However, if you wanted to limit the string to $x characters you might be
> better off testing like this:
>
> unless (/^[\w.\-]{1,$x}$/) { print "you cheater!" }
>
> --
> Today is Pungenday, the 17th day of Confusion in the YOLD 3167
> Umlaut Zebra über alles!




Re: what does perl do internally when filehandles are undefined?

2001-06-12 Thread Jos Boumans

Hello,

> I commonly make use of statements like: print OUTFILE "Print
> results, data, or anything else\n";
> This is normally preceded by defining my file handle, as in something
> like: open(OUTFILE, ">newfile.txt");
>
> Or does print (or printf for that matter) recognize that no such
> filehandle exists and quit?

it doesnt 'quit' if you mean by that exit the program or cause an error...
if you run under -w it will tell you you might have made a mistake by not
opening the filehandle... you could do a check if it's open of course but
that's not what you want most likely

> As part of a program I'm writing, I would prefer that it quit if the
> filehandle is undefined.  I want the user to specify between 2 levels
> output verbosity,

you can make an easy check for that if you like:

my $debug = 1; (or '' if you want to turn muy verbose off)

and with that you can build in statements like this:

$debug && print "extra verbose msg!";

this will only print if $debug has a value

Hope this helps,

Jos Boumans




Re: use of split command

2001-06-13 Thread Jos Boumans

if this is what you want:

while () { $string .= $_ }

you'll want to concider using this instead:
{ local $/; $in =  }

which will put the entire contents of HANDLE into $in (by undeffing $/, which
is holds the line seperator character - it will be restored once the block
exits)

but like genie said, carefull you dont read in *too* much into memory, cuz it
will kill your PC

if your intent is something like this:

"if a certain line in the file contains 'foo', print it to a log file" then
this:

while () { if(/foo/) { print LOG "$. holds $_" } }

which will be a lot safer and kinder to your memory then:

@foo = ;
for (@foo) { if (/foo/) { print LOG "$. holds $_" } }

since the first doesnt require the entire file to be read into memory first

hope this helps,

Jos Boumans


"Evgeny Goldin (aka Genie)" wrote:

> > I am trying to read a quite large file (ca 13000 lines) directly into an
> > array (for speed)
>
> while (  ){..}
>
> is the best way for reading large files, I think.




Re: use of split command

2001-06-13 Thread Jos Boumans

I'd like to make a few adjustments on this code, and give you some things you might 
want
to concider using:

open (ACCS, "C:\\Perl\\BioPerl-0.7\\Seqdata\\Accession.txt") or die "can't open 
Accessions
file ", $!;
# this will produce also the error returned by the system call... usefull for figuring 
out
*why* the file wasnt opened
# you might want to concider putting the location in a var name, like $loc and have 
open
operate on $loc... makes it easy if you use that file more often in the script.

# depending on size of the file, you will probably want to do one of the following:

#this will read the entire file into a string and will save you somewhere around 24 
bytes
per line compared to an array
#quick math says that saves you ~2.4mb of ram on 100k lines
#putting it in a string is nice for doing s///, m// operations and passing it around to
subroutines etc
*** Option 1 ***
my $in;
{local $/; $in =  }
while(split "\n", $in) {
my ($one, $two) = split "\t";#assuming a tabdelimited list again
# do something with those vars
}

#however, you might just want to lower memory load and use:
*** Option 2 ***
while () {
my ($one, $two) = split "\t";#assuming a tabdelimited list again
# do something with those vars
}

doing as mentioned below is not very smart, seeing it first copies all the info to an
array, and then handles it one line at a time anyway in the for loop
this has the memory load of option 1, while it has the functionality of option 2... the
worst of both worlds so to speak

last remark i want to make is that it's always good to run 'use strict' and force 
yourself
to use lexicals (my'd vars).

hope this helps,

Jos Boumans

> open (ACCS, "C:\\Perl\\BioPerl-0.7\\Seqdata\\Accession.txt") or die "can't
> open Accessions file";
> @ets=;
>
> foreach (@ets) {
>
> ($first, $second) = split(/\t/, $_);#(Splits current on a tab: 
>\t)
>
> # do what you need with the two variables
>
> }
>
> you are right, that is a very fast way to deal with files.
>
> If you have regularly delimited files, and would prefer to work with them
> using SQL like syntax, you might look at DBD::CSV for another alternative.
>




Re: Strict, require and hashes..

2001-06-13 Thread Jos Boumans

what you need in your config file is something like the following:

### config.pm ###
%hash = ( foo => 'bar' );

1; #return a true value for 'use'

in your script, you'll need to do this:

### script.pl ###
use strict;
use 'config.pm';
use vars qw(%hash);

and then strict wont complain about lack of package indication...

now, what you *really* want to do is package the config file and use exporter to
make sure you don't clobber namespaces, but that might be a bit advanced, so for
now, this should solve your problem

hope this helps,

Jos Boumans

Dianne Van Dulken wrote:

> Hi all,
>
> I was (yet again) hoping someone might help me with something.
>
> I have a cfg file called extra_details.cfg containing a hash %my_hash.
>
> I reference this in my perl script, using a require "extra_details.cfg"
>
> The problem now is that every time I try to reference my_hash in my script,
> whilst I am using strict, I get a
> Global symbol "%my_hash" requires explicit package name error.
>
> If I add an "my %my_hash;" anywhere, it overwrites the hash, so it is just a
> blank one.
>
> Does anyone know how I can get around this?
>
> It will work perfectly if I remove the "use strict" line, but I have these
> terrible qualms of guilt and fear every time I do so.
>
> Thanks
>
> Di
>
> --
> Dianne van Dulken
> E-commerce Analyst/Programmer
> OzEmail
> Phone: (02) 9433 2510
>
>




Re: Unexplainable behavior

2001-06-13 Thread Jos Boumans

untested, but here's my theory:

you're having precedence problems, try parenthesizing!

ie,

if( exists($hash{s}) and ( ($hash{s} ne "T") or ($hash{s} ne "F") ) ) {


hth,

Jos Boumans


Charles Lu wrote:

> The following snippet of code doesn't behave the way I want it to.  Yet i
> cannot see why?
>
> $hash{s} = "T";
>
> if(exists($hash{s}) and $hash{s} ne "T" or $hash{s} ne "F") {
> print "inside\n";
> }
> else{  print "outside\n"; }
>
> the OUTPUT of this program prints   "inside".  But I want it to go INSIDE
> only if the key "s" exists in the hash, AND the value of $hash{s} DOES NOT
> equal "T" OR "F".Can anyone suggest what I might be doing wrong here?
> By the way, even if I comment out the line that contain
> $hash{s} = "T";,  the output still goes to "INSIDE".
>
> _
> Get your FREE download of MSN Explorer at http://explorer.msn.com




Re: fork

2001-06-18 Thread Jos Boumans

Make your life easy, don't fork...

on unix systems, it's ok... on NT it's horrible... it's unreliable, blocking,
resource hogging 
anyway, taht's my 2 bits.

enough flaming, now for an answer to your question.

if you want to fire off multiple processes, i seriously advice you to look into
POE (perl object environment) which is basicly a multi threader for perl
now, this will take a little bit to wrap your head around, and i'll be more then
happy to answer any questions that might come up.

take a look at the POE article, which you can read here:
http://www.perl.com/pub/2001/01/poe.html

and of course, all contents, faqs, docs etc are available from poe.perl.org

Hope this helps,

Jos Boumans

"Ronald J. Yacketta" wrote:

> Folks,
>
> Can someone shed some light on using fork to spawn 2+ simultaneous process?
> I am reading in allot of logfiles and splitting them into 3 separate arrays.
> Currently I am forking and doing a exec("egrep", "-c", "Err", @array1);
> (yes, ugly but it is just the beginning!) this works well
> if I were to exec one at a time, I would like to fork and send all three
> execs rolling at one. any clues?
>
> Regards,
> Ron




Re: AW: Problems with LWP::UserAgent and HTTP::Response

2001-06-18 Thread Jos Boumans

I'm being a bit lazy and just showing you a bit of code i wrote to fetch all
film info from imdb.com and comment on it a bit, to explain what goes on:

### config hash ###
my $href = {
 base  => 'http://www.imdb.com/',
 spage  => 'Find',
 ua  => 'Mozilla/4.74 [en] (Win98; U)',
 form  => 'select=All&for=',
};

### Set up the content ###
my $content = $href->{form} . $film;

# here, $film is the user input

### Set up the useragent ###
 my $ua = new LWP::UserAgent;
 $ua->agent( $href->{ua} );

 ### Set up the headers ###
 my $header = new HTTP::Headers(
   'Accept' => 'text/html',
   'content-length' => length($content),
   'content-type'   => 'application/x-www-form-urlencoded',
 );

 ### do the request, get the responce ###
 my $req = new HTTP::Request('POST', $url, $header, $content);
 my $res = $ua->request($req);

if you now print $res->as_string; you'll find that it holds the entire reply
from the server...

in short, you setup your content as follows (and you can try it if you like by
changing a 'post' to a 'get' on some page and see what is displayed in the
adresbar):
thing1=foo&thing2=bar&thing3=quux etc etc
be sure to define the header properly, as well as the useragent, which above
snippet shows you how to do...
and then it's as simple as doing the last step: do the request, get the
responce...

i hope this example shows you The Path To The Dark Side ;-)

Jos Boumans



Ela Jarecka wrote:

> Thanks, at least I know that I am sending my XML properly.. But I still get
> the same error message, so if anyone has more suggestions
> please write..
>
> Ela
>
> > -Ursprüngliche Nachricht-
> > Von: Tim Keefer [mailto:[EMAIL PROTECTED]]
> > Gesendet: Montag, 18. Juni 2001 15:46
> > An: Ela Jarecka; Beginners list (E-Mail)
> > Betreff: Re: Problems with LWP::UserAgent and HTTP::Response
> >
> >
> > Hi Ela,
> > The documentation for perl LWP agent seems sparse. I had a
> > difficult time
> > figuring out how to send multipart form-data. I'll share the
> > code with you that
> >
> > some shared with me. Hope it helps.
> >
> >
> >
> > require  LWP;
> > use  LWP::UserAgent;
> > use  HTTP::Request::Common;
> >
> > # Create a user agent object
> >
> >   $ua = new LWP::UserAgent;
> >   $ua->agent("AgentName/0.1 " . $ua->agent);
> >
> > # Pass request to the user agent and get a response back
> >
> >   my $res = $ua->request (POST $URL, Content_Type =>
> > 'form-data', Content => [
> >   login_id => $Username,
> >   login_passwd => $Password,
> >   name_auth=> $Prefix,
> >   fname=> ["$XML_Dir\\$XML_File"],
> >   operation=> 'Submit Batch File',
> > ]);
> >
> > # Check the outcome of the response - I guess we just file away
> >   if ($res->is_success) {
> > print "success!\n";
> > print $res->content;
> >if ( $res->content =~ /\QSUCCESS<\/H2>\E/i ) {
> > print "Deposit successful\n";
> > } else {
> >  print POSTLOG "Deposit FAILED.\n";
> >}
> >
> >   } else {
> > print " failed!\n";
> >}
> >
> >
> > Ela Jarecka wrote:
> >
> > > Hi,
> > > I am using the following code to send and XML document (
> > output.xml ) to a
> > > remote server:
> > >
> > > use strict;
> > > use LWP::Debug qw(+);
> > > use LWP::UserAgent;
> > > use IO;
> > >
> > > my $resp;
> > > $resp = 'response.xml';
> > > my $FILEH;
> > > open (FILEH, ) or die "Can't open file output.xml!\n";
> > >
> > > my $ua = LWP::UserAgent->new;
> > >
> > > #another version that i've tried...
> > > #my $h = new HTTP::Headers Date=> '2001-05-18';
> > > #my $req =
> > > HTTP::Request->new('POST','http://195.252.142.171:8008',$h,$FILEH);
> > >
> > > my $req = HTTP::Request->new(POST => 'http://195.252.142.171:8008');
> > >
> > > #$req->content_type('text/xml');
> > > $req->content($FILEH);
> > >
> > > my $res = $ua->request($req,$resp);
> > <here I've also
> > > tried

Re: more class stuff

2001-06-19 Thread Jos Boumans

What probably is going wrong here, is that you're using 'strict' and not
declaring the @Next array

so what you'd need to do is say:

my @Next; on the op of your module

probably tho, you'll have that array filled with something if you're
adding it to your constructor, and
probably, you have a function filling it... if my assumption is true,
then you'd want something like this:

sub new {


my @Next = function();
my $self = {


@Next,
@_,
    }
....
}

hope this helps,

Jos Boumans

PS, if you want to read more about namespaces etc, take a look at mjd's
tutorial about it here:
 http://perl.plover.com/FAQs/Namespaces.html


Nick Transier wrote:

> given this new function which acts as a constructor
>
> sub new {
>
> my $invocant = shift;
> my $class = ref($invocant) || $invocant;
> my $self = {
> Level => 999,
> Value => 999,
> Key => 999,
> @Next,
> @_,
> };
> return bless $self,$class;
>
> }
>
> I am getting the following error:
> "Global symbol @Next requires explicit package name at c:\"
>
> What does this mean?
>
> _
> Get your FREE download of MSN Explorer at http://explorer.msn.com




Re: Perl Security

2001-06-19 Thread Jos Boumans

depending on what you want, you could use rot13 (or twice ;-) or actually go about 
hard core and md5 them

you might want to take a look at the modules that come with the Digest bundle...
(search.cpan.org to look for them)

hope this helps,

Jos Boumans

jonathan wrote:

> Hi,
>
> I am insterested in creating a reusable module that allows my scripts to have 
>pretty good security. I just don't know how i would go about encrypting passwords. 
>Please help
>
> Thanks




Re: if statement

2001-06-21 Thread Jos Boumans

concider:
if(not ($foo == 1) ) { print "foo" }

it prints 'foo' just as expected... one can use 'not' without too many worries...

just remember 2 things:
! has higher precedence (ie, it 'binds tighter') so parentheses would be required
if you use ! here instead of 'not'
further more, ! is a unary operator used in combination with others as well ( !~
!= and friends). Here you CAN NOT just use 'not~' or 'not= '

hope this clears things up,

Jos Boumans


Tim Musson wrote:

> Hey Jos,
>
> I believe you have to use ! instead of "not" also...
>
> Wednesday, June 20, 2001, 6:05:39 PM, you wrote:
>
> JIB> i'd say, there is no 'like' operator...
>
> >> This isn't working for me.  Help please.  What is wrong with the second if
> >> statement
> >>
> >>   while ( ($timestamp, $report_type, $game_name, $data_name, $data_value)
> JIB> =
> >> $ora_sth->fetchrow_array)
> >> {
> >> if (($data_name eq 'min') || ($data_name eq 'time')) {$data_value =
> >> $data_value * 1440}
> >> if (not ($report_type like  'unique'))
> >> {   %myvar =(   $report_type,
> >> $data_name,
> >> $data_value,
> >> );
> >> $dname{$report_type} = $data_name;
> >> $dvalue{$report_type} = $data_value + $dvalue{$report_type};
>
> --
> [EMAIL PROTECTED]
> Using The Bat! eMail v1.53d
> Windows NT 5.0.2195 (Service Pack 1)
> Why is it that to stop Windows 2000, you still have to click on "Start"?




Re: Last page

2001-06-21 Thread Jos Boumans

Assuming you'll utilise the CGI module, this would work:

my $q = new CGI;
my $calling_page = $q->referer();

hth,

Jos Boumans

Stéphane JEAN BAPTISTE wrote:

> How can I get the URL which was calling my script (like
> document.referrer in Javascript)
>
> tks




Re: Another Regex Question

2001-06-22 Thread Jos Boumans

assuming i'm understanding correctly what you want, you might want to try this:

use strict;
use vars qw(@store);

open I, "input.txt" or die "oops: $!\n";

while(){ my @foo = /(.+?)\s+(.+?)\s{2,}(.+?)(?:\s{2,}(.+))?$/; push @store,
\@foo }

@store will now hold all matches on your input file, which are references to
arrays.
you can acces the references as follows, with the format of the array referred
to like this:

for(@store) {
$_->[0] # is the date
$_->[1] # is the time
$_->[2] # is either 'x quarter | sunrise, etc' or 'x feet'
$_->[3] # will hold the tide indication if there is one
}

you can print them out as a csv file as follows:
for(@store){ print ( (join ',', @$_) . "\n")}

this is a bit advanced regexes, but you can check out a tutorial on them at
www.sharemation.com/~perl/tut to give you an insight in them

hth,
Jos Boumans

Ken wrote:

> One thing to do would be to test for Tide in the line(Assuming all tide data
> ends with the word "Tide") right away...then do special stuff for each case
> in an if:
>
> if( /Tide$/ ) # If last word in line is Tide
> {
> }
> else # Must be lunar
> {
> }
>
> And just a note, if you're just going to put the date and time fields back
> together, don't seperate them in your pattern match.
>
> ($date, $time, ... ) = ^(\d+-\d+-\d+)\s+(\d+:\d+)...$/
>
> - Original Message -
> From: "Jack Lauman" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, June 21, 2001 3:48 PM
> Subject: Another Regex Question
>
> > I'm trying to create a CSV file from the text data below.  Lines
> > containing High and Low Tide data have 9 fields, lines having
> > sunrise/sunset and lunar data have 8 fields.
> >
> > How you differentiate between the two conditions?
> >
> > 2000-12-03 11:30 AM PST   9.39 feet  High Tide
> > 2000-12-03  4:15 PM PST   Sunset
> > 2000-12-03  7:56 PM PST   First Quarter
> > 2000-12-04  3:42 AM PST   2.81 feet  Low Tide
> > 2000-12-04  7:48 AM PST   Sunrise
> >
> > <->
> >
> > while () {
> >
> > ($year, $month, $mday, $hour, $minute, $am_pm, $tz, $height, $cond)
> > =
> > ^(\d+)-(\d+)-(\d+)\s+(\d+):(\d+)\s+([A-Z]{2})\s+([A-Z]{3})\s+
> > ([0-9A-Za-z-.\s]{11})\s+(\w+\s+\w+)/;
> >
> > $year and $started++;
> >
> > if ($cond) {
> > ($year, $month, $mday, $hour, $minute, $am_pm, $tz, $cond) =
> > /^(\d+)-(\d+)-(\d+)\s+(\d+):(\d+)\s+([A-Z]{2})\s+([A-Z]{3})\s+
> > ([A-Za-z\s])/;
> >
> > $date = "$year-$month-$mday";
> > $time = "$hour:$minute";
> > # Strip the leading and trailing spaces from $height
> > StripLTSpace($height);
> >
> > printf OUTFILE "%s\,%s\,%s\,%s\,%s\,%s\n",
> > $date, $time, $am_pm, $tz, $height, $cond;
> > }
> >
> > }
> >
> > $started or print STDERR "Didn't find a tides line";
> >
> > close(INFILE);
> > close(OUTFILE);
> > print STDERR "\n";
> >
> > 1;
> >




Re: output filenames as inputs

2001-06-22 Thread Jos Boumans

on that note, you can also use the getopt module, that lets you specify
switches like you're used to on any linux system as follows:

script.pl -i input.txt -o output.txt

look at perldoc getopt for a simple description

regards,
Jos Boumans

"Brett W. McCoy" wrote:

> On Thu, 21 Jun 2001, Pedro A Reche Gallardo wrote:
>
> > I am writing a program that creates a file and write some data into it
> > using the usual
> > open (OUT, ">filename") or die "can't open file '$file'\n"; way
> >
> > but, how can I make the program to create a file with a name that is
> > given as one of
> > the program inputs?
> >
> > In other words if I execute the program as it follows:
> >
> > program.pl input1 input2 filename.out
> >
> > program.pl should use take  input1 and input2, do the job, and write the
> > data to a new file named   "filename.out".
>
> All of the arguments to your program go into an array @ARGV.  You need
> only to get the args out of there.  $0, BTW, holds the program name used
> on the command-line.
>
> -- Brett
>http://www.chapelperilous.net/btfwk/
> 
> Oh wearisome condition of humanity!
> Born under one law, to another bound.
> -- Fulke Greville, Lord Brooke




Re: Pooling of objects and session data

2001-06-22 Thread Jos Boumans

if you say 'multi thread' you say POE
it's an excellent module that allows you to multithread in perl, you can read
some about it here
http://www.perl.com/pub/2001/01/poe.html

it will take you a bit to wrap your brain around it, but i assure you it's worth
it... of course, feel free to post questions about it to the list

you can get the latest download from either sourceforge.net or from poe.perl.org

i recently made a ppm for windows to install the latest version, which should be
available for public download shortly as well

hth,

Jos Boumans



Rajeev Rumale wrote:

> Dear Chas,
>
> Thank U very much for the suggestion. I am very  much convinced with this
> and would like to proceed in same direction.
>
> I perfer to develop the whole application in a single language, as far as
> possible.   Since I am quite new to Perl I would like to know if we can
> write multi-threaded programs in PERL.
>
> I would be greatfull if any one can suggest me some good online tutorial for
> the same.
>
> with regards
>
> Rajeev Rumale
>
> ~~~
> Rajeev Rumale
> MyAngel.Net Pte Ltd.,Phone  :
> (65)8831530 (office)
> #04-01, 180 B, The Bencoolen,   Email  :
> [EMAIL PROTECTED]
> Bencoolen Street, Singapore - 189648 ICQ: 121001541
> Website : www.myangel.net
> ~~~
>
> - Original Message -
> From: "Chas Owens" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, June 21, 2001 7:34 PM
> Subject: Re: Pooling of objects and session data
>
> > On 21 Jun 2001 15:16:19 +0800, Rajeev Rumale wrote:
> > > Hi,
> > >
> > > I need to know if there is any easiest way to keep session data or
> object
> > > accross the scripts.
> > >
> > > Basically I would like to pool Database connections so that Parrallel
> > > running scripts don't open multiple connection with the database.
> > >
> > > with regards
> > >
> > 
> >
> > The only way I can think of to achieve this would be to write a daemon
> > process in perl (or any other language for that matter) that would be
> > responsible for accessing the database based on requests (through IPC,
> > BSD style sockets, files being placed in certain directories, smoke
> > signals, whatever) and returning the data (again through some
> > communication method).  I have seen production systems (not that I
> > recommend this) that had a special set of directories named /work/in and
> > /work/out.  Shell scripts would print sql statements to files in the
> > /work/in dir and a C daemon would: pick them up, see if they were from
> > the right owner, discard the invalid files, run the valid ones and put
> > the results in the /work/out dir.  Filenames were based on the pid of
> > the shell script.  The shell script would then sit waiting for a file
> > with its pid to show up in the /work/out directory.
> >
> > In general, if you are having to create hacks like this the problem is
> > most likely you choice of RDBMS.  Enteprise level databases generally
> > don't have a problem with thousands of concurrent connections.
> >
> > --
> > Today is Boomtime, the 26th day of Confusion in the YOLD 3167
> > Or is it?
> >
> >
> >




Re: compilation errors in win98

2001-06-22 Thread Jos Boumans

it's not a perl problem, it's an m$ 'feature' (mainly found under NT lacking
some service packs/upgradss)
for example, on win98 i never had that problem, neither do i have it on
win2k or on my fully sp'd and upgraded winnt4 box
however on a few nt boxes having NOT had all service packs, i'm stuck with
supplying the window with a screen size it should retain and it refuses to
buffer beyond that...
thanks to darth gates of course...

Jos

james crease wrote:

> In message <[EMAIL PROTECTED]>,
> Aaron Craig <[EMAIL PROTECTED]> writes
> >At 21:49 20.06.2001 +0100, james crease wrote:
> >>I have a perl script which generates many compilation errors which
> >>scroll off the DOS window perl is running in. How do I capture (or
> >>recover) the lines that have scrolled away?
> >>--
> >>james crease
> >>
> >
> >Use EditPlus2 as your editor.  You can capture perl output in an output
> >window inside the program, copy and paste it, as well as double click a
> >line number and get taken directly to that line in your code, among
> >many other helpful features.
> >
> >
> Thanks for that. I've just tried it and it looks well worth the bucks.
>
> I still think it odd that the distribution of Perl for Windows doesn't
> mention this problem when using the standard M$ command window.
>
> --
> james crease
> http://wocediu.org   Tel. +1 302 645 4240
> http://www.codata.orgTel. +44 1608 642335




Re: How to start

2001-06-22 Thread Jos Boumans

look in the archives, i replied to a few posts already that had the same
problem

the thread is called "LWP " -something...
it shows you how to check all pages on a site for aliveness

hth,
Jos Boumans

Joel Divekar wrote:

> Hi There
>
> I have been asked to write a program to check if links on our website are
> live. I have never tried it and I don't know how to start. I am looking for
> some guidelines.
>
> Thanks
>
> Regards
>
> Joel
>
> --
> QuantumLink Communications, Bombay, India




Re: to delete only one line

2001-06-22 Thread Jos Boumans

maybe there's a more elegant way, but this will work:

open I, "input.txt";
open O, "output.txt";

while() { print O unless $. == $foo }

where $foo is the line number you dont want printed.

hth,

Jos Boumans

Stéphane JEAN BAPTISTE wrote:

> HI.
>
> I'm looking for a method to delete the line number  x  into a file.
>
> Is it simply possible ?
>
> tks




Re: What's a good pre-built binary Perl for Windoze?

2001-06-22 Thread Jos Boumans

www.activestate.com is where you should look

hth,
Jos Boumans

Jude Suszko wrote:

> I'd like to get my feet wet with a decent pre-built binary Perl
> before I try building my own from sources.  At the moment
> I'm stuck with a Win98 SE platform to run it on.  I found several
> possibilities at www.cpan.org , but since I'm a Perl beginner
> I'm not well prepared to judge their relative merits.
>
> I would appreciate any advice that would help me make an
> appropriate choice for my initial learning.  I am particulary
> interested in using Perl to connect directly to email and  news
> servers to retrieve messages, so I'll want a Perl that has good
> networking support.  I do have considerable experience
> programming in other languages for both Windoze and Unix, and
> I have read the RFC's that define the SMTP, POP and NNTP
> client/server interactions.
>
> Jude




Re: DBI Module

2001-06-22 Thread Jos Boumans

try reading this article:

http://www.perl.com/pub/1999/10/DBI.html

hth,

Jos Boumans

Diego Riaño wrote:

> Hi Everybody
>
> I am trying to use de perl DBI module to use a MySQL database.  I want to know
> where can I find a tutotial or maybe a HowTo (I do not know?) about perl DBI
> module?
> Could someone help me?
>
> Thanks in advances
>
> Diego Riano




Re: Help please (any one)

2001-06-25 Thread Jos Boumans


Hey, you might want to concider reading up on some tutorials here:
http://www.sharemation.com/~perl/tut

both a regexp as a perldata tutorial are on the site along with a few
more

hth,

Jos Boumans


> > 1. If we are after field 15, how comes you used field 14 in your
> > answer please!   *if ($fields[14] =~
> /M/)***
>
> The Nth element of an array is offset N-1.
>
> So $foo[0] is the first element, $foo[1] is the second
> and so on. This is a common practice in computing
> languages.
>

> > 2. Were could I read up on 'regexp' please!
>
> At a shell prompt or command line:
>
> perldoc perlre
>
> More generally:
>
> http://learn.perl.org/




Re: I need some help ...

2001-06-25 Thread Jos Boumans

well, first of all you want to take this open statement out of the 'for loop' and
declare it before the loop starts:
$resultat="c:\\resultat.txt";
open (RESULT, ">>$resultat");

not sure why the file existance check isn't working.. you might want to add some
print statements, or maybe try and open such a file manually etc to see if you
have specified all locations properly

hth
Jos Boumans

[EMAIL PROTECTED] wrote:

> I want to do this :
>
> I have a file where there are 256 servers names, one server name per line.
> I want to read all lines to take the names of all servers to check the size of
> some files ...
>
> I tried this but it's not working like I want .. :
>
> $serveur="c:\\perl\\bin\\liste.txt";
> open (SERV, "$serveur");
> @serveurs = ;
> close (SERV);
>
> foreach $ligne (@serveurs)
> {
> $fichier="$ligne\\f\$\\cmd\\active.vbs";
> $fichier2="$ligne\\f\$\\universe\\data\\exp\\upr\\upe_dsms.000";
> $fichier3="$ligne\\f\$\\universe\\data\\exp\\upr\\upe_psms.000";
> $fichier4="$ligne\\g\$\\common\\bin\\upecbootnt.cmd";
>
> if (-e $fichier)
> {
> $size=(stat $fichier)[7];
> print RESULT"$fichier fait $size octets\n";
> }
> else
> {
> print RESULT"$fichier inexistant \n";
> }
>
> if (-e $fichier2)
> {
> $size2=(stat $fichier2)[7];
> print RESULT"$fichier2 fait $size2 octets\n";
> }
> else
> {
> print RESULT"$fichier2 inexistant \n";
> }
>
> if (-e $fichier3)
> {
> $size3=(stat $fichier3)[7];
> print RESULT"$fichier3 fait $size3 octets\n";
> }
> else
> {
> print RESULT"$fichier3 inexistant \n";
> }
>
> if (-e $fichier4)
> {
> $size4=(stat $fichier4)[7];
> print RESULT"$fichier4 fait $size4 octets \n";
> }
> else
> {
> print RESULT"$fichier4 inexistant \n";
> }
>
> $resultat="c:\\resultat.txt";
> open (RESULT, ">>$resultat");
>
>  }
>
> With this i have some probleme because when i try to do store the data in the
> file c:\resultat.txt it's taking only the last server name in the list.txt
> and is not checking the size of the files ...
>
> If someone can help me ...
>
> Thanx




Re: Is this correct

2001-06-25 Thread Jos Boumans

You could do 2 things:

either say:
if ($fields[14] =~ /[AM]/)

or

if ($fields[14] =~ /M|A/)

the first uses a character class, the second a simple boolean 'or'

hth,

Jos Boumans



Govinderjit Dhinsa wrote:

> One question please,   I want to search for  M and A, at the moment I am
> only searching for M (as below)
> if ($fields[14] =~ /M/)
>
> Would the example below be correct please;
> if ($fields[14] =~ /\M\|\A\/)
>
> Your help is much APPRECIATED
>
> > Kind Regards,
> > GD
> >




Re: types of datas

2001-06-25 Thread Jos Boumans

I think you're going to need to send us a bit of code to go with this,
because i'm really not sure what it is you're trying to do...
"I have a loop (while) with a value which have different values."

i can guess for a few explenations but code is probably easier =)

Jos Boumans


Stéphane JEAN BAPTISTE wrote:

> Hi!
>
> I get a value from a URL and I put it into a variable.
> I have a loop (while) with a value which have different values.
> The problem is that when I compare the first and the second value: If
> they're really equals, the program say they are'nt.
>
> Is ther a function to convert a value into an integer ?
>
> tks
>
> (sorry for my english :-) )




Re: Reading Code

2001-06-25 Thread Jos Boumans

This wouldnt, by chance, be your homework now would it?


[EMAIL PROTECTED] wrote:

> Can anyone tell me how to read this bit of code in english ?
>
> > sub accum_cycle_count
> > {
> >  # @acc_fields are:
> >  #0 - Cycle Counting Order
> >  #1 - Warehouse
> >  #2 - Location
> >  #3 - Item Code
> >  #4 - Container
> >  #   5 - Lot Code
> >  #   6 - Storage Unit
> >  #   7 - Counted Inventory
> >  #8 - Counting Date
> >
> >  local(@acc_fields) = @_;
> >  return(-810) if ( $acc_fields[0] == 0 || $acc_fields[0] eq '' );
> >  return(-811) if ( $acc_fields[1] eq "" );
> >  return(-812) if ( $acc_fields[2] eq "" );
> >  return(-813) if ( $acc_fields[7] < 0 );
> >  $acc_fields[8] = &get_date if ( $acc_fields[8] eq '' );
> >
> >  return(&send_ddc("tdilc5110b000","accum_cycle_count",@acc_fields));




Re: Reading Code

2001-06-25 Thread Jos Boumans

Try www.sharemation.com/~perl/tut
those are some beginners tutorials i wrote that should explain most of your
questions

hth,

Jos Boumans

[EMAIL PROTECTED] wrote:

> I am totally new to Perl and I have no training in perl at all and I was
> asked to look at tons of code and basically translate to english.I have
> an idea what this code does but it small bits like @_; that I havn't a clue
> about and their doesn't seem to be any really good sites for total
> beginners.
>
>
> Jos Boumans
>  eur.nl>  cc: [EMAIL PROTECTED]
>  Subject: Re: Reading Code
> 25/06/01
> 15:52
>
>
>
> This wouldnt, by chance, be your homework now would it?
>
> [EMAIL PROTECTED] wrote:
>
> > Can anyone tell me how to read this bit of code in english ?
> >
> > > sub accum_cycle_count
> > > {
> > >  # @acc_fields are:
> > >  #0 - Cycle Counting Order
> > >  #1 - Warehouse
> > >  #2 - Location
> > >  #3 - Item Code
> > >  #4 - Container
> > >  #   5 - Lot Code
> > >  #   6 - Storage Unit
> > >  #   7 - Counted Inventory
> > >  #8 - Counting Date
> > >
> > >  local(@acc_fields) = @_;
> > >  return(-810) if ( $acc_fields[0] == 0 || $acc_fields[0] eq '' );
> > >  return(-811) if ( $acc_fields[1] eq "" );
> > >  return(-812) if ( $acc_fields[2] eq "" );
> > >  return(-813) if ( $acc_fields[7] < 0 );
> > >  $acc_fields[8] = &get_date if ( $acc_fields[8] eq '' );
> > >
> > >  return(&send_ddc("tdilc5110b000","accum_cycle_count",
> @acc_fields));




Re: removing ASCII characters from array

2001-06-25 Thread Jos Boumans

and for esthetics:

print join ',' @array;

timtowtdi =)

John Edwards wrote:

> $data = "Sat Jun 23 01:07:31 2001,bytes=32,time=192ms,TTL=239";
>
> @array = $data =~ /=(\d*)/g;
>
> print "$array[0], $array[1], $array[2]\n";
>
> -Original Message-
> From: Alex Nelson [mailto:[EMAIL PROTECTED]]
> Sent: 25 June 2001 17:07
> To: [EMAIL PROTECTED]
> Subject: removing ASCII characters from array
>
> I wrote a simple Perl script that removes a line from a file then writes it
> to another file.  The result that is printed to the other file  is:
> Sat Jun 23 01:07:31 2001,bytes=32,time=192ms,TTL=239
> The last three elements are written from an array.  What I would like to do
> is only print the numbers to the file. In other words instead of bytes=32,
> time=192ms,TTL=239 I would like to write 32,192,239.
> Can someone help me out?
>
> Thanks!!!
>
> --Confidentiality--.
> This E-mail is confidential.  It should not be read, copied, disclosed or
> used by any person other than the intended recipient.  Unauthorised use,
> disclosure or copying by whatever medium is strictly prohibited and may be
> unlawful.  If you have received this E-mail in error please contact the
> sender immediately and delete the E-mail from your system.




Re: Finding @INC

2001-06-27 Thread Jos Boumans

Please use the the 'use lib' pragma, rather then fiddling with @INC

concider:
use lib (../foo);

rather than:

BEGIN: { push @INC, '../foo' }

perldoc lib for more info

hth
Jos Boumans


Maxim Berlin wrote:

> Hello Dennis,
>
> Tuesday, June 26, 2001, Dennis Fox <[EMAIL PROTECTED]> wrote:
>
> DF> My difficulty is that I don't understand how to modify @INC to
> DF> include the non-standard locations, so that I don't have to have the user
> DF> supply commandline arguments each time the script is needed.
>
> example:
>
> if ( $OS ne "NT" )
> {
>   BEGIN { unshift(@INC,"/usr/local/etc"); }
>   require "config.backup.pl";
> }
>
> Best wishes,
>  Maximmailto:[EMAIL PROTECTED]




Re: Finding @INC

2001-06-27 Thread Jos Boumans

because push @INC is a runtime statement,
use lib is a compile time statement

meaning you'll be alerted if the dir doesnt exist, or something else goes wrong at the
moment you start your script, rather then it dying half way when not findin a file.


hth
Jos Boumans

Maxim Berlin wrote:

> Hello Jos,
>
> Wednesday, June 27, 2001, Jos Boumans <[EMAIL PROTECTED]> wrote:
>
> JB> Please use the the 'use lib' pragma, rather then fiddling with @INC
>
> JB> concider:
> JB> use lib (../foo);
>
> JB> rather than:
>
> JB> BEGIN: { push @INC, '../foo' }
>
> JB> perldoc lib for more info
>
> according to perldoc lib:
>
>use lib LIST;
>
>is almost the same as saying
>
>BEGIN { unshift(@INC, LIST) }
>
>For each directory in LIST (called $dir here) the lib mod-
>ule also checks to see if a directory called $dir/$arch-
>name/auto exists.  If so the $dir/$archname directory is
>assumed to be a corresponding architecture specific direc-
>tory and is added to @INC in front of $dir.
>
> for my configs, i don't need (and don't have) $dir/$archname/auto directories, so i
> still use
>
> >>   BEGIN { unshift(@INC,"/usr/local/etc"); }
>
> am i wrong?
>
> Best wishes,
>  Maximmailto:[EMAIL PROTECTED]




Re: to delete the trailing newline

2001-06-27 Thread Jos Boumans

you might want to try to use 'chomp' on your variable... this function
is specifically there to 'chomp off' trailing newlines

you'll often see it used as:

open FH, 'foo.txt';
while(){
chomp; #remove trailing newline
do something
}

perldoc -f chomp for details

hth,

Jos Boumans


Stéphane JEAN BAPTISTE wrote:

> I have a variable and I want to write it into a textarea (HTML). The
> problem is when I look at the textarea in my HTML page, there is the
> text I want, plus a trailing newline.
>
> How can I delete this.
>
> My variable:
> "$texte="wazaa";"
>
> In textarea:
> "wazza
> "
>
> tks
>
> Sorry for my english
>
> steph




Re: Incrementing Strings

2001-06-27 Thread Jos Boumans

> How do you mean?

concider:
if ('a' == 'b') { print "foo" } # this will print 'foo', seeing 'a' and 'b' both yield 
'1' in numeric
context here.

however

$x = 'a';
print $x + 4;

will print '4';

Jos Boumans


> Converting 'a' to a number gives 0.
>
> --
> Paul Johnson - [EMAIL PROTECTED]
> http://www.pjcj.net




Re: Incrementing Strings

2001-06-27 Thread Jos Boumans

ok, long day, let me write it like it IS
 concider:
 if ('a' == 'b') { print "foo" } # this will print 'foo', seeing 'a' compared to 'b'  
yields '1' even in
numeric context here
(ie, the RETURN value of the compare, not the representation of the characters)

sorry for the confusion and thanks for poining out the mistake

Chas Owens wrote:

> On 27 Jun 2001 17:45:18 +0200, Jos Boumans wrote:
> > > How do you mean?
> >
> > concider:
> > if ('a' == 'b') { print "foo" } # this will print 'foo', seeing 'a' and 'b' both 
>yield '1' in numeric
> > context here.
>
> You mean 0 not 1 don't you?
>
> >
> > however
> >
> > $x = 'a';
> > print $x + 4;
> >
> > will print '4';
> >
> > Jos Boumans
> >
> >
> > > Converting 'a' to a number gives 0.
> > >
> > > --
> > > Paul Johnson - [EMAIL PROTECTED]
> > > http://www.pjcj.net
> >
> >
> --
> Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
> Kallisti!




Re: MYSql (fwd)

2001-07-02 Thread Jos Boumans

http://www.perl.com/pub/a/1999/10/DBI.html

this has an excellent article about starting with DBI

hth
Jos Boumans

Ryan Gralinski wrote:

> is there any documentation on using perl to access Mysql databases?
>
> Ryan




Re: using the backspace \b character

2001-07-02 Thread Jos Boumans

i think what you really want to use then is chomp or a regexp..
or you'd have to say

print "hello\n"
print "\b"
print "world"

etc

hth,

Jos Boumans

Bob Mangold wrote:

> Hello,
>
> I know I can use the backspace character to overwrite previous characters and
> the such, but can I use it to backup a few lines. Lets say I write:
>
> print "hello\n";
> print "world";
>
> I know that:
>
> print "\b";
> print "a";
>
> will replace the 'd' in 'world' with an 'a', but is there away to backspace
> over both lines. I guess what I really need to do is backspace over an '\n'. Is
> that possible?
>
> -Bob
>
> __
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/




Re: A Split Question

2001-07-03 Thread Jos Boumans

on a side note, if you CAN use perls internal char classes you really want to do
that
firstly to avoid typos, secondly, they're much faster.
and if you're using the same regexp over and over again, you *might* want to
concider building it outside the loop with the /o switch

(this all performace bits of course)

so in short, try:
my ($d,$m,$y) = $string =~ /(\d+)(\D+)(\d+)/

\D is perfectly safe here, but tehn again, we know context... =)

hth,

Jos Boumans




> > I stand by my reply to this post. Sure, unpack is quicker. But if you use
> > regex, i always prefer to use my own defined regex's
> >
> > my $dateis = "2Jul2001";
> > my ($date,$month,$year) = $dateis =~ /([0-9]+)([A-Za-z]+)([0-9]+)/;
> >






Re: RTF to HTML or text conversion

2001-09-25 Thread Jos Boumans

Jonathan Macpherson wrote:
> 
> Hi;
> 
> Im trying to write a perl script that will pull newspaper stories out of a
> sybase database and post them on the web. I can connect to sybase, pull
> stories, but they are in Rich Text Format. I would like to convert the RTF
> to text or html. Could anyone point me in the right direction ?
> 
> Thanks
> jon

-- 
Do a search for 'RTF' on search.cpan.org
there are quite a few modules that are looking interesting in regard to
your problem.. perhaps somebody already invented the wheel for you

regards,
Jos

-- How do I prove I am not crazy, to people who are?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: to reach an URL

2001-05-07 Thread Jos Boumans

Stephane, what you are looking for is the LWP module.. it comes standard
with any ActiveState perl release but is not standard with Linux (or at
least RedHat)
try search.cpan.org if you need to obtain and look for "LWP"
you'll find the documentation very informational.

Regards,

Jos Boumans

Stéphane JEAN BAPTISTE wrote:

> I'm looking for a command which permit to reach an URL from the script.
>
> tks
>
> PS: sorry for my english :-)




Re: FW: delete files

2001-05-15 Thread Jos Boumans

Chris,

You might want to start by reading the documentation for 'opendir' (perldoc -f
opendir) or view it online here:
http://www.perl.com/pub/doc/manual/html/pod/perlfunc/opendir.html

Now, you can then use a simple regexp (perldoc perlre) to see if you have any
all-uppercase characters in your file names
something like
if (/^[A-Z]+$/) {
do_your_stuff;
}

Try it out, see how far you get and feel free to ask if you get stuck!

Kind regards,

Jos Boumans

"Porter, Chris" wrote:

> Any ideas???
>
> >  -Original Message-
> > From: Porter, Chris
> > Sent: Tuesday, May 15, 2001 9:20 AM
> > To:   '[EMAIL PROTECTED]'
> > Subject:  delete files
> >
> > Hello,
> >
> > How are you?  Sorry to bother.  I am very new to perl so please bear with
> > me.  I want to create a script that deletes uppercase words from a
> > directory using the unlink command.  Probably a very simple thing to do
> > but unsure how to approach.  I would like this script to be run once a day
> > (I'll take care of that by putting in the crontab).  This particular
> > directory fills up with un-needed print files that have been getting
> > removed manually for a while.  I want to simplify that.  I hope I
> > described my problem okay.  Actually, the files that are being deleted are
> > users last names, if that helps any.
> >
> > Thank you very much in advance.  I hope you can help.
> >
> > Sincerely,
> >
> > Chris Porter
> > [EMAIL PROTECTED]




Re: New to Perl

2001-05-15 Thread Jos Boumans

Well, of course everyone has their own idea of 'best', so i'll just give
you mine =)

"Learning Perl" by randal schwartz is very good to start with, it teach
many of the basics (its the so-called 'llama' book)
and after that, you might want to try "Programming Perl" by Larray Wall
(thats the 'Camel' book)
Both published by O'reilly...

If you want some tutorials, you might want to try MJD's site at
perl.plover.com or www.sharemation.com/~perl/tut for some really basic
tutorials.

Of course learn.perl.org also has some advice on which books to read and
such.

Hope that helps,

Jos Boumans

RS wrote:

> Im new to Perl/programming. I know HTML pretty well
> but would like to get into Perl.  What is the best
> book I can get for a beginner?
>
> =
> **R.S.** (pronounced R-dot S-dot)
> "Look at all the pretty C shells"
>
> __
> Do You Yahoo!?
> Yahoo! Auctions - buy the things you want at great prices
> http://auctions.yahoo.com/




Re: passing part of an array to a function

2001-05-15 Thread Jos Boumans

Ok, let's hope i can shed some light on this situation.

What's going wrong is that you are using a reference to an array slice...
not sure why that's a big problem but it is apparently.
in your case, there are 2 solutions:

1) do something like the following if you insist on using references

@foo = (1,2,3,4,5,6,7,8,9);
@baz = @foo[1..5];
bar(\@baz);

sub bar {
my $aref = shift;
for (@$aref) {print}
}

#which will nicely print '23456'

2) Seeing your passing an array slice to the sub, there is no real need for
references, so you could do something like this:
  @foo = (1,2,3,4,5,6,7,8,9);
   bar(@foo[1..5]);

sub bar {
 my @a = @_;
 for (@a) {print}
}

 #which will nicely print '23456'

I hope this will solve your problem for now...

Regards,

Jos Boumans

Paul wrote:

> --- Gary Stainburn <[EMAIL PROTECTED]> wrote:
> > Hi all,
>
> Hi, Gary. =o)
>
> > I have an array that holds the source code to a cobol program.  I
> > then have a number of integers that hold the subscript for section
> and
> > division changes.
> > I then have subs that parse sections of that array. e.g. a sub called
> > file_control will parse the file-control section and extract
> > information from the file select statements.
>
> Actually, that sounds like a pretty cool arrangement.
>
> > At the moment my code works because I store the array as a global
> > variable and pass to the sub the start and end array elements.
>
> Ah. A reasonable way to deal with the circumstance, but globals are
> commonly considered "bad", lol
>
> > I want to now make my code a bit more flexible and simply pass a
> > reference to the section I require.  The code I've tried may give a
> > better idea of what i mean.  when I run my code I get the following
> > error on the 'foreach (@$lines)' line
> >
> > Not an ARRAY reference at ./s line 109.
>
> Hmmlooking below, the cause is not immediately apparent to me.
> In fact, what you've done was the first solution that popped into my
> mind. (Somebody please explain the problem with that for me, too?)
>
> > I could simply pass the array sections to the subroutines but that
> > would be very inefficient - the procedure divisions of some the
> > programs are 5k lines - hence the attempt to reference.
>
> I think this is a good candidate for an object.
> Try this:
>
>   my $obj = {};
>   $obj->{CODE} = [ @lines ];
>
> now you can undef @lines to recoup that memory (though Perl probably
> won't give it back.)
>
> Then you can do neat things like putting the section indexes on the
> object also:
>
>   $obj->{FILECTL} = $fc_ndx;
>
> Then all you have to do is pass the object to each function.
>   file_control($obj);
>
> and they can grab the pieces they need off it.
>
>  sub func {
>  my $obj = shift;
>  for my $ndx ($obj->{SECTION1} .. ($obj->{SECTION2}-1)) {
>  # code for section
>  }
>  }
>
> try looking at the perldocs for
> perlref
> perlreftut
> perlobj
> perlboot
> perltoot
> perltootc
>
> Paul
>
> (Original code left below for reader's convenience)
>
> > my @lines=( # simulate read cobol file
> > 
> > "   file-control.\r\n",
> > "   select jobfile\r\n",
> > "   assign external das1\r\n",
> > "   organization is indexed\r\n",
> > "   access dynamic\r\n",
> > "   record key is job-jf-key\r\n",
> > "   file status is w01-jobf-stat\r\n",
> > "   lock mode is automatic with rollback.\r\n",
> > ...
> >
> > &file_control(\@lines[10..36]); # pass pointer to array elements
> > 10-36
> >
> > sub file_control() {
> >   my ($lines)=@_;
> >   foreach (@$lines) {   # process each line in array section
> > next if (/^  [\/\*]/);
> > 
>
> __
> Do You Yahoo!?
> Yahoo! Auctions - buy the things you want at great prices
> http://auctions.yahoo.com/




Re: perl newbie

2001-05-15 Thread Jos Boumans

A quick glance at your code shows a missing ; at the end of
$refresh=$q->param('refresh')

check if that's not the problem first!

Regards,

Jos Boumans

Peter wrote:

> hi,
>
>  i just started learning perl and i'm kinda stuck
>
>  i want to pass two querystrings from an asp page to a perl script.
> ie  ..cgi?&tickers=yyy&refresh=x
>
>  the script accepts the tickers by itself, but when i try to add the refresh
> it says
> i have a compile error, here's how its coded...
>
>  so what it does is grabs the ticker name and gets quotes for itthen
> redirects
> me back to the page i requested the info from with the new data.
>
> ---
> my $q = new CGI;
>
> if ($q->param('tickers')) {
> my @tickers = split ' ', $q->param('tickers');
> init;
> getquote $q, ($tickers[0]);
> }
>
> $refresh=$q->param('refresh')
> ---
>
> thanks,
> pete




Re: perl newbie

2001-05-15 Thread Jos Boumans

Ok, it's hard to help you without knowing the exact error that is generated.
So it would help if you posted that too

furthermore, that bit of code seems to be in order then, altho the first & in
..cgi?&tickers=yyy&refresh=x shouldnt be there...

Regards,

Jos Boumans

Peter wrote:

> yes there is a semicolon there.
>
> -Original Message-
> From: Jos Boumans [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 15, 2001 9:39 AM
> To: Peter Lee
> Cc: [EMAIL PROTECTED]
> Subject: Re: perl newbie
>
> A quick glance at your code shows a missing ; at the end of
> $refresh=$q->param('refresh')
>
> check if that's not the problem first!
>
> Regards,
>
> Jos Boumans
>
> Peter wrote:
>
> > hi,
> >
> >  i just started learning perl and i'm kinda stuck
> >
> >  i want to pass two querystrings from an asp page to a perl script.
> > ie  ..cgi?&tickers=yyy&refresh=x
> >
> >  the script accepts the tickers by itself, but when i try to add the
> refresh
> > it says
> > i have a compile error, here's how its coded...
> >
> >  so what it does is grabs the ticker name and gets quotes for itthen
> > redirects
> > me back to the page i requested the info from with the new data.
> >
> > ---
> > my $q = new CGI;
> >
> > if ($q->param('tickers')) {
> > my @tickers = split ' ', $q->param('tickers');
> > init;
> > getquote $q, ($tickers[0]);
> > }
> >
> > $refresh=$q->param('refresh')
> > ---
> >
> > thanks,
> > pete




Re: perl newbie

2001-05-15 Thread Jos Boumans

I'm afraid that error is too general to make any comments about... maybe it's
more precise if you run the script on the command line?

and if you want to add a refresh option, you need not use javascript per se... a
simple meta refresh tag might suffice in this case.

anyway, i'm afraid i cant help you as such... i'd need to look at the entire
code for that i think

Regards,

Jos Boumans


Peter wrote:

> i corrected the & before tickers.
>
> when i append the &refresh=x, i get a software error:
> Execution of cgi aborted due to compilation errors
>
> without the &refresh=x, the script runs fine.
>
> what i'm doing with the refresh value is attaching it to a javascript
> redirect window which
> sends the value to an asp page.  ie.  .asp?refresh=x&symbol=.
>
> thanks,
> peter
>
> -Original Message-
> From: Jos Boumans [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 15, 2001 9:45 AM
> To: Peter Lee
> Cc: [EMAIL PROTECTED]
> Subject: Re: perl newbie
>
> Ok, it's hard to help you without knowing the exact error that is generated.
> So it would help if you posted that too
>
> furthermore, that bit of code seems to be in order then, altho the first &
> in
> ..cgi?&tickers=yyy&refresh=x shouldnt be there...
>
> Regards,
>
> Jos Boumans
>
> Peter wrote:
>
> > yes there is a semicolon there.
> >
> > -Original Message-
> > From: Jos Boumans [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, May 15, 2001 9:39 AM
> > To: Peter Lee
> > Cc: [EMAIL PROTECTED]
> > Subject: Re: perl newbie
> >
> > A quick glance at your code shows a missing ; at the end of
> > $refresh=$q->param('refresh')
> >
> > check if that's not the problem first!
> >
> > Regards,
> >
> > Jos Boumans
> >
> > Peter wrote:
> >
> > > hi,
> > >
> > >  i just started learning perl and i'm kinda stuck
> > >
> > >  i want to pass two querystrings from an asp page to a perl script.
> > > ie  ..cgi?&tickers=yyy&refresh=x
> > >
> > >  the script accepts the tickers by itself, but when i try to add the
> > refresh
> > > it says
> > > i have a compile error, here's how its coded...
> > >
> > >  so what it does is grabs the ticker name and gets quotes for itthen
> > > redirects
> > > me back to the page i requested the info from with the new data.
> > >
> > > ---
> > > my $q = new CGI;
> > >
> > > if ($q->param('tickers')) {
> > > my @tickers = split ' ', $q->param('tickers');
> > > init;
> > > getquote $q, ($tickers[0]);
> > > }
> > >
> > > $refresh=$q->param('refresh')
> > > ---
> > >
> > > thanks,
> > > pete




Re: foo bar?

2001-05-16 Thread Jos Boumans

it comes from the vietnam war iirc (watch full metal jacket if you want some
'insight' ;-)

it is originally 'fubar' or Fucked Up Beyond Any Recognition (pardon the expletives)

so, us perl geeks use 'foo' and 'bar' as standard variable names in examples now...

So much for a short stroll thru history =)

Regards,

Jos Boumans

ber kessels wrote:

> Hi,
>
> Maybe a silly question but where does foo-bar or foobar refer to?
>
> Everyone uses it in perl, but I cannot find the origin of it.
> I am not english (I am Duch), but even my english teacher didn't know it, he had
>  even never heard of it.
>
> I am just curious that's all.
>
> Thanx for reading
>
> Ber
>
> _
>   STRUIKDUIK IS VERNIEUWD
>   (er staat nu dus iets)
>   http://struikduik.tripod.com
>
>   telefoon: ++31625181320
>   adres: Capadosestraat 51
> 2623 AD
> Den Haag
>
> Get your wireless addressbook at room33. http://room33.com




Re: #!/usr/local/bin/perl

2001-05-16 Thread Jos Boumans

Actually, its something YOU need to tell your server, so it knows where perl is

the #! is called a shebang and basicly tells your computer where to find perl

an example

#!c:\perl\bin\perl is what you should type if you installed perl on a wintendo
in c:\perl (bin\perl is simply perls subdir to put the interpreter)

so: #!your\path\to\perl will tell your machine what it needs to know...
especially important for .cgi scripts and the like!

Regards,

Jos Boumans

Kevin Williams wrote:

> I'm just starting out and I've come across a line of code that no book seems
> to explain. Its seems that I should put #!/usr/local/bin/perl at the start
> of every script but it doesn't work for my script. How do I find out what
> the correct line should be? I'm writing a guest book so is it something that
> my server would need to tell me?




Re: Compile problem

2001-05-16 Thread Jos Boumans

Kristi:

the problem is that your @INC array (which holds all the directories the perl
interpreter will look for files),
hold only some temp folder in your my documents directory.

ok, this is BAD =)

there are 2 solutions to this problem:
1) the hard way: read perldoc perlrun and perldoc perlfaq8 on how to modify
your @INC array permanently
2) the easy way: reinstall your AS perl distro which should fix the problem for
you

I hope this fixes your problem!

Regards,

Jos Boumans

Goodman Kristi - kgoodm wrote:

> > I have installed Perl 623 and PDK 210.  Almost everytime I try to compile
> > one of my old programs, I get this error:
> >
> > Can't locate File/Glob.pm in @INC (@INC contains:
> > C:\DOCUME~1\kmgood\LOCALS~1\Te
> > mp\0830\ .) at ibtdabilitec.pl line 205.
> > BEGIN failed--compilation aborted at ibtdac.pl line 205.




Re: .dat

2001-05-16 Thread Jos Boumans

.dat is used by a myriad of program to indicate it holds some form of data for
the program: .dat(a)
among the heavy users is SPSS and its friends...
bad part is that more then one kind of program uses it, and i've even seen perl
modules relying on a .dat file for them, so there's no way to exclusively tell
you where that file belongs to.

On a side note, should i be adressing this mail to Kevin or Sally?

regards,

Jos Boumans

Kevin Williams wrote:

> Does anybody know what type a file with a .dat extension is?
>
> I've come across them as backup files, but have found one in a perl script
> and I'm fairly sure it's not a back up file. It's in a guestbook script, and
> I'm sure it's the file that would contain the submitted guest book entries,
>
> Thanks,
>
> Sally




Re: Variable Creation

2001-05-17 Thread Jos Boumans

Alberto,

let's start with something very basic:
DO NOT use variables as variable names!

seeing MJD already wrote a very nice piece about why that's a bad idea, i'll just refer
you to his site:
http://perl.plover.com/varvarname.html

Now, what *should* you do?

1. if you want multiple values for $varname but all want them to point at a certain
(maybe same) array, use hashes

like this:
my @names = qw(name1 name2 name3);
my @values = qw (value1 value2 value3);

for (@names) {$hash[$_] = \@values}

2. you want to use multiple names for the $varname, but also the contents of the array
may vary:
in that case, read up on how to use hashes and references.
perldoc perlre would help you out, or read the tutorials on
www.sharemation.com/~perl/tut


Regards,

Jos Boumans

Alberto Manuel Brandao Simoes wrote:

> Hellows
>
> I'm writing a module and, as all modules should be, I'm using strict. So, I
> need to 'declare' every variable. What I want, is to do something like:
>
> $varname = "myvar";
> @$varname = ('a','b','c');




Re: Compare statement.

2001-05-17 Thread Jos Boumans

well, actually you cant *just* use || instead of or, seeing || binds
tighter...

just try running this bit of code, and you'll see what i mean:

if($c || $d = 2) { print "foo" }

thus, if you use || and you wish to compare like you do, you *have* to use
parens

correct code would therefor be
if($a || ($b = 2) ) { print "foo" }

alltho what jeff said is very true: use OR for strings... just like you should
use EQ rather then ==

Regards,

Jos Boumans



Jeff Pinyan wrote:

> On May 17, Doug Johnson said:
>
> >my $x = "return";
> >
> >if (($x = "a") || ($x = "test" ) || ($x = "return" ) || ($x = "x-retun"))
> >   {
> >   print("bunch of foo);
> >   }
>




>
> (Yes, you can use parens if you want, and || instead of 'or', but the
> point is, using = is ASSIGNING to $x.  And using == on strings is a
> no-no.  You need to use 'eq'.)
>




Re: elegant REGEX

2001-05-18 Thread Jos Boumans

i'm not too fond of  below suggestion's variable naming, but hey,
tmtowtdi here's my 2 bits:

my $foo = 'test case total : 32456 allocated : 12000 from tech';

my ($num1,$num2) = $foo =~ /(\d+).+?(\d+)/;

Good luck,
Jos Boumans


Aaron Craig wrote:

> my $sLine = "test case total : 32456 allocated : 12000 from tech";
> $sLine =~ /(\d+)[^\d]+(\d+)/;
> my $lNumber1 = $1;
> my $lNumber2 = $2;
> print "number 1: $lNumber1 and number 2: $lNumber2";
>



> >can any one suggest me a REGEX to catch the numbers in the following
> >input line:
> >test case total : 32456 allocated : 12000 from tech
> >
> >I want to catch the two numbers and insert them to vars
>




Re: Quick rounding to nearest integer

2001-05-18 Thread Jos Boumans

try to take a look at the 'floor' and 'ceil' in the posix module

they will do exactly what you want!
 POSIX qw(ceil floor)

perldoc posix

Kind regards,

Jos Boumans


Craig Moynes/Markham/IBM wrote:

> I looked through my book (perl nutshell) and PP has not arrived yet, so I
> will ask here.
>
> I have an number that needs to be rounded to the nearest whole number.
> This is my solution:
>
>if ( $archives_needed =~ /\.\d+/ )
> {
> ($remainder = $archives_needed) =~ s/\d+(\.
> \d+)/$1/;
> $archives_needed += $remainder;
> $archives_needed =~ s/\.\d+//;
> }
>
> Is there an easier way (or more efficent).  This is more a curiosity than
> anything else.
>
> Thanks perl junkies,
>
> -
> Craig Moynes
> [EMAIL PROTECTED]




Re: ftp

2001-05-18 Thread Jos Boumans

if you use the activestate perl build, you can use hteir package manager, called 'ppm'

www.activestate.com for more info =)

Kind Regards

Jos Boumans

kosta gruzdnev wrote:

> Thank all the perl gurus answering our naive novices' questions.
>
> ok, now the problem is:
>
> I try to install Net::FTP in WinNT. ppm says there is no such PPD file. That's ok, I 
>don't object. As far as I can see, I cannot influence it. Or can I? Anyway, what are 
>the ways (lazy ones :] ) to install perl packages in WinNT. Or, again, which man-page 
>or doc should I read to learn about it?
>
> Thank you again,
> kosta




Re: truncating a string

2001-05-18 Thread Jos Boumans

Try this:

it just replaces MORE then one whitespace...

$title = "The Linux Programmer's Guide ";

$title =~ s/\s+$//;

Regards,

Jos

David Merrill wrote:

> Hi,
>
> I'm working on my very first perl application, which is a front end to
> a database for the LDP. I am trying to truncate a string, using:
>
> $title =~ s/\s*$//;
>
> where $title = "The Linux Programmer's Guide "
>
> and it is being truncated after the ' mark. All I want to do is remove
> the trailing spaces from the string. Can someone please help?
>
> TIA,
>
> --
> Dr. David C. Merrill http://www.lupercalia.net
> Linux Documentation Project   [EMAIL PROTECTED]
> Collection Editor & Coordinatorhttp://www.linuxdoc.org
>Finger me for my public key
>
> Your code should be more efficient!




Re: profiles

2001-05-21 Thread Jos Boumans

First of all, this is a linux question, not a perl question, so i suggest for
further help you try the appropriate lists, rather then this one.

Now for my 2 bits about linux profiles:

I know redhat's setup, which means that your profile is a .profile file in the
/home/$who dir..
ie, if your login name is 'foo', your home dir will by default be, /home/foo
and the profile will be in the .profile file

now, this is no guarantee... maybe your sysadmin set up the box differently, or you
dont run redhat or, or or...

I hope this helps, if not, try a linux mailing list

Regards,

Jos Boumans

[EMAIL PROTECTED] wrote:

> Can anyone help me???
>
> I did a  which ls 'ell ess' which someone suggested I try to locate my user
> profile and this is what came up:
>
> no ell in /home/users/schatzj /home/users/schatzj/bin /opt/sfw/bin /usr/dt/bin
> /opt/BackEx/bin /usr/bin /opt/sfw/bin /usr/local/bin /usr/ucb /opt/BackEx/bin .
> /usr/openwin/bin /bin /usr/ucb /usr/ucb.
>
> no ess in /home/users/schatzj /home/users/schatzj/bin /opt/sfw/bin /usr/dt/bin
> /opt/BackEx/bin /usr/bin /opt/sfw/bin /usr/local/bin /usr/ucb /opt/BackEx/bin .
> /usr/openwin/bin /bin /usr/ucb /usr/ucb.
>
> I don't know how to interpret this.  I thought that maybe the paths after the
> periods were possibilities, but I still don't know what file names I am looking
> for.
>
> I saw files called locale, localedef, and profile among the hundreds of files,
> but when I use emacs, they are not readable (as in they come up with &&&&& for
> the entire file).
>
> All I want to know is what directory my user profile should be in, which I
> believe is /usr/bin, but once there I have no idea what file name I am looking
> for.  There are 100's of files and I am lost!
>
> Thanks.




Re: Regular Expressions

2001-05-23 Thread Jos Boumans

Or a really one:

if ($x =~ /\D/) {
print "found non digit, do not pass go, no 20 grands for you";
} else {
print "good boy";
}

where \D stands for NON digits

regards,

Jos Boumans

"Brett W. McCoy" wrote:

> On Wed, 23 May 2001, Kyrytow, Stefan wrote:
>
> > As you can see the last two inputs should not be accepted. I am using $x =~
> > /[0-9]/ as my filter. I understand why the values are being accepted, I am
> > searching for a number and 12bob & bob12 each contain a number.
> >
> > What I do not understand is how to search for just a number.
>
> The problem is that your regexp is matching *any* string that contains the
> pattern.  You want to narrow your expression down a bit.
>
> Try:
>
> $x =~ /^\d+$/.
>
> -- Brett