Hi there,
I'm trying to setup a SMTP connection to a server. From the Perl Cookbook
I got the following:
1) To start a new connection:
$mailer = Mail::Mailer->new ("smtp", "smtp.mydomain.com") ;
2) To open a connection (this is were the problem is I think), I tried the
following
three:
$mail
> # form a script
> local($^I, @ARGV) = ('.bak', glob("*.c"));
> while (<>) {
> if ($. == 1) {
> print "This line should appear at the top of each
file\n";
> }
> s/\b(p)earl\b/${1}erl/i;# Correct typos,
pres
Oops, hadn't finished.
's/(^\s+test\s+)\d+/ $1 . ++$count /e'
Breaking this down,
s/foo/bar/
means, search $_ ($_ is the current line in many
scripts) for something, and then replace what is
matched with something else.
s/foo(bar)baz/$1/
replaces foobarbaz with bar. Parens "captu
Simplifying:
> # Renumber a series of tests from the command line
> perl -pi -e 's/(^\s+test\s+)\d+/ $1 . ++$count /e'
t/op/taint.t
This is what is called a "one-liner".
One enters the above at a shell prompt (command line).
The "perl -pi -e" combo is a common one for quick on
> What would be the easiest way to capture [stderr]?
One way:
$output = `$cmd 2>&1 1>$null`;
$null depends on the os; /dev/null on unix, /nul on an M$ OS.
Kirk,
The most popular tutorial book for Perl is "Learning Perl" by Randal
Schwartz et al. . I started learning from it, and look where I am now
*grin*
The 3rd edition should be coming out next month, so you may want to hold
off on it and read some online docs 'till then, as it will probabl
I'm having difficulty fully understanding what this code is
saying/doing... Could someone please, break it down for me into step
by step pseudocode? Thank you in advance.
# Renumber a series of tests from the command line
perl -pi -e 's/(^\s+test\s+)\d+/ $1 . ++$count /e' t/
Folks,
What would be the easiest way to capture time output?
that is the output from time -p ps -ef > /dev/null,
time prints it output on stderr. I was going to use qx()
but that will not work, seeing qx (to my knowledge) does not
catch stderr correct?
I had another idea, but that is revert back
Hya,
At 03:22 PM 13/06/2001 -0700, Hans Holtan wrote:
>Hi everyone,
>
>I'm a bit green, and I'm trying to split a large file into a hash. My
>problem is that the parts that I want to use as keys are a bit long
>(100-200 letters), and I will need to pull them out by the presence of
>certain sub
At 10:56 AM 6/14/01 +0900, Gupta, Ashish wrote:
> >From where is the value of @INC initialized by Perl ?
It's compiled in when perl is built. Do a strings `which perl` | grep /
and you'll see it.
>Can I change the value of @INC from within my program or from the
>environment ?
Both. The form
>From where is the value of @INC initialized by Perl ?
Can I change the value of @INC from within my program or from the
environment ?
***
This communication is confidential and is intended only for the person
to whom it is
OK, I had to try the two ways again to see how much difference it made. I
created a random contents fixed field file 14500 lines long X 80 columns
wide, and tried processing the lines (using substr($_,)to break lines up
into 4 sections, substitute based on a few patterns, and change a couple o
On Wed, Jun 13, 2001 at 04:30:01PM -0700, David Kenneally wrote:
> Hello-
>
> This is a really basic question, sorry. Can anybody tell me why I get the
> following error when I run this script:
>
> "Use of uninitialized value in numeric lt (<) at ./x2 line 8"
"Use of uninitialized value" means
I think "Learning Perl" by Randal Schwartz and Tom Christiansen covers more than
"Learn Perl in 24 Hours".
If you "really" wanna know something about regex, try "Mastering Regular
Expressions" by Jeffrey Friedl, and enjoy ;=)
Of course, you can always consult "Programming Perl" by Larry Wall,
Dave Watson [[EMAIL PROTECTED]] quoth:
*>
*>Using ExtUtils::Installed like;
Thank you for attributing the FAQ :)
I can't say enough good things about Alan Burlisons oft overlooked
ExtUtils modules that have been in the core since 5.005 as I recall. There
are lots of fun features to them and I wh
Hello-
I get the error both when it is quoted and when it is not. It still works,
and I guess this is just a notification, but I was hoping there might be a
more correct way.
Thanks!
David "Not quite a Saint" Kenneally
>David,
>Verily, on Wednesday June 13, 2001, the Sainted David Kenneally
--scott lutz <[EMAIL PROTECTED]> [010613 16:17]:
> Is there a command to list all installed modules?
> _
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
Yes. There are a few ways.
perldoc perl
David,
Verily, on Wednesday June 13, 2001, the Sainted David Kenneally spake:
> #!/usr/bin/perl -w
>
>
> opendir DIRH, "/home/dwk/test" or die "can't open it: $!\n";
> @allfiles = readdir DIRH;
> closedir DIRH;
> foreach $temp (@allfiles) {
> if (-M $temp < "0.5") {
>print "$temp\n";
>
Hi all,
The point of this script is to get arround setting application MIME types on
the server for when you don't have the right to do that on your server. It
will fetch any file as any MIME type. It adds the file extension and
defaults to "example.opx" if there is no filename given.
However, I
There are a few ways. My favorite is to use:
perl -MCPAN -e autobundle
This will create a file (and display) all modules installed in the @INC paths,
as well as their versions. It also tells you the versions currently on the
CPAN.
perldoc CPAN
for more information on the useful CPAN module.
Hello-
This is a really basic question, sorry. Can anybody tell me why I get the
following error when I run this script:
"Use of uninitialized value in numeric lt (<) at ./x2 line 8"
#!/usr/bin/perl -w
opendir DIRH, "/home/dwk/test" or die "can't open it: $!\n";
@allfiles = readdir DIRH;
clo
At 11:17 PM 6/13/01 +, scott lutz wrote:
>Is there a command to list all installed modules?
http://www.cpan.org/misc/cpan-faq.html#How_installed_modules
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com
Is there a command to list all installed modules?
_
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Can you give us an example of the code that is not connecting, or not
working? It's pretty difficult to answer with no more than we have to go on.
Steve Howard
-Original Message-
From: justin todd [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 13, 2001 7:22 AM
To: Beginners (E-mail)
Su
The reason I preferred to read a file into an array (when it is manageable)
then processing it is because of my understanding of what is occurring with
IO. It seems to bear out in the performance when I have tested the two side
by side. When you are using:
while ()
you are accessing the disk for
Regexes (regular expressions) are pretty important - I'm surprised the "24
hours" book didn't mention them.
I'd suggest reading O'Reilly's "Learning Perl" (aka "the llama book") for a
healthy introduction to regexes.
chad
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECT
On Wed, Jun 13, 2001 at 06:00:34PM -0400, F.H wrote:
>
> Michael,
> Thanks for taking the time to solve this problem. Of course those are not real ssn
>numbers.
> I tried your suggestion:
>
>
> if ($key =~ /^Hobbies/i) {
> push @{$ssns{$ssn}{hobbies}}, [@line[2 .. $#line]];
> }
> }
At 05:32 PM 6/13/2001, you wrote:
>I join this group, and I get discussions of regexes and XML, etc. I have
>no idea what a regex is! What books have you guys (who I assume are
>beginners too, since that's the name of this board) been reading? Turn
>me into a beginner too!
>
>Kirk
Despair not.
At least we were a little more friendly about it, as well as point to some
resources that would be more help in the long run. And let's not forget
TMTOWTDI.
--SNIP--
> Fucking typical.
--SNIP--
> I hope this answer is more useful than that suggested by the others.
On Wednesday, June 13, 2001, at 12:05 PM, Ward, Stefan wrote:
> Does anyone have an example of a way to write a perl script that will
> go out
> hit a data base table, pull in a column for that table and use that
> column
> in a dropdown list? I know what to do once I get that variable
> sel
Hi everyone,
I'm a bit green, and I'm trying to split a large file into a hash. My
problem is that the parts that I want to use as keys are a bit long
(100-200 letters), and I will need to pull them out by the presence
of certain substrings later. So my actual question is this, how do I
retre
Hi,
Let me just clarify that in this loop where it doesn't work:
foreach $i ( 0 .. $#{ $ssns{$ssn}{hobbies} } ) {
print " $ssns{$ssn}{hobbies}[$i]";
}
I need to be able to access through maybe a multidemensional array each elemnt of the
hobbies.
Thanks
I.S
[EMAIL PROTECTED]
Well a regex is a regular expression ... I am pretty sure you will come round
to it eventually if you go info hunting on perl. A good book that I always
recommend (for beginners) is "Learning Perl" published by O'Reilly.
It is a bit difficult for a beginner sometimes as Perl can be used for so m
On Wed, 13 Jun 2001 [EMAIL PROTECTED] wrote:
> I read Learn Perl in 24 Hours. I did the exercises in the book, and I wrote
> a couple web pages where you could submit a text file that would be posted
> onto the web (i.e. joke of the day sites). I've written scripts that have
> taken
> files of
Michael,
Thanks for taking the time to solve this problem. Of course those are not real ssn
numbers.
I tried your suggestion:
if ($key =~ /^Hobbies/i) {
push @{$ssns{$ssn}{hobbies}}, [@line[2 .. $#line]];
}
}
# print results
print "\n TEST: $ssns{'123-43-4352'}{'hobbies'}[2][2
At 04:32 PM 6/13/01 -0500, [EMAIL PROTECTED] wrote:
>I read Learn Perl in 24 Hours. I did the exercises in the book, and I wrote
>a couple web pages where you could submit a text file that would be posted
>onto the web (i.e. joke of the day sites). I've written scripts that have
>taken
>files of
> I've tried placing [ ] around each variable,
Stop, don't run and read "perlre" before you trying to use any special
regex characters.
When you put characters inside [] it means "any character" and it doesn't mean
"the whole word"
[abcd] = "a or b or c or d" and not "abcd"
> using the || ope
ASCII 12 is a new page to printer.
Steven Scott
Team Lead
Email: mailto:[EMAIL PROTECTED]
Web: http://www.invatron.com
Invatron Systems Corp.
5710 Timberlea Blvd.,
Suite 201,
Mississauga, Ontario
L4W 4WI
Telephone: (905) 282-1290 x40
Fax: (905) 282-1266
- Original Message -
From: "E
I read Learn Perl in 24 Hours. I did the exercises in the book, and I wrote
a couple web pages where you could submit a text file that would be posted
onto the web (i.e. joke of the day sites). I've written scripts that have
taken
files of lists of labels, compared them, then built a list of the
This should help :
http://dbi.symbolstone.org/
http://search.cpan.org/doc/TIMB/DBI-1.18/DBI.pm
On Wed, Jun 13, 2001 at 04:09:29PM -0400, F.H wrote:
[snip]
> $ssns{$ssn}{hobbies}[0][2] which should yield H3
> $ssns{$ssn}{hobbies}[3][0] to get HG.
[snip]
> if ($key =~ /^Hobbies/i) {
> push @{$ssns{$ssn}{hobbies}}, @line[2 .. $#line];
> }
>From this, your data structure i
Hey, thank's for the answers !
Although, I didn't ask the question but I was occasionally thinking
about it. "\r" and "\b" - great !
As once I was pointed to the ASCII character causing the printer to
start a new page .. Btw, I've forgot it - does anybody know it ?
11 ?
> I'm very new to perl (a
perlop, qx// operator :
> To read both a command's STDOUT and its STDERR separately, it's
> easiest and safest to redirect them separately to files, and
> then read from those files when the program is done:
>
> system("program args 1>/tmp/program.stdout 2>/tmp/program.stderr");
So, if I was y
> Subject: testing on email characters
I just wanted to expand on Jeff Yoaks comment that the regexes discussed in
this thread don't actually validate syntax on _all_ e-mail addresses. I
think this is a common problem. I remember looking this up in 'Mastering
Regular Expressions' (though I don
Always, always proofread your work, Sigh. I meant to say:
Line 14 should be:
print $mail->child('smtp_server')->value;
not
print $mail->child('smtp_server')->{VALUE};
On 13 Jun 2001 16:46:06 -0400, Chas Owens wrote:
> line should be:
> print $mail->child('smtp_server')->va
At 06:45 PM 6/12/01 +0200, Jos Boumans wrote:
>Please, if you try and flame posts, get your facts straight.
That seems a little harsh. I don't think it was intended as a flame or to
be insulting in any way. It was just suggesting what the author thought
was a better way to do it. :-)
>2nd:
line should be:
print $mail->child('smtp_server')->value;
not
print $mail->child('smtp_server')->{VALUE};
On 13 Jun 2001 20:25:18 +, Stout, Joel R wrote:
> I took the example from
> http://www.xml.com/pub/a/2001/04/18/perlxmlqstart1.html
> I wanted something really simple for
You're a beginner?
-Original Message-
From: Stout, Joel R [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 13, 2001 3:25 PM
To: [EMAIL PROTECTED]
Subject: XML::Parser XML::SimpleObject -> First XML parsing pls help
I took the example from
http://www.xml.com/pub/a/2001/04/18/perlxmlqst
I took the example from
http://www.xml.com/pub/a/2001/04/18/perlxmlqstart1.html
I wanted something really simple for XML parsing that basically just reads
values. But I'm stuck (again).
#Here's what I'm trying to run:
#!c:\perl\perl.exe
use XML::Parser;
use XML::SimpleObject;
use strict;
my
On Wed, 13 Jun 2001, Bryan Gmyrek wrote:
> Hi, I tried to do this, but it didn't really work because first I
> declare an array like this:
> my @day;
>
> Then I did as you said...
>
> Then, I add information using things like:
>
> $day[$ext]{$line[2]}{$line[0]}{pages}=$line[1];
Oh, yeah, you're
On 13 Jun 2001 13:39:49 -0400, Craig S Monroe wrote:
> Chris,
> I appreciate you responding to my message, but I don't understand some of
> the
> issues you were speaking about.
>
> "you want to use backticks " I do not understand what you mean by this?
> Where should I be using them? In place of
Hi All,
Here is my problem with the script below:
I can access each item from each line. But I got stuck trying to figure
out how to access each hobbies/sports lines!!
I need to be able to get data from for instance:
$ssns{$ssn}{hobbies}[0][2] which should yield H3
$ssns{$ssn}{hobbies}[3][0
On Wednesday 13 June 2001 12:22 pm, Peter Scott wrote:
> At 12:05 PM 6/13/01 -0700, Ward, Stefan wrote:
> >Does anyone have an example of a way to write a perl script that will go
> > out hit a data base table, pull in a column for that table and use that
> > column in a dropdown list? I know wha
On Wed, Jun 13, 2001 at 02:45:40PM -0400, Brett W. McCoy ([EMAIL PROTECTED])
wrote:
> On Wed, 13 Jun 2001, Esrar Chowdhury wrote:
>
> > my question is...how do I make the read pointer read every 10th line
> > from my input file? (After reading one line, does the read pointer stay
> > on the same
At 12:05 PM 6/13/01 -0700, Ward, Stefan wrote:
>Does anyone have an example of a way to write a perl script that will go out
>hit a data base table, pull in a column for that table and use that column
>in a dropdown list? I know what to do once I get that variable selected by
>RTFriendlyM, but co
Unfortunately, perl is quite liberal with memory, so from personal
experience: have as many "my"ed variables as possible, undef things as
often as possible, and remember, that perl doesn't release memory, just
recycles it, so once it takes from the system, that's it until the end
of execution,
Brett,
Hi, I tried to do this, but it didn't really work because first I
declare an array like this:
my @day;
Then I did as you said...
Then, I add information using things like:
$day[$ext]{$line[2]}{$line[0]}{pages}=$line[1];
I checked out the database file and there was stuff like this in t
Does anyone have an example of a way to write a perl script that will go out
hit a data base table, pull in a column for that table and use that column
in a dropdown list? I know what to do once I get that variable selected by
RTFriendlyM, but couldn't find a clear example of this.
Thanks,
Ste
This appeared either on this list or the Perl-Win32 list as the same
question. You can use
select(0,0,0,25) I believe which will pause for .25 of a second. You may
need also to set autoflush to 1(ie, $|=1 ), so each IO will be displayed.
Wags ;)
-Original Message-
From: Dave Newton [m
-Original Message-
From: Michael Dube [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 12, 2001 11:19 AM
To: Perl Beginners List
Subject: Remote command execution on NT and Solaris?
I have just begun a project that will involve automated state setting on
multiple machines across multiple
On Wed, 13 Jun 2001, Esrar Chowdhury wrote:
> my question is...how do I make the read pointer read every 10th line
> from my input file? (After reading one line, does the read pointer stay
> on the same line or automatically go the next line?)
Hmmm... a homework problem?
Keep a counter that kee
One thing you could do is to read only the things you need into memory at
the time you need them to. If you change the values in the hash(es), you
could dump it to a temporary file and load them again as needed(note kind
of like a swap file does).
Another thing w
On Wed, 13 Jun 2001, Bryan Gmyrek wrote:
> I have just written a program that makes an array of hashes of hashes of
> hashes. It reads all kind of information in from a bunch of files and
> then later I access the elements of this thing in a convienient way
> because it's kind of like a little d
Bear in mind that without any sort of delay it's unlikely
you'll be able to see any of this occuring.
Ah, the good old days, where a 300-baud modem was fast
and little spinny cursors were still interesting. *sigh*
Dave
--
Dave Newton, [EMAIL PROTECTED]
On Wed, Jun 13, 2001 at 01:30:07PM -0700, Esrar Chowdhury ([EMAIL PROTECTED]) wrote:
> Hi!
>
> I just started using perl and have a question. Let say I have an inputfile
> with 100 lines. Each of these lines contain a name...first name and
> last name.
>
> I need to be able to read the 1st name.
Hi!
I just started using perl and have a question. Let say I have an inputfile
with 100 lines. Each of these lines contain a name...first name and
last name.
I need to be able to read the 1st name..the 10th name...20th name..so on
i.e. every 10th name from the input file.
I do :
$name = ; #fo
Hey, I had a similiar problem, but under different circumstances, i
found only 2 reasonable solutions: tieing the hashes to a db file, and
not storing data before printing it (print as soon as read). Tell me if
you find another solution
__END__
=sincerely, eduard grinvald
=email: [EMAIL PROTEC
At 12:46 PM 6/13/01 -0400, Tim Musson wrote:
>I was thinking along the same lines, but have another question. Why
>would you.instead of,in the print line?
>
>why
> print DATAFILE "\n\n" . '='x77 . "\n\n" . localtime;
>over
> print DATAFILE "\n\n" , '='x77 , "\n\n" , local
At 11:40 AM 6/13/01 -0500, [EMAIL PROTECTED] wrote:
>How do you evaluate a block in scalar context? Any light on this
>( or a pointer ) maybe?
$ perl -le 'do { print wantarray ? "LIST" : "SCALAR" }'
SCALAR
perlfunc should mention this under 'do', perhaps...
--
Peter Scott
Pacific Systems Design
I have just written a program that makes an array of hashes of hashes of
hashes. It reads all kind of information in from a bunch of files and
then later I access the elements of this thing in a convienient way
because it's kind of like a little database. Anyways, I end up printing
everything ou
On Jun 13, Carl Rogers said:
>Good afternoon;
>I have a dumb question: I'm working with the following:
>
>$line = "Joe Doe 123 Main St. Sometown, USA";
>
>I have parsed the line to assign the values to the following variables:
>
>$fname = "Joe";
>$lname = "Doe";
>$addr = "123 Main St.";
>
>I'm tr
Good afternoon;
I have a dumb question: I'm working with the following:
$line = "Joe Doe 123 Main St. Sometown, USA";
I have parsed the line to assign the values to the following variables:
$fname = "Joe";
$lname = "Doe";
$addr = "123 Main St.";
I'm trying to use the substitution operator to d
Thank you all for your suggestions.
I appreciate you all giving your time...
Craig
[EMAIL PROTECTED]
Pager
Numeric: 1-877-895-3558
Email pager: [EMAIL PROTECTED]
--
You will never find time for anything.
If you want time, you must make i
So wouldn't you expect the more clingy '||' to work here? It doesn't, I
checked. If operator precedence was the problem then using the higher
precedence operator should work. I think this is a logic flaw. Charles
really meant
if (exists ... and this and that) { ... }
not
i
Chris,
I appreciate you responding to my message, but I don't understand some of
the
issues you were speaking about.
"you want to use backticks " I do not understand what you mean by this?
Where should I be using them? In place of what?
I understood the incorrect use of the binding operator.
As
Dave> Well it's quite simple actually. A BLOCK of Perl code is a BLOCK of
Perl code.
Dave> No matter where you put it. Typically anything inside a set of {}'s
is a block
Dave> of code. So the fact that a subroutine consists of a block of code
Dave>
Dave> sub foo { BLOCK }
Dave>
Dave> and ma
On Wed, Jun 13, 2001 at 11:53:48AM -0400, Charles Lu wrote:
> How do I direct the messages destined for STDERR and redirect them to
> STDOUT?
>
>
>
> I have a perl script A that calls another program B. If there is bad input,
> Program B dumps out a lot of error messages through STDERR. I w
Check up my catalog at :
http://geniek.net/books/books/Programming/Perl/index-list.html
It's only a catalog but I upload titles from it upon request.
Hi, just joined the list and jumping into the middle of this thread, so
excuse me if I'm talking out of turn.
I have a couple of suggestions for you Craig.
1) Where you have
print DATAFILE
"\n\n===
==\n\n";
> I guess it's talking about *? - this will match the minimum number of times
> for a sucessful match, rather than the maximum.
Let me say the same with more formalism :
perldoc perlre :
By default, a quantified subpattern is "greedy", that is, it will match
as many times as possib
> Is the moral of this story "Don't use regexps unless nothing
> else will solve the problem?".
First, it even wasn't me who gave this idea - I met it twice in both
"Effective Perl Programming" and "Data Munging with Perl".
Second, the moral, I think, is "do whatever is good for your eyes but
t
--- Charles Lu <[EMAIL PROTECTED]> wrote:
> How do I direct the messages destined for STDERR and redirect them to
> STDOUT?
try:
*STDERR = *STDOUT;
This aliases STDERR so that it's really STDOUT anyway.
=
print "Just another Perl Hacker\n"; # edited for readability =o)
How do I direct the messages destined for STDERR and redirect them to
STDOUT?
I have a perl script A that calls another program B. If there is bad input,
Program B dumps out a lot of error messages through STDERR. I want to be
able to stop my perl script when it detects messages coming fro
On 13 Jun 2001 10:49:44 -0400, Craig S Monroe wrote:
> Hello all,
>
> I have a script that opens a socket to a device, issues some commands,
> then writes the results to a datafile.
> That all works fine. I decided that I wanted to time stamp each of the
> entries
>
> So where I put my separator
/^[\w.-]+$/ and !/[^\w.-]/ have one major difference (and I am kicking
myself for not seeing it until now). The former requires that at least
one character must exist. !/[^\w.-]/ is equivalent to /[^[\w.-]*$/.
However, this can be overcome by saying !(/^$/ or /[^\w.-]/) and it
still has one ad
--- Dianne Van Dulken <[EMAIL PROTECTED]> 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
On Jun 13, Josh said:
>Hi all,
> I'm reading Mastering Regular Expressions and it discusses a
>non-greedy version of star. can someone explain how to write this
>non-greedy version of star. (i.e. how does it differ than just *)
Thanks to Peter for plugging my modules... you might also want
--- Charles Lu <[EMAIL PROTECTED]> wrote:
>
>Lets say I want my program to print to STDOUT unless the user
> specifies that the output goes to a file. Here is my code:
>
>
>
> my $oldhandle=undef;
> if($user_input ne 'STDOUT') { #user specify output to a
> file
> open (OUT,
> -Original Message-
> From: Charles Lu [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, June 13, 2001 10:53 AM
> To: [EMAIL PROTECTED]
> Subject: Unexplainable behavior
>
> The following snippet of code doesn't behave the way I want it to. Yet i
> cannot see why?
>
>
> $hash{s} =
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 wh
On Jun 13, Charles Lu said:
>$hash{s} = "T";
>
>
>if(exists($hash{s}) and $hash{s} ne "T" or $hash{s} ne "F") {
> print "inside\n";
>}
>else{ print "outside\n"; }
'or' is less "clingy" than 'and'. Therefore, your code parses like:
if (
(exists $hash{s} and $hash{s} ne "T")
or
Try:
if(exists($hash{s}) and $hash{s} ne "T" __and__ $hash{s} ne "F") {
(underscore for emphasis, not code). Using the 'or' means that if $hash{s}
is "T", ($hash{s} ne "F") is actually true, so it continues with that block.
Cheers
Mark C
-Original Message-
From: Charles Lu [mailto:[EM
On Wed, 13 Jun 2001, 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"; }
This exp
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
Hello all,
I have a script that opens a socket to a device, issues some commands, then writes the
results to a datafile.
That all works fine. I decided that I wanted to time stamp each of the entries
So where I put my separator:
# print a section separator to the dateFile
print DATAFILE
"\n
You might want to check out Japhy's modules YAPE::Regex and
YAPE::Regex::Explain. You can pass in regular expressions and have it spit out
an explanation of what the parser is doing.
An example of (non) greedy matching would be something like:
$string = "here"; #you want to pull out the tags
an
Hi Matt
The \r option works fine, but an alternative is to use 'print "\b"' - this
will print a backspace character, and means you can have other stuff on the
line too. Try:
$|=1; for ($i=0; $i<10; $i++) {print "$i\b";sleep 1}
This method only works for single digit numbers though, since
On Wed, 13 Jun 2001, Pate Mark-marpate1 wrote:
> I'm very new to perl (a week or so), so this may not be the best way to do
> this, but
>
> for ($i=0; $i<10; $i++) {printf "%d\r",$i;}
Just to point out a more Perlish way to do this, rather the C-ish way
(since we're doing Perl and not C):
p
Hi Matt,
I'm very new to perl (a week or so), so this may not be the best way to do
this, but
for ($i=0; $i<10; $i++) {printf "%d\r",$i;}
This will (should?) print the number followed by a Carriage Return (no
linefeed), so the cursor returns to the start of the line.
Hope this is what you
I am very confused.
About a week ago I completed a site that used perl and connected to a
MSSQL7 database. Everything worked hunky dory.
Now I have to start a new script but when I try do a select query it is
as if the site goes into a internal loop. If I run the query directly on
the DB it wo
1 - 100 of 114 matches
Mail list logo