l the user presses any key, and then just
> continue. Is there an easy way to do this? A way without modules?
There's no simple way that's cross platform. Read the source code for
Term::ReadKey for the gory details.
Nigel Wetters
Research Fellow, Epidemiology Unit
London Sc
reference to the object, which must be dereferenced before you can call
a method on it.
> $data[0]->show; # This won't work, it sais "Can't call method "show" on
> unblessed reference"
This is what happens when you call a method on a reference,
k('N',...
as this seems to be the friendliest format for cross-platform binary
files.
http://search.cpan.org/author/NWETTERS/IP-Country-2.07/
--
Nigel Wetters <[EMAIL PROTECTED]>
Perl Developer, Sun Certified Java Programmer
123 Ravensbury Road, London SW18 4RY
Tel. 020 8944 86
On Wed, 2002-12-11 at 13:55, Ruth Albocher wrote:
> I need to "cast" a scalar reference (SCALAR0x) into a reference to
> an object that I can use. (in other words, bless it).
> How can I do it?
my $object = bless $scalar_reference, 'Your::Class';
--
Nig
to convert both to lower case, using lc:
if (lc($x) eq lc($y)){
# do something
}
--
Nigel Wetters, Senior Programmer, Development Group
Rivals Digital Media Ltd, 151 Freston Road, London W10 6TH
Tel. 020 8962 1346 (direct line), Fax. 020 8962 1311
PGP keyserver: pgp.mit.edu <[EMAIL PROTECTE
ess, it returns the country code where that
address was registered. Probably useful for log analysis, as it can
lookup 20,000 country codes a second on a reasonably fast processor.
Might also be useful for country-based redirects on a corporate website.
--
Nigel Wetters, Senior Program
are fairly
constant, you should probably not need to store them in a database.
--
Nigel Wetters, Senior Programmer, Development Group
Rivals Digital Media Ltd, 151 Freston Road, London W10 6TH
Tel. 020 8962 1346 (direct line), Fax. 020 8962 1311
http://www.rivalsdm.com/ <[EMAIL PROTECTED]>
-
my $month = $row[0]; # first column of DB row
if ($month eq (split ' ', uc localtime)[1]){
# print SELECTED stuff
} else {
# don't print selected stuff
}
}
--
Nigel Wetters, Senior Programmer, Development Group
Rivals Digital Media Ltd, 151 Freston Road, Lon
ility of the code.
My guess is that your colleague has used such separators in a persistent
store of these data structures. But I could be wrong.
--
Nigel Wetters, Senior Programmer, Development Group
Rivals Digital Media Ltd, 151 Freston Road, London W10 6TH
Tel. 020 8962 1346 (direct line), Fax. 0
produces this
problem?
--
Nigel Wetters, Senior Programmer, Development Group
Rivals Digital Media Ltd, 151 Freston Road, London W10 6TH
Tel. 020 8962 1346 (direct line), Fax. 020 8962 1311
http://www.rivalsdm.com/ <[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additio
their lack will produce no errors
during the build process, only during testing.
If you still have problems after installing prerequisites, raise a bug
against the module here:
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBIx-HTMLView
--
Nigel Wetters, Senior Programmer, Development Group
Riv
On Thu, 2002-10-24 at 16:57, Goodman Kristi - kgoodm wrote:
> $recs = (-s "$outname.src") / $recl;
>
> ... on some large files, it will return a negative amount of
> records.
>From the snippet of code you've given me, it looks like $recl is
sometimes set to a negative number. Can you post the code
On Thu, 2002-10-24 at 13:04, I wrote:
> $news =~ s/^\[\*\] (.*)$/$1/;
sorry, this is probably better
$news =~ s/^\[\*\] //;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
On Thu, 2002-10-24 at 01:03, Andres L. Figari wrote:
> [*] headline 1
> [*] headline 2
ok
> $news =~ s/^(\[\*\]) + ([^W.*])/$2/;
This won't match, and thus no substitution will happen.
try:
$news =~ s/^\[\*\] (.*)$/$1/;
--
Nigel Wetters, Senior Programmer, Development Group
nd
ASP, it's easy to write applications with clear boundaries between
layers. With only the templating language, the model and controller are
forced into the view layer, which soon becomes unmaintainable.
However, PHP is fine for building quick and dirty webpages, which is
what most peopl
bXML::SAX
XML::LibXML::Fixup
and if speed isn't an issue, there's also a pure Perl XML parser:
XML::SAX::PurePerl
--
Nigel Wetters, Senior Programmer, Development Group
Rivals Digital Media Ltd, 151 Freston Road, London W10 6TH
Tel. 020 8962 1346 (direct line), Fax. 020 8962 1311
http
data;
while (my $line = ){
chomp $line;
$data{$line} = 1;
}
print keys %data;
--
Nigel Wetters, Senior Programmer, Development Group
Rivals Digital Media Ltd, 151 Freston Road, London W10 6TH
Tel. 020 8962 1346 (direct line), Fax. 020 8962 1311
http://www.rivalsdm.com/ <[EMAIL PROTEC
On Fri, 2002-10-18 at 16:21, Jack Chen wrote:
> Thought there is some easy way bu could not find.
Use a require statement within an eval(), then check for errors:
eval("require Foo::Bar");
if ($@){
print "not installed";
} else {
print "installed"
John Griessen wrote:
>I have not figured out how to run a program yet, though.
>Will I be able to run etiher perl or mod perl with the same web server?
Apache can run Perl either through CGI or through mod_perl. You can set up
different URLs on the same Apache installation to run cgi and mod_per
d 40 times the speed
of a CGI script:
http://search.cpan.org/search?dist=Apache-Emulator
--Nigel Wetters
<[EMAIL PROTECTED]>
Etienne wrote>>>>
I am using CGI only to get the data sent to the script from my html
forms.
When I put use CGI, does it "load" all the modul
Sorry, typo:
http://www.perlfascist.com/factory.tar.gz
I've already amended the example to include some comments made by people who
found my site despite my best efforts!
Still looking for sites that have any information about design patterns in
perl. Anyone seen any?
--Nigel We
lled directly, thereby ignoring the existence of a base class.
Is this the factory method, or am I deluding myself? Does anyone have any
decent links for design patterns in Perl?
--Nigel Wetters
_
Get your FREE download of MSN
here's a way to pad to 32 bits:
sub _pad32 { substr("0" x 32 . shift, -32); }
which is used in Image::Size in the following manner:
# _bin2int - converts binary string to decimal
sub _bin2int {unpack("N",pack("B32",substr("0"x32.shift,-32)));}
>>>Schoeneman, Carl 09/26/01 08:40pm >>>
Is there
I've been disecting the CPAN Image::Size module, and have found out some useful stuff
that I wanted to share. The beginners list seemed an appropriate place.
Here's the algorithm for finding the height and width of a JPEG (all nambers are hex):
1. Skip the first two bytes of the file.
2. Read t
buffer1 is undefined, and so the line
print OUTFILE "$buffer1";
prints nothing.
A good idea when having problems such as this is to run the program
using
warnings - change your first line to
#!/usr/bin/perl -w
--Nigel
>>> agc 09/03/01 03:31pm >>>
well I solved the thng, but the thing
Yep, using fork() will make your code less portable. If you want concurrency and don't
want to use fork(), you'll need to either experiment with threads (as suggested by
Jos), or build a multiplexed server using select(). One book I've found useful is
Network Programming with Perl by Lincoln D
>From CPAN - URI::Escape -
NAME
URI::Escape - Escape and unescape unsafe characters
SYNOPSIS
use URI::Escape;
$safe = uri_escape("10% is enough\n");
$verysafe = uri_escape("foo", "\0-\377");
$str = uri_unescape($safe);
DESCRIPTION
This module pro
FH> Also another question:
FH> Is it NOT recomended to have a for loop nested in a 'if' statement or it doesn't
really matter.
It's more preferable to do this...
if (some_test){
for (some_loop){
# code
}
}
Than this...
for (some_loop){
if (some_test){
# code
}
Sorry Tim, you chose a problem that looks simple, but isn't. Here's the code to move
an arbitrary file or directory:
http://language.perl.com/ppt/src/mv/mv.plx
>>> Tim Musson <[EMAIL PROTECTED]> 06/25/01 02:00pm >>>
Hey Perlers,
I asked this before, but I am still stuck, and never got a work
Here's a bit of code that retrieves a webpage and stores it in a scalar.
use LWP::Simple;
$content = get("http://www.slashdot.org/";);
Now, it's quite useful (and instructive) to use regular expressions to chop the
resulting page into useful lists and hashes.
--nigel
>>> "JM C. Alonzo" <[EMA
err... sounds viral
explain the problem in more general terms.
>>> "suman sanyal" <[EMAIL PROTECTED]> 06/23/01 12:37pm >>>
I want to write a perl program.which will automatically execute itself 5 secs
after its creationwhat should i doany good resources...
suman sanyal
--
__
semicolon after close brace is probably the problem. Try:
$cnt = 0;
foreach (@data)
{
$background = ($cnt % 2) ? 'bgcolor="#cc"' : 'bgcolor="#ff"';
print(''.$_.'');
$cnt++;
}
>>> Martijn van Exel <[EMAIL PROTECTED]> 06/22/01 01:15pm >>>
>On Fri, 22 Jun 2001, Martijn van Exel
Works for me! Have you tried using:
$odd_even = ($cnt % 2) ? 'ODD' : 'EVEN';
>>> Martijn van Exel <[EMAIL PROTECTED]> 06/22/01 11:56am >>>
Dear subscribers.
Why the $! does
(int($cnt/2) == ($cnt/2))
not return TRUE for an even $cnt and FALSE for an odd $cnt ?
What _is_ the way to test for od
ish!
Most perl will run equally well on Windows and Un*x machines. However, a few
system-dependent calls exist (for example, POSIX::termios isn't implemented on
Windows). You'll only likely to run into such issues when dealing with networking and
transferring files across systems.
Check out t
ADD ERROR CHECKING!
Lots of memory (small file)?
Read file line by line into a scalar, ignoring the line you want to omit. Close the
file, then open and overwrite with your scalar.
$ignore_line = 42;
$count = 0;
$file = '';
open(FH,"){
$count++;
$file .= $line unless ($count == $ignore_
I want to do this:
use POSIX qw(:termios_h);
$term = POSIX::Termios->new;
$term->getattr(fileno(STDIN));
# do some terminal manipulation here
However, I get the error message on Windows NT:
POSIX::termios not implemented on this architecure
I have two questions:
1. Is there _any_ way to t
To delete a file:
unlink($filename) or die "can't delete $filename:$!\n";
To delete lots of files:
unlink(@filenames) == @filenames or die "couldn't unlink all of @filenames: $!\n";
To delete a folder:
use File::Path;
rmtree($directory);
>>> Stéphane JEAN BAPTISTE <[EMAIL PROTECTED]> 06/21/01
Some people have obviously lost the first email they received from this list, so
here's a recap.
To unsubscribe to the list, you need to send an email to a special email address that
is formed partly from YOUR OWN email address. For example, if your email address is
[EMAIL PROTECTED], you shou
TMTOWTDI.
I don't know about how XML::Parser handles memory - last time I tried to use it to
parse content.rdf from http://dmoz.org , it soaked up all my memory, then bombed.
Sometimes, you need to write your own parsing subs :)
>>> Chas Owens <[EMAIL PROTECTED]> 06/19/01 09:39pm >>>
Please, p
Sorry, got the wrong end of the stick for a moment. Here's your problem (rom perldoc
perlipc):
If you're writing to a pipe, you should also trap
SIGPIPE. Otherwise, think of what happens when you start
up a pipe to a command that doesn't exist: the open() will
in all likeli
>From perldoc perlre:
s Treat string as single line. That is, change "." to
match any character whatsoever, even a newline, which
normally it would not match.
>>> <[EMAIL PROTECTED]> 06/19/01 01:40pm >>>
I don't understand the regex s#.*/##s
(given as part of the
I think I can give you some clues. Here's some code out of the Perl Cookbook (6.8
Extracting a Range of Lines), which I've adapted for you. You should be able to nest
such structures to get what you want.
my $extracted_lines = '';
while (<>) {
if (/BEGIN PATTERN/ .. /END PATTERN/) {
1.
$filename = 'foo.txt';
open(FH,"<$filename") or die "couldn't open $filename - $!";
while ($line = ){
print "$line matches\n" if ($line =~ /^USD /);
}
2.
while ($line=){
chomp $line;
next unless $line;
next if ($line =~ /^-+?$/);
next if ($line =~ /^=+?$/);
# only goo
I'm playing around with terminal programming on Linux, and wondered whether the
POSIX::termios package was the correct method to make my code cross-platform
compatible.
--nigel
This e-mail and any files transmitted with it are confidential
and solely for the use of the intended recipient.
Sad, I know, but I've produced a module that replicates the GNU file utility - touch.
I'm going to try to get it onto CPAN, and would love some constructive criticism
before I throw it to the wolves.
Here's the url:
http://www.codekitty.com/touch.pm
--nigel
This e-mail and any files tran
45 matches
Mail list logo