well, i'm guessing, from the error msg that you got that you have:
Too many files specified
what is in $cmd?
are you sure it's a command NT or Cygwin understand?
what happens if you just run the $cmd on a prompt?
why don't you check the return value of open?
if it fails, what's in $! ?
in short,
if we're talking about optimization and the question was really how to
CAPTURE the characters after the last /
there is really NO need for a s/// and a simple m// would do
which i imagine will also be quite a bit faster
regards,
jos
- Original Message -
From: "Gary Hawkins" <[EMAIL PROT
There's 2 ways to go about it...
if you always have file names, you should really use the File::Spec module
(which has been core for quite some time)
if you really want to use a regexp, well be my guest, but the above method
is really better...
i'll show you both:
### the script ###
use strict
you can also take a look at
http://japh.nu/index.cgi?base=tuts
which has a few OO tutorials there as well
hth,
jos
- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, December 05, 2001 7:33 AM
Subject: OO perl tutorials
> Hi all,
> can anyone sugges
> Sigh ! My mind simply refuses to work. What must I do to print the number
of
> records $count in line 3.
> Thanks
>
>
> 1.@array = qw ( hello world hello how are you );
> 2.$match = 'HEllo';
> 3.print "Your search for $match returns $subroutine $count
> records\n";
> $subroutine = &
what you probably want is:
use vars qw|$foo @bar|;
but ONLY use that if you're REALLY sure what you're doing
globals are usually a bad idea.
hth
Jos
- Original Message -
From: "Tomasi, Chuck" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 08, 2001 4:45 PM
Subject:
you're talking about simple OO programming...
i wrote a tutorial on just that subject, i think it will help you along with
your project.
take a look here:
http://japh.nu/index.cgi?base=tuts
hth,
Jos
- Original Message -
From: "AMORE,JUAN (HP-Roseville,ex1)" <[EMAIL PROTECTED]>
To: "Begi
this code just returns a reference to a scalar, which is rather pointless in
this case and really doesn't solve the problem.
> sub return_scalars {
> $scal1 = 5; Assign values to scalars somehow
> $scal2 = 7;
> return \$scal1, \$scal2;
> }
>
> ($test_scalar1, $test_scalar2) = &return_scalars();
hi,
firstly, that's not a regexp, it's a simple concatenation
( the . operator 'glues' two strings together - try
http://japh.nu/index.cgi?base=data_types for a tutorial that mentions this )
secondly, to answer the "\', \'"-question:
it's simply a quoted string
not much unlike "foo", but iwth th
make your code readable, try this:
$line =~ s|\|/|;
perhaps it's not working because you dont have the /s and /g modifiers?
/s = read beyond newlines
/g = chnage them all, not just the first
hth,
Jos
- Original Message -
From: "RAHUL SHARMA" <[EMAIL PROTECTED]>
To: "Konstantin Berma
take a look at any of these (depending on your OS):
the user id's are in
$> and $< #perldoc perlvar for more information
otherwise, try this:
### this will print out all your %ENV vars... look for 'user' or 'username'
or some such
perl -e "for (sort keys %ENV){print qq($_ => $ENV{$_}\n)}"
hth,
will be available in $ARGV[0] in your script
read http://japh.nu/index.cgi?base=perlvartut if you want to learn some more
about it
hth
Jos
- Original Message -
From: "phumes1" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, October 22, 2001 3:54 PM
Subject: Re: passing filena
i must be missing the point, but why are you using prototyped subroutines to
populate a hash ref?
what's wrong with:
my $href = {
foo => 'quux',
bar => [ qw( bleh yuck) ],
};
or
$href->{'baz'} = { foo => 'bar' }
?
regards,
Jos
- Original Message -
From: "Ross Howard" <[EMAIL
Hi,
> > Hello all,
> > I hope you can help, I have the following information
> >
> >
> > Happy,[EMAIL PROTECTED], manager, $2
> > Bob, [EMAIL PROTECTED], manager, $35000
> > Jim, [EMAIL PROTECTED], manager, $5
> > Charles, [EMAIL PROTECTED], sales, $28000
> > Ann, [EMAIL PROTECTED], sale
Hi,
> How do I get this to work?
well, let's try...
> package main;
> use Simple.pm;
if you define the package in the same file, you dont do 'use Simple': perl
will then look in @INC for a 'Simple.pm' file,
which you dont have.
ALSO the syntax is 'use ModuleName' - so no '.pm' at the end!
>
same way you did with teh scalar:
dereference it:
%$hash_reference;
there's a tutorial on this at http://japh.nu
hope that helps
Jos
- Original Message -
From: "Ulle Siedentop" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 26, 2001 3:30 PM
Subject: Problems w
i have to honestly say, i didnt read the entire problem, but i see a line in
your code which you probably don't want:
while () {
my @line = split /\|/, ;
the while thing puts the line in $_
you are then discarding that line, and reading hte *next* line in that file
and feeding that to split.
then learn how to use a search engine, quit the spam
you're not happy with a reply, take it to personal message rather than more
spam
now can we please close the thread?
thanks
- Original Message -
From: "rc" <[EMAIL PROTECTED]>
To: "LazyDBA.com Discussion" <[EMAIL PROTECTED]>; <[EMAI
what code/modules are you using?
and try:
perldoc THATMODULE
first please
hth
Jos
- Original Message -
From: "Rahul Garg" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 19, 2001 12:27 PM
Subject: timeout problem
Well, I am getting the html pages from site.
well
you can discriminate by OS if that helps you:
$^O will hold the name of the operating system you're running on
(alltho i think it'll probably be in %ENV somewhere too)
so something like this might work:
BEGIN: { use Win32 if $^O eq 'MSWIN32' } #or whatever it's called again
depending on the co
what you probably want is this:
for(@lines){
last unless $_;
# your stuff;
}
hth,
Jos
@lines is an array which contains blank lines as well as textlines...what i
want to do is to get a line from array thru shift(@lines)
until the array doesnt contain the textline or array has no more
li
that's not a problem with inheritance, but with 'strict'
do something like:
use vars qw(@ISA);
regards,
Jos
- Original Message -
From: "Edwin Günthner" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, September 06, 2001 1:19 PM
Subject: Problem with inheritance
> Hi there
These are very basic questions, which any good perlbook will deal with.
(I'd advise 'learning perl' by randal schwartz).
now for your answers:
1: that's called 'autoflush', print right away rather then buffering
2: undefine a variable (ie, make it empty)
3: they're called hashes, and => makes ''
2 seconds of thinking says you MIGHT be able to use the meta refresh option
just tell it to redirect to the submit page after x seconds, maybe sending a
cookie along that says when they *got* the page, so you know they'r enot
cheating.
not sure if this is an adequate solution, but it's a fairly s
something like this would be good praxis:
BEGIN
use vars qw(@ISA @EXPORT_OK);
@ISA = qw(Exporter OtherModule);
@EXPORT_OK = qw(some_function);
}
damian's book is definately worth your while if you're into OO programming
btw:
"Object Orientated Perl" by Damian Conway
Published b
you need to send it a reference to a hash rather then an array then
hth
Jos
- Original Message -
From: "Veeraraju_Mareddi" <[EMAIL PROTECTED]>
To: "Jos I. Boumans" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, September 04, 2001 11:48 A
coincidently, i had to do the same thing yesterday...
i used Win32::AdminMisc module, which you can obtain from www.roth.net
the docu is good, so it should all explain itself from there.
if your'e still stuck after installing, msg me, i'll send you some sample
code.
regards,
Jos
- Origina
http://japh.nu/index.cgi?base=references
a basic reference tutorial =)
hope that helps,
Jos
- Original Message -
From: "Bert de Jong" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, September 04, 2001 9:08 AM
Subject: References?
Hi all,
I'm reading a beginners tutorial o
you'll need to dereference it..
this would work for you:
perl -e "$ref=[qw(1 2 3)]; print scalar @$ref"
regards,
Jos Boumans
- Original Message -
From: "Hamish Whittal" <[EMAIL PROTECTED]>
To: "perl beginners" <[EMAIL PROTECTED]>
Sent: Friday, August 31, 2001 5:24 PM
Subject: Gettin
perhaps you want to 'use' or even 'do' your module
but it depends on the error you are getting
perhaps you can provide a bit more context?
Jos
- Original Message -
From: "Oliver Velten" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 23, 2001 3:32 PM
Subject: usage of
Hello Randy,
I wrote some beginners tutorials you might find usefull on http://japh.nu
Also, I'd recommend the camel book (programming perl, by larry wall, published by
o'reilly)
and the llama book (learning perl, by randal schwartz, also published by o'reilly).
hth,
Jos Boumans
"Randy5235" <
just print out $self
it will tell you what it is
-Jos
- Original Message -
From: "Tom" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, August 21, 2001 11:17 PM
Subject: What just happened
>
> Is the new_bp_handler_config_t(@args) a new array reference or a new
hash ??
>
>
LS,
I should have this under 'paste' by now, seeing this apparently needs repeating every
so often.
DO NOT READ ENTIRE FILES INTO ARRAYS UNLESS THERE IS NO OTHER OPTION.
are you realising you are slurping an entire file into memory? ever tried that with an
apache log file?
In this case, slur
i think you can get this done if you use printf
not sure about the dynamically determining the length, but you can always
use an IF block for that
perldoc printf is your friend here =)
hth,
Jos
- Original Message -
From: "Javier Bellido" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent:
Just a little correction on your explenation:
$/="o" || "p" || "q"; will assign 'o' to $/, not 'q'.
the || short circuits, meaning it will assign the *first* true value, not
the last.
in short, 'p' or 'q' won't even be evaluated, since 'o' evaluates to true.
you might have seen syntax like:
op
I think what you want is constructor related, not exporter related...
I have this covered in an OO tutorial on my site.
you would probably find it usefull to read:
http://japh.nu/index.cgi?base=tuts
both part 1 and 2 deal with the problem you're experiencing.
hope this helps,
Jos Boumans
---
depending on what you want, you could use the Win32::* modules (standard
with active state perl, else get them from cpan)
or use a system call if they dont do what you want...
if you have a more precise question, feel free to ask, but i'm nto sure what
extra advice to give you now =)
regards,
J
ok, i'm not 100% sure what you're doing here..
the object CGI.pm returns is a hash reference... so what your'e doing here
is passing a reference to a hashreference.
why?
secondly, you're prototyping your subroutine... altho it has it's use in
some cases, most of the time this is NOT what you wan
\D = non numbers
\d = numbers
perldoc perlre
or an online tutorial about regexes at
http://japh.nu/index.cgi?base=tuts
hth,
Jos
- Original Message -
From: "Steve Howard" <[EMAIL PROTECTED]>
To: "Toby Stuart" <[EMAIL PROTECTED]>
Cc: "Beginners@Perl. Org" <[EMAIL PROTECTED]>
Sent: Thursd
to be on the safe side, just get bundle::lwp
it has all you'll ever need probably!
- Original Message -
From: "Jennifer Pan" <[EMAIL PROTECTED]>
To: "Jos I. Boumans" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, Augu
This is exactly what LWP is for...
it comes standard with activestate's distro of perl (www.activestate.com)
but not with *nix iirc.
you can grab the module from cpan and just read up on the docs of
LWP::Simple
it does all you need =)
hth
Jos
- Original Message -
From: "Tyler Cruicksha
i was referring to the entire line (ie, the command).
and i stand by my former reply: try the win32::* modules for interaction
with windows first, before reinventing the wheel.
Jos
- Original Message -
From: "Michael Fowler" <[EMAIL PROTECTED]>
To: "Jos I. Bouma
it's in the last line:
kill 'HUP',`cat $PIDFILE`;
it's a unix command to kill *nix processes... which of course won't work on
windows...
what is the purpose of using this on windows? it's structure is quite
different...
hth
Jos
- Original Message -
From: "Rajeswary Santhiran" <[EMAIL P
a snippet of data you're trying to parse would probably be helpful in this
case
not all of it of course, but give us a fair idea =)
Jos
- Original Message -
From: "Ron Woodall" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Jos I. Boumans" <
a few notes on soft references:
1. they are generally concidered evil
2. they will not work under use strict
3. they are rarely what you really need/want
I'm not saying they are bad in your case, but let me just elaborate on the
above.
you'll have to say 'no strict refs' for a certain block to
it's a way to dereference a hash-reference.
just like you might see @$array etc...
here's roughly how this works:
my $href = \%hash; # create reference
my %new_hash = %$href#dereference.
if you'd like to read more about it, check out
http://japh.nu/index.cgi?base=tuts
which has
cute nick btw.
take a look at http://japh.nu
there's a tutorial on loops and blocks in the tutorial section.. it should
answer your question.
hth,
Jos Boumans
> Hey all,
>
> I just started learning Perl yesterday and I've already gotten pretty far
in my first program.
>
> My question is... wel
if you're on windows, your OS shipped without a c-compiler...
for that reason, activestate (www.activestate.com) use 'ppm' - the perl
package manager..
which means they already built binaries of the modules you're looking for.
i suggest you check that out, it will make your life a LOT easier if y
are you sure your input is what you expect it to be?
maybe print out all the lines?
and if you like, i wrote a very basic and simple html parser.
you can get it here: http://japh.nu/index.cgi?base=modules
take a look at the source, it should probably explain a lot
hth
Jos
> I'm trying to modi
let's see if i can shed some light on this.
your statement:
print("Defined: <<$z>>\n") if defined(my $z="x");
this will be evaluated like this if i'm not mistaken:
( print("Defined: <<$z>>\n") ) && defined(my $z="x");
or a simplistic version:
(print $z) && (my $z = 'bar');
try and 'use strict'
you'll have to use regular expressions
http://japh.nu for a basic tutorial on those
and read perldoc perlretut
if you want more specific advice, show us what you tried so far and what
happened.
hth, Jos
> Hi folks:
>
> i have a file like this:
>
> mail [EMAIL PROTECTED] from
> to: [EMAIL PR
if you're just interested in *EXACTLY* the same files, use MD5 (get it from
search.cpan.org)
even one BIT of difference (literally) will result in a different checksum
thorough and fast
hth
Jos Boumans
- Original Message -
From: "Maxim Berlin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
you want the qr// operator
that means 'quote regex'
hth
Jos
- Original Message -
From: "Adimoolam Narayanan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, August 06, 2001 9:18 PM
Subject: Regular Expressions
> Hi,
>
> In a nutshell, I have been trying to store a reg. exp.
== is for numeric comparison
eq is for string comparison
hth
Jos
- Original Message -
From: "CDitty" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, August 06, 2001 7:22 PM
Subject: == vs eq What's the difference?
> The subject pretty much says it all. Why do some if stateme
make your life easy, use something like this:
$_ = 'foo@bar';
print "ILLEGAL!" if /[^a-zA-Z]/;
the ^ in side the character class says, everything NOT belonging to what's
in this class
it should be a bit faster then checking the entire string for sure.
hth,
Jos Boumans
- Original Message
for (1..10) {
last if /3/;
print;
}
you'll notice this printing '12'
so 'last' breaks out of the loop if the condition is met
hth
Jos Boumans
- Original Message -
From: "Webmaster" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, August 05, 2001 7:31 PM
Subject: Breaking out
L.S,
For those who read and enjoyed part one of my OO tutorial, part two is now available
at http://japh.nu
also, thanks a lot for the feedback on my materials, it was most helpfull!
regards,
Jos Boumans
PS. My appologies for those that are 'spammed' by this.
Hi,
I'm not sure you're quite understanding the logic of modules and packages
yet...
the idea of a module is that you use methods (subroutines belonging to a
package) to execute code
however, you're making your 'methods' attributes to an object.
This quite defeats the purpose and provides nothing
just dereference it:
foo( @{ $R{"first"} } );
it's as easy as that =)
hth
Jos Boumans
>
> Hi all,
>
> here's my question :):
>
> I define a hash array:
> our %R=("first" => [ "one", "two" ], "second" => ["third", "fourth"]);
>
> Now I can get back back array references from this using:
nah that's quite alright... teaches me to go to BED rather then try and make
my hands type things my brain can't even grasp anymore ;-)
> On Sat, Jul 28, 2001 at 01:22:06AM +0200, Jos I. Boumans wrote:
>
> Hopefully my corrections below aren't insulting, but I felt it ne
it's quite simple
while, for, etc are operators in a way
they do something with whathever you give them
for, for example, assigns every every element of a list to $_
unless you specify differently
so what you're doing with this:
if (/foo/) { print "found foo" }
is the same as saying:
'some
my guess would be that the locating of use'd modules is a compile time
directive...
while your push @INC is a runtime thing
ie, too late
besides, you use the 'use lib' pragma anyway
ie:
use lib qw($ENV{'PERL_LIB'});
hth,
Jos Boumans
- Original Message -
From: "Tirumal Reddy" <[EMAIL P
Hi,
actually, that should print ' is '
the reason for that is that regexes will try to match the earliest possible
string, but as much as possible.
so in your case, you say:
find a whitespace # \s
find one or more word chars# \w+
find a white space#
t explains this
hth
Jos Boumans
- Original Message -
From: "Sally" <[EMAIL PROTECTED]>
To: "Jos I. Boumans" <[EMAIL PROTECTED]>; "perl" <[EMAIL PROTECTED]>
Sent: Friday, July 27, 2001 11:37 AM
Subject: RE: errors
> Thanks for th
ok, first, what are you trying to do?
secondly, dont put a filehandle in an array.. it's A BAD THING!
this means you're slurping the entire file into memory, as well as having to
allocate a bit of extra memory for perl to understand each line should be a
different value of the array.
if you're si
those errors mean that the variable you're trying to print out holds no
value.
ie, this would cause such an error:
$bar = $foo . 'quux';
since I didnt assign any value to $foo, it will say i usded an unitialized
variable.
a little pointer for readabillity of your code; instead of escaping all
if you say 'unique' you probably want to concider an autonumber field in
your db for the primary key
it's *always* unique...
you can even do a query on the db to give you the current_id for a table (so
the one you want to insert would be current_id + 1 )
depending on what db you use, the sql is
This is exactly why we have \b
consider the following:
$_ = "hello world. goodbyecruel world";
s/\b(.)/uc$1/seig;
print;
this should do exactly what you want... it matches the first character after
a word boundary and uppercases it.
there's an explenation about regexes at the
because you are using ==
that's for numerical compares
numerical, SOS and 'all' are the same
use 'eq'
hth
Jos Boumans
- Original Message -
From: "Bob Bondi" <[EMAIL PROTECTED]>
To: "Beginners-perl" <[EMAIL PROTECTED]>
Sent: Friday, July 27, 2001 12:54 AM
Subject: Why does this conditio
I'd actually be surprised if that works...
let me point out a few things:
if ($list = 'foo') will always be true.. you are assigning 'foo' to $list
what you want is probably 'eq'
the if block also needs curly brackets {} around it, especially if you want
to use the 'else' part
more so, assumign
LS,
as promised, i wrote up a beginners OO tutorial
i split it into mulitple parts as i saw the tutorial growing to quite a size
part 1 is now up and can be read in the tutorials section of http://japh.nu
part 2 and followign will be up there shortly
(and for those wondering, yes, i put the nu
assuming you are alright with storing them in a hash as key value pairs,
something like this will probably work for you:
open I, "$ARGV[0]" or die $!;
my %conf;
while(){
chomp;
next unless $_;
my ($key,$val) = split /\s*=\s*/;
$conf{$key} = $val;
}
for (keys %conf) { print "$_ = $conf{$_}\
I love it when i write up complete crap about needing to check existance of
keys...
the following code will merrily suffice:
#
open I, "state.txt";
my %codes;
while () {
chomp; #remove newline
s/\s+//g; #remove white space
my @entry = split ':'; #split on :
pu
I took 2 looks at this problem and figured i'd need to use a hash of array
references.
now, i'm debating whether i should just hand you the code to get this job
done, or whether to realy explain how these things work.
i decided to do a bit of both, so bear with me here.
what we want is a list o
a snippet of the files would be msot helpfull...
- Original Message -
From: "Carl Rogers" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 24, 2001 4:51 PM
Subject: Extracting data from text files using Perl
> Good day;
> I have been banging my head against the wall on th
This is most definately not the same...
\w is equivalent to [A-Za-z0-9_]
there's a basic regexp tutorial here:
http://japh.nu/index.cgi?base=regexes
it also deals with (custom made) character classes, special symbols in
regexps etc,
maybe it's beneficial to you.
regards,
Jos Boumans
Also, [
dependingon what you want, you can probably use the Win32::* modules
they come standard with activestate's distribution, not sure about others...
hth,
Jos Boumans
- Original Message -
From: "Craig S Monroe" <[EMAIL PROTECTED]>
To: "Beginners@Perl (E-mail)" <[EMAIL PROTECTED]>
Sent: Mon
Very well, i'll try and write a tutorial somewhere this week and anounce it
regards,
Jos Boumans
> > I am feeling i'm getting a bit technical here... if there's a
> > desire i write
> > a tutorial about basic packages, please let me know
>
> That would be good. I did finf some other writings
Hello,
i wrote some beginners tutorial on http://japh.nu which deal with most of
the questions you're asking here
maybe you should take a look, see if that answers some of your questions.
regards,
Jos Boumans
HELP
More specifically : my essay demands me to find out about Perl data
types.Would
It's not all that hard, just follow the links...
but here's the page you can click to download:
http://aspn.activestate.com/ASPN/Downloads/ActivePerl
hth,
Jos Boumans
> Hi all
>
> This amy seem a little silly, but I've checked perl.com, perl.org, and
> activestate.com and cannot find instructi
ing out the existance of said module tho
regards,
Jos Boumans
> On Fri, Jul 20, 2001 at 02:45:52PM +0200, Jos I. Boumans wrote:
> > ### $res->content is the return value of a LWP request
> > my @images = $res->content =~ |
> Rather than go the broken regex route (in the ab
That's a good idea Joni,
however, personally, i'd always add a constructor, no matter how basic...
you could do something like this (add this to the file joni described):
sub new { return bless {}, shift }
this will indicate that this object belongs to that package you just
wrote...
this makes
you'll need to build a regexp that fetches all the image files, and then an
lwp thingie that goes and retrieves them
think of something like this:
### $res->content is the return value of a LWP request
my @images = $res->content =~ |
To: <[EMAIL PROTECTED]>
Sent: Friday, July 20, 2001 2:30 PM
Su
why yes there is... i wrote a little module for perl that does just that.
basicly, you pass the module a filehandle, it strips out all hte html
(leaving the links in the file intact however) and passes back a string
a sample script is also available. look at http://japh.nu/index.cgi
the site is
it's at learn.perl.org
-- Jos
- Original Message -
From: "Patrick Kelly" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 19, 2001 7:48 AM
Subject: question
What is the website of this newsgroup? I can't afford to keep listening to
it in my e-mail, as it is flooding my
1: Do NOT send 'high priority' mails to this list. Your problem isn't any
more important, interesting or special then anyone else's here. It's also a
recipe to get, at least myself, rather agitated.
2: there's a list specifically for cgi problems, as you can read on
learn.perl.org I suggest you s
short answer:
read about it at mjd's site http://perl.plover.com/FAQs/Namespaces.html
long answer:
what brian said... you've been asking quite a few beginners questions here
and i'd concurr that it's time you read a book about perl so you'll actually
learn the basics for it... both learning perl
I think you need to start reading on a few books my friend.
here are a few places to start:
read the regexp tutorial i wrote at http://japh.nu
read "perldoc perlre" for more details
look into getting "learning perl" by randal schwartz, it will teach you many
of the basics you'll need for Perl
n
using 'my' within the while loop will make it lose it's value once the loop
exits and it will be reset every time you read in a new line
declare 'my @list' above the loop, and you'll not have that problem.
for readabillity, use:
if(/(\S+/){ push @list, $1 }
altho that's a bit superfluous i think,
it's essentially the same thing, only instead of handing the match to the
print operator, we store it in @list
like so:
open(FP, "$tempfile"); # Open $tempfile for reading
while() { push @list, /(\S+)/ }
$list[0] will hold the first match, $list[1] the 2nd and so forth
hope this helps,
Jos
>
a short way:
open I, "file.txt" or die $!;
while () { print /(\S+)/ }
hope this helps,
Jos Boumans
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
ok, this is untested, but i think something like this would work just nicely
for you:
@nums = $str =~ /@id='(\d+)'/g;
first element of @nums would be 1, 2nd would be 2 etc
if you're sure only the @ids have numbers in them, you could even suffice by
saying:
@nums = $str =~ /(\d+)/g;
your regex
sorry for the spam, testing if i can receive mail again from lists.
Jos Boumans
Try this:
unless( $options{a} && $options{b} ) { do_stuff }
if both of those 2 keys have a value in the hash, the && will return true,
and the do_stuff won't get exuted
you can also use
if( !$foo && !$bar ) or some construct like that, but i find that less
legible...
also, if you want to have
Don't do the "put a file into an array" trick if you're not VERY sure the
file is small.
It's generally concidered bad programming practice and a recipe for disaster
if you dont control the input.
having said that, i'd like to note that there's also a memory penalty for
using an array over a stri
Sure, you can connect to a mysql database using the DBI module, available
from cpan.org
you'll also need to install the dbd driver (DBD::Mysql).
Then you can query your data just like you would at a mysql prompt
the documentation is quite extensive, and here's an article that should get
you start
On a side not, you might want to concider using the:
use CGI::Carp qw(fatalsToBrowser);
it will direct STDERR to your browser, so you can see where the error is in
the script if any.
hth,
Jos Boumans
- Original Message -
From: "David Wood" <[EMAIL PROTECTED]>
To: "Rahul Garg" <[EMAIL P
getting output immediately of an application started with open-commandI think what you
want is :
$| = 1;
that enables 'flushing' of the output, ie, doesnt buffer it, but prints right away.
hth
Jos Boumans
- Original Message -
From: Heiko Kundlacz
To: [EMAIL PROTECTED]
Sent: M
One: don't put all those ! in your subject, it's quite annoying
Two: there's a beginners cgi list for just this sort of question
Three: if you want help, you might want to concider describing your problem
a bit more, as well as showing some code
Four: You might want to check, if you're on linux, w
we use bpbatch to run on the NIC which works fine.. but that's all in C, not
perl...
in fact, i dont think i could point you to a perl module that does this...
sorry
Jos Boumans
- Original Message -
From: "Papo Napolitano" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July
1 - 100 of 198 matches
Mail list logo