On Fri, 1 Mar 2002, Troy May wrote:
> What do the letters after the "%02" mean? I know about "%02d", but I came
> across a few scripts with "%02u" in it. I've never seen that, what does it
> mean? What's the difference between the "d" and the "u"? And what ELSE can
> you possibly use there?
Check the documentation on sprintf(). I don't have perl with me, but I
think "perldoc -f sprintf" will find it, otherwise you can look through the
perlfunc section of the docs for sprintf. Offhand I'd guess that %02u
refers to an unsigned integer in decimal format?
-Original Message-
What do the letters after the "%02" mean? I know about "%02d", but I came
across a few scripts with "%02u" in it. I've never seen that, what does it
mean? What's the difference between the "d" and the "u"? And what ELSE can
you possibly use there?
--
To unsubscribe, e-mail: [EMAIL PROTECTED
I have a hash tables that looks like this:
my(%data) = ();
my($csid) = '';
$data{$csid} = {};
$data{$csid}{duration_on} += 0;
$data{$csid}{duration_off} += 0;
$data{$csid}{under_peak} += 0;
$data{$csid}{over_peak} += 0;
$data{$csid}{under_off} += 0;
$data{$csid}{ov
You should change the line
die "Device::SerialPort Aborted without match\n" unless (defined $data);
to read
die "Device::SerialPort Aborted without match\n" unless (defined
$bytein);
But be careful because the 'lookfor' method causes Device::SerialPort to
return an entire line (up to t
All I have to say is... (perldoc perlsyn; goto line 145)
The following compound statements may be used to control
flow:
if (EXPR) BLOCK
if (EXPR) BLOCK else BLOCK
if (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK
LABEL while (EXPR) BLOCK
LAB
The perlsyn doc says that "foreach" is a synonym for "for", so the two are
indeed interchangable. But you should also note that there are 2 different
"modes" in which the for/foreach statement works.
If you use it in the C-style "for($x=1; $x<10; $x++) {}" way, then $x is not
localized to the lo
Tony Ho wrote:
>
> Hi guys
Hello,
> I was wondering if you could help me
>
> I have 2 files.
> One file has 3 data rows, A, B and C
> The file has 1 data row D.
>
> I need to append row D to rows A and C in the first file, based on some
> condition.
> Any ideas how I could go about this ?
>
Jon Molin wrote:
>
> Jan Gruber wrote:
> >
> > Hi, Jon && list !
> > On Friday 01 March 2002 11:29 am, you wrote:
> > > Hi list!
> > >
> > > I've always thought there's a difference between for and foreach, that
> > > for uses copies and foreach not. But there's no diff is there?
> >
> > AFAIK th
Ok, I actually gave this a shot, and it works...sort of.
However, the original die still prints out the first argument of the array
which is an array reference. However, you can change what die is called
with from your die_handler by calling die again, so if you just want to
print a message, I w
Hi Papo,
Thank you very much for your information. I can send to serial port from my
script now. But when I try to read from the port, my script died and showed
"Device::SerialPort Aborted without match". Do you have any idea about how
can I fix the problem? My script is as followed.
#!/usr/bi
Instead of sendmail simply use mail or mailx. See script below.
Please make sure you change the From: addy... to a valid email address, you
do not
want your email server to be black listed. You know what I mean? That's
bad.
#!/opt/local/bin/perl
#---
Oops, sorry it was just pointed out to me today that this was already asked
today :) There are over 1000 unread messages in my Perl folder and I didn't
think to look through them all
On Friday 01 March 2002 11:52 am, you wrote:
> I'm really curious what the point of foreach is considering for d
On Mar 1, Sethi, Pradeep said:
>I have this in my code :
>
>local $SIG{__DIE__} = \&die_handler;
>
>sub die_handler {
> my (@vars)=@_;
> print STDERR "\nfirst : " . $vars[0];
> print STDERR "\nsecond : " . $vars[1];
>}
>
>if i give :
>
>die ('goo','foo','bar');
>
>Then I get the output :
>
>fi
According to
perldoc -f die
and
perldoc perlvar # look at %SIG{expr}
the die_handler will be called with the string die was passed. From the
perldoc -f die, die will concatenate all parameters together. Therefore,
your problem makes sense. You might try passing an array reference
containing th
I am trying to get this program to send mail. Unfortunately I am having
a hard time using sendmail. Could someone please help me out.
Thanks,
##Error Reporting
sub Notifyanddie {
my $message = shift;
open(MAIL, "|/usr/lib/sendmail -t -i")
or die "Couldn't open sendmail $!\n";
print M
On Fri, 2002-03-01 at 14:52, James Taylor wrote:
> I'm really curious what the point of foreach is considering for does the same
> exact thing? For example:
>
> @myarray = (1 .. 10);
>
> for (@myarray) {
>print "$_\n";
> }
>
>
> Or, you could swap the for for a foreach and the same thing
On Fri, 2002-03-01 at 14:52, James Taylor wrote:
> I'm really curious what the point of foreach is considering for does the same
> exact thing? For example:
>
> @myarray = (1 .. 10);
>
> for (@myarray) {
>print "$_\n";
> }
>
>
> Or, you could swap the for for a foreach and the same thing
On Fri, 2002-03-01 at 14:43, Joseph Bajin wrote:
> I am trying to get this program to send mail. Unfortunately I am having
> a hard time using sendmail. Could someone please help me out.
>
> Thanks,
>
> ##Error Reporting
> sub Notifyanddie {
> my $message = shift;
> open(MAIL, "|/usr
I'm really curious what the point of foreach is considering for does the same
exact thing? For example:
@myarray = (1 .. 10);
for (@myarray) {
print "$_\n";
}
Or, you could swap the for for a foreach and the same thing would get
accomplished... The only difference I can think of is a sli
[EMAIL PROTECTED] [[EMAIL PROTECTED]] quoth:
*>
*>$string =~ s/^\s+//; Removes leading whitespaces
*>
*>$string =~ s/^\s+//g; /g (GLOBALLY) is redundant in the
*>case of "leading whitespages"
For a beginner, it's a not a critical detail.
e.
--
To unsubscribe,
> If I have a string and the first character is a space,
> may not always be a space.
> Example: John
> Tommy
> Beth
>
> John and Beth have a space, Tommy does not.
> How do I strip that. I do not want to use the global
> command because a want the space between Fir
The registry changes made by ActivePerl are mainly to register the program
so that you can uninstall it and create the appropriate file associations
with .pl files. We run a perl script as part of our login process. So that
we don't have to install it on all of the clients, we run it from the
n
$string =~ s/^\s+//; Removes leading whitespaces
$string =~ s/^\s+//g; /g (GLOBALLY) is redundant in the
case of "leading whitespages"
See PERL Cookbook page 30 for the answer to your question.
__
William Ampeh (x3939)
Federal Reserve Board
Thank you! While, what I worry about is that the Registry changes made buy
Active, will it effect my script which using a downloaded module not a
default installed module?
"Timothy Johnson" <[EMAIL PROTECTED]> wrote in message
C0FD5BECE2F0C84EAA97D7300A500D5002581012@SMILEY...">news:C0FD5BECE2F0C8
Tanton Gibbs [[EMAIL PROTECTED]] quoth:
*>
*>The regular expression
*>s/^\s//;
s/^\s+//g; would be even better as it would remove all whitspace at the
beginning of a line and it would replace all matches to the pattern
instead of just the first it finds.
e.
--
To unsubscribe, e-mail: [EMAIL P
my @arr = (" This has a leading space", "This does not" );
foreach my $string (@arr ) {
$string =~ s/^\s//;
print $string, "\n";
}
prints:
This has a leading space
This does not
The regular expression
s/^\s//;
means
s/ # substitute
^ # at the beginning of the string
\s
If I have a string and the first character is a space,
may not always be a space.
Example: John
Tommy
Beth
John and Beth have a space, Tommy does not.
How do I strip that. I do not want to use the global
command because a want the space between First
and Last name.
Yeah, yeah. So I made a typo. :p
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 01 March 2002 18:00
To: [EMAIL PROTECTED]
Subject: TIMTOWDI Was: RE: some questions about for, foreach
It is really sad when people can't get their MLA
(Multi-Letter Acronym) cor
On Friday, March 1, 2002, at 10:22 , John Edwards wrote:
> I think it lies in the history of programming. Traditionally for loops
> look
> like this (when written in perl)
>
> for($i=1; $i<=100; $i++){
>print "$i\n";
> }
One could write, as an alternative to for:
$i=1;
while ($i<=100) {
On Fri, 1 Mar 2002, Brett W. McCoy wrote:
> On Fri, 1 Mar 2002, Dennis G. Wicks wrote:
>
> > It is really sad when people can't get their MLA
> > (Multi-Letter Acronym) correct!
> >
> > It should be TIMTOWTDI
> >
> > "There Is More Than One Way To Do It"
>
> I prefer
Err, ignore that... I h
On Fri, 1 Mar 2002, Dennis G. Wicks wrote:
> It is really sad when people can't get their MLA
> (Multi-Letter Acronym) correct!
>
> It should be TIMTOWTDI
>
> "There Is More Than One Way To Do It"
I prefer
http://www.chapelperilous.net/
-
On Fri, 1 Mar 2002, Nikola Janceski wrote:
> what the heck is TIMTOWDI?
It's TMTOWTDI
There's More Than One Way To Do It 00 pronounced like tim-toady.
-- Brett
http://www.chapelperilous.net/
-
It is really sad when people can't get their MLA
(Multi-Letter Acronym) correct!
It should be TIMTOWTDI
"There Is More Than One Way To Do It"
which is the Perl Hackers motto.
Good Luck!
Dennis
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROT
what the heck is TIMTOWDI?
I tried it at acronym finder and nothing..
http://www.acronymfinder.com/af-query.asp?String=exact&Acronym=TIMTOWDI&Find
=Find
-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 01, 2002 10:22 AM
To: 'Jon Molin'; [EMAIL PROTECT
On Mar 1, Jon Molin said:
>I've always thought there's a difference between for and foreach, that
>for uses copies and foreach not. But there's no diff is there?
>From perlsyn, "Foreach Loops":
The foreach keyword is actually a synonym for the for
keyword, so you can use for
On Fri, 1 Mar 2002, Jon Molin wrote:
> > It merely depends on your preferences, readable/maintanable code vs
> > quick && dirty.
>
> if there's no difference, what's the point of having both? I can't see
> how readable/maintanable would increase by adding functions with the
> same name, it'd rath
I think it lies in the history of programming. Traditionally for loops look
like this (when written in perl)
for($i=1; $i<=100; $i++){
print "$i\n";
}
while foreach loops look like this.
@array = qw(one two three);
foreach (@array) {
print "$_\n";
}
Even though you can do
for (@a
On Mar 1, Jon Molin said:
>Jan Gruber wrote:
>>
>> On Friday 01 March 2002 11:29 am, you wrote:
>> >
>> > I've always thought there's a difference between for and foreach, that
>> > for uses copies and foreach not. But there's no diff is there?
>>
>> AFAIK there's not really a difference betwee
Hmmm. I tried putting in the icmp instead, but because I am not root I
am unable to run it. I don't understand why I can ping it from the
command line just fine but not in this program.
Any more ideas.
[EMAIL PROTECTED] wrote:
>Try changing the line below to:
>
>$t = Net::Ping->new('icmp');
>
Hi, Joseph && list !
On Friday 01 March 2002 02:44 pm, you wrote:
> I am appearing to have some
> troubles. It appears that it can not reach the hosts specified, but when I
> try it manually it works just fine.
# use TCP if we're not root, ICMP if we are
my $pong = Net::Ping->new( $> ? ("tcp",
Try changing the line below to:
$t = Net::Ping->new('icmp');
by default Net::Ping uses UDP packets, but not all hosts will respond to
this.
-Original Message-
From: Joseph Bajin [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 27, 2002 8:43 AM
To: [EMAIL PROTECTED]
Subject: Trouble
Jan Gruber wrote:
>
> Hi, Jon && list !
> On Friday 01 March 2002 11:29 am, you wrote:
> > Hi list!
> >
> > I've always thought there's a difference between for and foreach, that
> > for uses copies and foreach not. But there's no diff is there?
>
> AFAIK there's not really a difference between
From: Roman Fordinal <[EMAIL PROTECTED]>
> why i can compile PERL script under Linux to binnary?
I think you meant "HOW" :-)
I believe there is a Linux version of PerlApp from ActiveState
See http://www.ActiveState.com , look for Perl Development Kit.
You might also try perl
I am appearing to have some
troubles. It appears that it can not reach the hosts specified, but when I
try it manually it works just fine. Here is what I have for my code:
#!/usr/bin/perl -w
use strict;
use Net::Ping;
Initalize Variables#
my @hosts= qw(au)
why i can compile PERL script under Linux to binnary?
:
:.. Roman Fordinal
:.: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
I would use the second approach. I would think that it would be better
performance-wise, not to mention I always like to have a backup in case
things don't work the way I expected.
Alother thing you have to try to do is only read in as much data at one time
as you need to, because a million rows
Hi, Jenda !
- code snipped -
Grr, i was playing around with eval and bless, but forgot the KISS !
Thx,
Jan
--
cat /dev/world | perl -e "while (<>) {(/(^.*? \?) 42 \!/) && (print $1)}"
errors->(c)
_
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECT
Hi guys
I was wondering if you could help me
I have 2 files.
One file has 3 data rows, A, B and C
The file has 1 data row D.
I need to append row D to rows A and C in the first file, based on some
condition.
Any ideas how I could go about this ?
Another alternative would be for me to open up
From: Jan Gruber <[EMAIL PROTECTED]>
> I'm trying to build a linked list, containing hashrefs.
> Walking through the %HashRef (-x %HashRef) i can see a lot of
> 'REUSED_ADDRESS'es in the list. At the end, all refs point to one
> single adress, so every HashRef in my list points
Hi, List !
I'm trying to build a linked list, containing hashrefs.
Walking through the %HashRef (-x %HashRef) i can see a lot of
'REUSED_ADDRESS'es in the list. At the end, all refs point to one single
adress, so every HashRef in my list points to the same hash.
I have considered trying the OO
Hi, Jon && list !
On Friday 01 March 2002 11:29 am, you wrote:
> Hi list!
>
> I've always thought there's a difference between for and foreach, that
> for uses copies and foreach not. But there's no diff is there?
AFAIK there's not really a difference between these two.
It merely depends on you
The problem lies in the second loop. Each time through the loop I am
writing to a separate file, which appears to be working, the body of the
report is in each file. The header is what I am having problems with. I
want to change the page length so the header appears at the top of each file
inste
Hi list!
I've always thought there's a difference between for and foreach, that
for uses copies and foreach not. But there's no diff is there?
my @a = (1, 2, 3 , 4 , 5);
$_ += 2 for (@a);
print "@a\n";
3 4 5 6 7
my @a = (1, 2, 3 , 4 , 5);
$_ += 2 foreach (@a);
print "@a\n";
3 4 5 6 7
why isn
++
Please read the disclaimer at the bottom of this e-mail.
++
TMTOWTDI.
I havent got my "Mastering regular Expressions Book" at hand, so Im sure
the syntax is wrong, but you get the drift...
55 matches
Mail list logo