Re: very confused - chdir not working
On Fri, Oct 11, 2002 at 06:50:00AM +0100, mike wrote: > On Fri, 2002-10-11 at 05:36, Michael Fowler wrote: > > On Fri, Oct 11, 2002 at 04:16:41AM +0100, mike wrote: > > > Unfortunatel chdir does not work > > > > In what way doesn't it work? Are you getting an error? How are you > > verifying it doesn't work? > > no errors but directory does not change > with use script and -ww all I get is my output from a die statement You get output from your die statement? So, the script dies with the error "cannot change on line ..."? If that's the case, that's an error; include $! in your die and that'll tell you why the chdir failed. Also, that's the second time you've used -ww, so I'm thinking it isn't a typo. Only one -w is necessary. > > What do you see when you print $dir4? > > the previous directory ie: not changed Ok, this would imply the die is never being called, i.e. chdir never fails. So, let's clear this up; does your die ever get called? Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
how to get the last line of a file
hi, all i want to know how to get the last line of a file .i know the func read has a paramenter offset but i don't know how to use it.please help!!! thanks alex chen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to get the last line of a file
Hi, Alex i suggest the following: #!/usr/local/bin/perl -w my $filename = "Your_file_name"; # if you are so lucky to work on Unix my $lastline = `tail -1 $filename`; print $lastline; # if file is small enough to hold in an array open(FILE, $filename) or die "Can't open $filename.\n"; my @array = (); close(FILE); $lastline = $array[-1]; print $lastline; # otherwise, read file line by line and retain the last one open(FILE, $filename) or die "Can't open $filename.\n"; while($_ = ) {$lastline = $_;}; close(FILE); print $lastline; Hope it helps. alex chen a écrit : > > hi, all > > i want to know how to get the last line of > a file .i know the func read has a paramenter offset but i don't know how to > use it.please help!!! > > thanks > alex chen > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Ultra-Newbie Reformatting a text file
First of all I beg your pardon for such a stupid question, but I'm new to programming and also to Perl. The question is I've got one text message with a great amount of numbers, like this: 23845235900210848046801531651000151564186414812000441848415041848464143995 (There are a lot of lines like this) First, I have to cut the line to, for example, 25 characters. After I would like to insert in certain places (in every line, of course), for example betwen the 12 an 13 character and between the 24 and 25, and so on, some characters to split the line in fields (really this data are a text exportation of a database). Where should I begin with it?? Thanks in advance for your answer. Josep Sànchez [papapep] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to get the last line of a file
alex chen wrote: > hi, all > > i want to know how to get the last line of > a file .i know the func read has a paramenter offset but i don't know how to > use it.please help!!! the easy way (but inefficient): # read until the last line open F, "file.txt" or die $!; $last=$_ while ; the more (though probably not the *most*) efficient way: # position pointer at the end of file, and then search for newlines open F, "file.txt" or die $!; seek F, 0, 2; while ($pos = tell F) { seek F, -($pos > 1024 ? 1024 : $pos), 1 or die; read F, $block, 1024; $_ .= $block; do {$last=$1; print ">>$last"; last} if /.+\n(.+)/s; } print "Last line is: $last"; hope it helps. -- dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how to get the last line of a file
use Tie::File; tie @array, 'Tie::File', "file.txt" or die $!; my $last_line=$array[$#array]; José. > -Original Message- > From: alex chen [mailto:[EMAIL PROTECTED]] > Sent: Friday, October 11, 2002 8:57 AM > To: [EMAIL PROTECTED] > Subject: how to get the last line of a file > > > hi, all > > i want to know how to get the last line of > a file .i know the func read has a paramenter offset but i > don't know how to use it.please help!!! > > thanks > alex chen > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > DISCLAIMER "This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer". Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to get the last line of a file
Alex Chen wrote: > > hi, all Hello, > i want to know how to get the last line of > a file .i know the func read has a paramenter offset but i don't know how to > use it.please help!!! 1) Install http://search.cpan.org/author/URI/File-ReadBackwards-0.98/ use File::ReadBackwards; my $bw = File::ReadBackwards->new( 'file' ) or die "Cannot read 'file' $!"; my $last_line = $bw->readline; 2) Use the Tie::File module use Tie::File; tie my @lines, 'Tie::File', 'file' or die "Cannot read 'file' $!"; my $last_line = $lines[-1]; 3) Read through the whole file open FILE, 'file' or die "Cannot read 'file' $!"; my $last_line; $last_line = $_ while ; 4) Read the file like File::ReadBackwards does use Fcntl ':seek'; my $size = 1024; my $buffer = ''; my $last_line; sysopen FILE, 'file', O_RDONLY or die "Cannot open 'file' $!"; binmode FILE; my $pos = sysseek FILE, 0, SEEK_END or die "Cannot seek on 'file' $!"; while ( $pos ) { $pos = 0 if ($pos -= $size) < 0; sysseek FILE, $pos, SEEK_SET or die "Cannot seek on 'file' $!"; sysread FILE, my $temp, $size or die "Cannot read 'file' $!"; chomp( $buffer = $temp . $buffer ); if ( ( $index = rindex $buffer, $/ ) >= 0 ) { $last_line = substr $buffer, $index + length $/; last; } } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Mime::Lite can't locate object "new"
Hi I have installed MIME::Lite without any errors, but when i try to run a test program, it gives me an error saying Can't locate object method "new" via package "Mime::Lite" at ./mimelite.pl line 5 Here is the program. #! /usr/bin/perl use MIME::Lite; $aem = Mime::Lite->new( # error on this line From => '[EMAIL PROTECTED]', To => '[EMAIL PROTECTED]', Subject => 'Hello, nurse!', Type => 'TEXT/Plain', Data => "here is a gif file you wanted" ); $aem->attach( Type => 'HTML', Data => 'hello there ' ); $aem->send('smtp','mail.cybercon.net'); Regards Nitish
Cleaning lines
I'm trying to make a little perl script that reads the subject lines from email. Problem that I see is being able to correctly remove the "bad" characters, like embedding perl code into the subject line... Example: Subject: Hello `rm -rf /*` have a nice day! Would, I suspect, be a bad thing to have. True? Would it execute? Is there some safe way to be sure to catch everything? -- If wishes were horses, then beggars would be thieves. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Cleaning lines
Tom Allison wrote: > > I'm trying to make a little perl script that reads the subject > lines from email. >From files on your HD or from an SMTP server? > Problem that I see is being able to correctly remove the "bad" > characters, like embedding perl code into the subject line... > > Example: > Subject: Hello `rm -rf /*` have a nice day! > Would, I suspect, be a bad thing to have. > > True? Would it execute? It won't execute unless _you_ execute it, so don't do that. > Is there some safe way to be sure to catch everything? It is just a string like any other string. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Program Stability Issue
Below is a perl script I've been working on that logs into and checks a notes email account for new messages once every second. When it finds a new message it tests for a password, and if it success it process's the email. The script will based on what is in the email either run another script, or do anything that can be done form a command line on the system it is running on. It then clears the mailbox, then goes back into the loop where it checks for any mail. The original propose for this program was to allow me to do some diagnostics remotely via email (usually my blackberry handheld), but I've already found dozens of other uses for it. The problem is that the script is supposed to loop basically forever until it finds something. It does this for awhile. The program works for about 24 hours at which point it just stops. I've tried changing to loop time from 1 second to 10, and even 30 seconds, but it still crashes after about 24 hours. I've never managed to be around when this happens to try to figure out what is going on. Looking for improving programs stability, or even ideas on how to get it to log what is going wrong. Only thing I can think of is having it open a text file, and have every line in the program log it's execution in some way. I've also already added lines that force it back into the waiting loop at almost every stage I can think of it possibly halting, but that has had little of any effect it seems. If anyone has any ideas on how to improve this programs stability, how to make perl programs more stably in general, or even a possible reason why this, or any general purpose program might crash for unknown reasons let me know. Looking for input of any kind on this issue. Have been thinking of writing some simple but very system specific network monitoring apps using perl and I really need to prove to myself that I can keep a perl script running for weeks at a time before I even start. use strict; use warnings; use diagnostics; use Win32::OLE; #Notes database Info my $userid = "xx"; my $server = "x/xxx/xxx"; #Log into Notes database my $Notes = Win32::OLE->new('Notes.NotesSession'); my $Database = $Notes->GetDatabase("$server", "mail\\$userid.nsf"); #Loop a check for mail once every second, send a '.' to console for monitoring WAIT: sleep 1; print "."; my $AllDocuments = $Database->AllDocuments; my $Document = $AllDocuments->GetFirstDocument or goto WAIT; #Process mail my $From = $Document->GetFirstItem('From')->{Text} or goto WAIT; my $Password = $Document->GetFirstItem('Subject')->{Text}; my $Command = $Document->GetFirstItem('Body')->{Text}; my $Subject = "CMD: $Command"; #Password Check - Password must be in subject line of email unless ($Password eq "xyz") {goto BADPASS} #execute command my $Report = `$Command`; print "!"; #Send reply mail SENDMAIL: my $ReportMail = $Database->CreateDocument('NEW') or goto WAIT; $ReportMail->{Form} = 'Memo'; $ReportMail->{Body} = "$Report"; $ReportMail->{SendTo} = "$From"; $ReportMail->{Subject} = "$Subject"; $ReportMail->Save(1, 1); $ReportMail->Send(0); #Clear the mailbox foreach (1..3) { my $AllDoc = $Database->AllDocuments or goto WAIT; my $delete = $AllDoc->GetFirstDocument or goto WAIT; $delete->Remove(1) or goto WAIT; } goto WAIT; #Password Fails - Reformat reply mail and log the attack BADPASS: $Report ="You do not have access to this system. This attack has been logged"; $Subject = "ACCESS DENIED"; open(BAD, ">>BADPASS.TXT") or goto WAIT; print BAD "\n\nACCESS VIOLATION: \nFrom: $From\nSubject: $Password\nBody:\n\n$Command \n\n " or goto WAIT; close(BAD); print "#" or goto WAIT; goto SENDMAIL; goto WAIT; # Chris Benco Network Administrator Austin Powder Company 216-464-2400 x277 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Cleaning lines
Tom Allison said: > I'm trying to make a little perl script that reads the subject > lines from email. > > Problem that I see is being able to correctly remove the "bad" > characters, like embedding perl code into the subject line... > > Example: > Subject: Hello `rm -rf /*` have a nice day! > Would, I suspect, be a bad thing to have. > > True? Would it execute? That depends on what you do with it. If it's just a string that you are passing around there's no problem. If you (string) eval the subject for some reason then you should be wary. If it gets to the shell somehow, maybe by using it as a filename to open, then you should also be careful. > Is there some safe way to be sure to catch everything? A magic bullet? I doubt it. There's no substitute for thinking hard about what you want to do. But, Use strict, warnings and tainting. It's probably safer to specify the characters which are allowed, rather than those which aren't. And the smaller you can make that set, the less you'll have to worry about. Of course, that goes against the principal of being liberal in what you accept, so you'll have to make your own judgement. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Ultra-Newbie Reformatting a text file
From: papapep <[EMAIL PROTECTED]> > First of all I beg your pardon for such a stupid question, but I'm new > to programming and also to Perl. > > The question is I've got one text message with a great amount of > numbers, like this: > > 23845235900210848046801531651000151564186414812000441848415000 > 0041848464143995 > > (There are a lot of lines like this) > > First, I have to cut the line to, for example, 25 characters. After I > would like to insert in certain places (in every line, of course), for > example betwen the 12 an 13 character and between the 24 and 25, and > so on, some characters to split the line in fields (really this data > are a text exportation of a database). You should start with a decent introductory book :-) The script might be something like this: #!perl use strict; my $file = shift() or die "Usage: reformat.pl inputfilename outputfilename\n"; my $outfile = shift() or die "Usage: reformat.pl inputfilename outputfilename\n"; open IN, '< '.$file or die "Cannot open file '$file' for reading: $!\n"; open OUT, '> '.$outfile or die "Cannot open file '$outfile' for writing: $!\n"; while () { # read the file line by line chomp(); # strip the newline $_ = substr $_, 0, 25; # only use the first 25 characters $_ =~ s/^(.{12})(.{12})(.*)$/$1 $2 $3/; # put a space after first and second 12 characters print OUT $_,"\n"; # print the result and a newline } close IN; close OUT; __END__ HTH, Jenda=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mime::Lite can't locate object "new"
> I have installed MIME::Lite without any errors, but when i try to run > a test program, it gives me an error saying Can't locate object method > "new" via package "Mime::Lite" at ./mimelite.pl line 5 Here is the > program. > > #! /usr/bin/perl > > use MIME::Lite; > > $aem = Mime::Lite->new( # error on this line Perl is case sensitive! Jenda=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Program Stability Issue
Chris Benco said: > If anyone has any ideas on how to improve this programs stability, how > to make perl programs more stably in general, or even a possible reason > why this, or any general purpose program might crash for unknown > reasons let me know. Looking for input of any kind on this issue. > > Have been thinking of writing some simple but very system specific > network monitoring apps using perl and I really need to prove to myself > that I can keep a perl script running for weeks at a time before I even > start. My first thought is that if you want stability, you are on the wrong platform. But I won't say that. Instead, I have a couple of suggestions. The first is to be wary of signals, forks and threads. You didn't tell us which version of Perl you are running, nor your exact OS, but perl didn't get safe signals until 5.8.0. Of course, Win32 does signals and forks differently to *nix, but it doesn't look like your are using these features anyway. The second is to watch out for memory usage. I don't know whether your OS has some way to monitor the memory usage of a process, but it might be worth checking. Perl has memory leaks. Many leaks have been fixed in 5.8.0, so it might be worth upgrading if you haven't already. I think that for Win32 that means compiling your own version at the moment. You might also like to try rewriting your script without the gotos. Not necessarily because of stylistic reasons, but simply because they are not used much, and it is possible that there might be memory leaks hiding behind them. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Program Stability Issue
I'm not familiar with "notes email" or the Win32::OLE module you're using, so it's unlikely that I can solve your problem. I do have a few general observations to offer though. First, checking something like e-mail every one second, may border on obsessive compulsive behavior!Seriously, I do think this time loop is a bad idea. This could potentially be a pretty significant resource drain on the computer doing the checking not to mention the checked server. My server would ban me for "flooding" shortly after I started something like this. If you need e-mail service with less than a five minute delay, I think it's time to consider a different form of communication that would meet your needs better. Second, goto programming is BAD, BAD, BAD! It creates what is often affectionately called "spaghetti code", where following the individual strands to their natural end can become maddening. Your code is short and simple, and it's still hell to follow because of those gotos. That makes it hard to get help, when you send your code to anyone. A goto call is VERY rarely ever needed in modern programming languages, so unlearn it as soon as possible. All the gotos in your script can be replaced with loops and subroutines. You used a foreach loop at one point, so I assume you're at least passingly familiar with the idea. Your main WAIT label could easily be replaced with a while loop, given a condition of 1, which will always evaluate to true and thus be infinite. Then, when you need to get back to the top of the loop, as all those gotos function, just use a call to next. For example: while (1) { # replaces WAIT: # do some processing next if CONDITION; # this sends us back to the while # more processing, if next wasn't called } # end of loop, repeats back to the while The other construct you can use to replace goto calls is a subroutine (or sub) to create a reusable chunk of code that you can call anywhere. This is how I would replace your BADPASS label, for example: sub badpass { # doesn't execute at this point, just declares # processing... return if CONDITION;# in a sub, return sends us back to the calling code # more processing, if we didn't return } # end of sub, return to calling code # we can now call this code later with... badpass(); # will execute the whole badpass sub, right here You get the idea. These are basic Perl concepts that would be in every book out there, but especially focused on in learning to program Perl type books. Learning Perl from O'Reilly is very popular, if you would like to check one out. Two other minor observations: I question the accuracy of your 1 to 3 foreach loop. It seems like magic numbers chosen instead of based on criteria like the documents available. I could be way off here though, since I don't really know what you're doing. And two, use diagnostics enables warnings, so having both is redundant. Good luck with your problem. James On Friday, October 11, 2002, at 09:31 AM, Chris Benco wrote: > Below is a perl script I've been working on that logs into and checks a > notes email account for new messages once every second. When it finds > a > new message it tests for a password, and if it success it process's the > email. The script will based on what is in the email either run > another > script, or do anything that can be done form a command line on the > system > it is running on. It then clears the mailbox, then goes back into the > loop > where it checks for any mail. The original propose for this program > was to > allow me to do some diagnostics remotely via email (usually my > blackberry > handheld), but I've already found dozens of other uses for it. > > The problem is that the script is supposed to loop basically forever > until > it finds something. It does this for awhile. The program works for > about > 24 hours at which point it just stops. I've tried changing to loop > time > from 1 second to 10, and even 30 seconds, but it still crashes after > about > 24 hours. I've never managed to be around when this happens to try to > figure out what is going on. Looking for improving programs > stability, or > even ideas on how to get it to log what is going wrong. Only thing I > can > think of is having it open a text file, and have every line in the > program > log it's execution in some way. I've also already added lines that > force > it back into the waiting loop at almost every stage I can think of it > possibly halting, but that has had little of any effect it seems. > > If anyone has any ideas on how to improve this programs stability, how > to > make perl programs more stably in general, or even a possible reason > why > this, or any general purpose program might crash for unknown reasons > let me > know. Looking for
Re: very confused - chdir not working
On Fri, 2002-10-11 at 09:14, Michael Fowler wrote: > On Fri, Oct 11, 2002 at 06:50:00AM +0100, mike wrote: > > On Fri, 2002-10-11 at 05:36, Michael Fowler wrote: > > > On Fri, Oct 11, 2002 at 04:16:41AM +0100, mike wrote: > > > > Unfortunatel chdir does not work > > > > > > In what way doesn't it work? Are you getting an error? How are you > > > verifying it doesn't work? > > > > no errors but directory does not change > > with use script and -ww all I get is my output from a die statement > > You get output from your die statement? So, the script dies with the error > "cannot change on line ..."? If that's the case, that's an error; include > $! in your die and that'll tell you why the chdir failed. > > Also, that's the second time you've used -ww, so I'm thinking it isn't a > typo. Only one -w is necessary. > > > > > What do you see when you print $dir4? > > > > the previous directory ie: not changed > > Ok, this would imply the die is never being called, i.e. chdir never fails. > > So, let's clear this up; does your die ever get called? > Just to clarify - $dir4 only gets printed if I remove the die When I add a print $dir3 it shows what it shows is this ../build.pl /root/cvs/esound # this the output of $dir3 / cannot change No such file or directory at ./build.pl line 13, line 55. this is ls in same directory, as you can see esound is there [root@localhost cvs]# ls atkesoundgnome-desktop gnome-vfs libglade librsvg bonobo-activation g2_build gnome-icon-theme gtk+ libgnome libwnck build1.pl g2buildlist gnome-mime-data gtk-doc libgnomecanvas libxml2 buildlist gail gnome-panel gtk-engines libgnomeprintlibxslt buildlist1 glib gnome-session intltool libgnomeprintui libzvt build.pl gnome-applets gnome-terminallibart_lgpl libgnomeui linc build.sh gnome-common gnome-themes libbonobo libgtop ORBit2 eelgnome-control-center gnome-utils libbonoboui libIDL pango > > Michael > -- > Administrator www.shoebox.net > Programmer, System Administrator www.gallanttech.com > -- > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- Linux, Gnome what more do you need http://www.redtux.demon.co.uk -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: very confused - chdir not working
At 11:40 AM -0400 10/11/02, mike wrote: >../build.pl >/root/cvs/esound # this the output of $dir3 >/ Is your output of 'print "$dir3\n"' : /root/cvs/esound / Or just: /root/cvs/esound From your code, I suspect the former since $dir3 is supposed to end with a "/" And from that it looks like you are forgetting to remove the line endings from the package names you read in from "buildlist" so $dir3 is "/root/cvs/esound\n/" and not "/root/cvs/esound/". Try using 'chomp' before using the package names: foreach my $pkg (@pkg){ chomp $pkg; my $dir1 = $pkg; ... You might also want to change your die statement to: or die "cannot change to \"$dir3\": $!" to get more informative error messages. ---Larry ++ | Larry Coffin, G.P.H. Watertown, MA | | http://www.PointInfinity.com/lcoffin/[EMAIL PROTECTED] | ++ COBOL programs are an exercise in Artificial Inelegance. - -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Program Stability Issue
About the resource load in having the program check once per second, I Actually though this would be a problem. I only set it that low to 'test' how bad of a hit I would take. I was really stunned to see just how efficient perl is. When I checked the memory usage, and CPU time that this process uses when running it is surprisingly tiny. I mean VERY VERY small. Less than 1% CPU time, and about 1% of available memory usage. The server on which the mail database physically exists is also minimally impacted. It already handles dozens of such transactions per second, and reports very low overall usage under these loads. The nice thing about it is when it's working I can send a command from my backberry, and get a response back in about 3-5 seconds on average. This is not at all required, but it is nice to get that kind of response time. I also tested it with 10, and 30 second wait timers and the resource usage numbers came out almost identical. I ran another test with no wait timer to see just how fast perl is. Giving perl the ability to use 100% of system resources it did something like 8,000,000 look-ups in about 30 seconds. This did peg both the server the script runs on, as well as the mail database server. The only reason I used the GOTO's at all was because I didn't think of the infinite while loop trick. Thanks I'll make that change right away. As for the 1-3 delete loop it really only needs to be 1-2. 1 to delete the original inbound email, and 2 to delete send reply mail. Since I'm using AllDocuments look-up, notes puts all documents in that database there. It's a nice easy way to access the whole database from one place. I did it to 3 just in case something else came in while it was processing it gives it the ability to 'clean' out the mailbox. Chris Benco [EMAIL PROTECTED] James Edward Gray II To: "Chris Benco" <[EMAIL PROTECTED]> Subject: Re: Program Stability Issue 10/11/2002 11:40 AM I'm not familiar with "notes email" or the Win32::OLE module you're using, so it's unlikely that I can solve your problem. I do have a few general observations to offer though. First, checking something like e-mail every one second, may border on obsessive compulsive behavior!Seriously, I do think this time loop is a bad idea. This could potentially be a pretty significant resource drain on the computer doing the checking not to mention the checked server. My server would ban me for "flooding" shortly after I started something like this. If you need e-mail service with less than a five minute delay, I think it's time to consider a different form of communication that would meet your needs better. Second, goto programming is BAD, BAD, BAD! It creates what is often affectionately called "spaghetti code", where following the individual strands to their natural end can become maddening. Your code is short and simple, and it's still hell to follow because of those gotos. That makes it hard to get help, when you send your code to anyone. A goto call is VERY rarely ever needed in modern programming languages, so unlearn it as soon as possible. All the gotos in your script can be replaced with loops and subroutines. You used a foreach loop at one point, so I assume you're at least passingly familiar with the idea. Your main WAIT label could easily be replaced with a while loop, given a condition of 1, which will always evaluate to true and thus be infinite. Then, when you need to get back to the top of the loop, as all those gotos function, just use a call to next. For example: while (1) {# replaces WAIT: # do some processing next if CONDITION;# this sends us back to the while # more processing, if next wasn't called }# end of loop, repeats back to the while The other construct you can use to replace goto calls is a subroutine (or sub) to create a reusable chunk of c
connecting to oracle
is there an alternative to using DBI and DBD::Oracle to connect to an Oracle database to run a simple select statement? ** Mercantile Bankshares Corporation Confidential Electronic Mail: The information contained in this message is intended only for the persons to whom it is addressed and may contain confidential or privileged material. Copying, distributing, dissemination, reliance on, or other use of the information by persons other than the intended recipient(s) is prohibited. If you received this message in error, please notify the sender and delete the entire message from any computer. ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: connecting to oracle
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Charles Belcher) writes: >is there an alternative to using DBI and DBD::Oracle to connect to an Oracle >database to run a simple select statement? You could run sqlplus from Perl like any other program. I would find it simpler to use DBI and DBD::Oracle to run the simple select statement, even if I had to install the modules first. Unless they just didn't build on my system for some reason. -- Peter Scott http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: excluding @@
Sudarshan Raghavan wrote: > On Thu, 10 Oct 2002, John W. Krahn wrote: > >> What version of Perl are you using? > > perl 5.8.0 cool. no time for 5.8.x yet. > >> $ perl -Mstrict -wle'@+ = qw/b c d/;(my $name = q/a b c d efg/) =~ >> s/@+//; print $name' a b c d efg > > When I run this on 5.8.0 it gives out a 'Modification of a read only > attempted...' Same with 5.6.1 as well, but not the case with 5.6.0 which distribution of Perl you have? ActiveState? the Mac side? be specific. your statement is far reaching. did you try what you just said? do you mean you have to use s/\@+/xxx/ instead of just s/@+/xxx/ in 5.6.1? try it before you post: #!/usr/bin/perl -w use strict; use 5.6.1; my $i = 'abcd1234'; $i =~ s/@+/__hahaha__/; print "$i\n"; #-- guess what that prints __END__ prints: abcd__hahaha___1234 my stuff: [dzhuo@panda perl]# perl -v This is perl, v5.6.1 built for i386-linux lastly, escapeing won't hurt too. if that's what 5.8.x say, you might as well get in the habit to do it now. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to get the last line of a file
Alex Chen wrote: > hi, all > > i want to know how to get the last line of > a file .i know the func read has a paramenter offset but i don't know how > to use it.please help!!! > > thanks > alex chen try this: #!/usr/bin/perl -w; use strict; my $line=''; my $byte=''; open(FH,"foo.txt") || die $!; seek(FH,(-s "foo.txt")-2,0); while(1){ read(FH,$byte,1); print $line and last if($byte eq "\n"); $line = $byte . $line; seek(FH,tell(FH)-2,0); } close(FH); __END__ david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
SUID and getting the basename
Hello list, I have a script that will run with the SUID bit set. This of course has generated a bunch of problems. As I have been working through them I have come across one that I just can't seem to figure out. I want to get this ( or some equivalent) to work: $oraProgName = `/usr/bin/basename $0`; this command gives me "Insecure dependency in `` while running setuid at" yada yada yada does anyone have a way to make this work? thanks for your help Steve
RE: SUID and getting the basename
You need the program name, hence the $0. But you've wrapped the path in backticks, which Perl interprets as an OS command. I think you mean single quotes, but double quotes are better for $0 interpolation: my $oraProgName = "/path/to/$0"; You could also use the caller function, for example: my $oraProgName = (caller(0))[1]; #progam filename Hope this helps, Nathanael >= Original Message From Steve Main <[EMAIL PROTECTED]> = >Hello list, > >I have a script that will run with the SUID bit set. This of course has >generated a bunch of problems. As I have been working through them I have >come across one that I just can't seem to figure out. > >I want to get this ( or some equivalent) to work: > >$oraProgName = `/usr/bin/basename $0`; > >this command gives me "Insecure dependency in `` while running setuid at" >yada yada yada > >does anyone have a way to make this work? > >thanks for your help > >Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Is this correct? print syntax
Is this correct placement of the parenthesis? print FILEHANDLE (list_of_print_stuff); Nikola Janceski The straightest path is not the path of experience. -- Nicky J. from da' Bronx The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is this correct? print syntax
Parenthesis are optional for pre-defined subroutines, like Perl's built-in, so most users just leave them off when they're not needed: print FILEHANDLE list, of stuff, to print; On Friday, October 11, 2002, at 01:28 PM, Nikola Janceski wrote: > Is this correct placement of the parenthesis? > > print FILEHANDLE (list_of_print_stuff); > > > Nikola Janceski > > The straightest path is not the path of experience. > -- Nicky J. from da' Bronx > > > --- > - > > The views and opinions expressed in this email message are the sender's > own, and do not necessarily represent the views and opinions of Summit > Systems Inc. > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Is this correct? print syntax
I need them.. for print FILEHANDLE (list, of, stuff), next if (condition); > -Original Message- > From: James Edward Gray II [mailto:[EMAIL PROTECTED]] > Sent: Friday, October 11, 2002 2:39 PM > To: Nikola Janceski > Cc: Beginners (E-mail) > Subject: Re: Is this correct? print syntax > > > Parenthesis are optional for pre-defined subroutines, like Perl's > built-in, so most users just leave them off when they're not needed: > > print FILEHANDLE list, of stuff, to print; > > On Friday, October 11, 2002, at 01:28 PM, Nikola Janceski wrote: > > > Is this correct placement of the parenthesis? > > > > print FILEHANDLE (list_of_print_stuff); > > > > > > Nikola Janceski > > > > The straightest path is not the path of experience. > > -- Nicky J. from da' Bronx > > > > > > > -- > - > > - > > > > The views and opinions expressed in this email message are > the sender's > > own, and do not necessarily represent the views and > opinions of Summit > > Systems Inc. > > > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: excluding @@
On Fri, Oct 11, 2002 at 10:10:22AM -0700, david wrote: > Sudarshan Raghavan wrote: > > > On Thu, 10 Oct 2002, John W. Krahn wrote: > > > >> What version of Perl are you using? > > > > perl 5.8.0 > > cool. no time for 5.8.x yet. > > > > >> $ perl -Mstrict -wle'@+ = qw/b c d/;(my $name = q/a b c d efg/) =~ > >> s/@+//; print $name' a b c d efg > > > > When I run this on 5.8.0 it gives out a 'Modification of a read only > > attempted...' Same with 5.6.1 as well, but not the case with 5.6.0 > > which distribution of Perl you have? ActiveState? the Mac side? be specific. > your statement is far reaching. did you try what you just said? do you mean > you have to use s/\@+/xxx/ instead of just s/@+/xxx/ in 5.6.1? try it > before you post: @+ and @- were recently made readonly. That is why "@+ = qw/b c d/" gives "Modification of a read-only value attempted". -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is this correct? print syntax
In that case yes, I believe you have it right. It's the indirect method call syntax, as far as I understand. Personally though, I would prefer to see your example as: if (condition) { print FILEHANDLE list, of, stuff; next; } TMTOWTDI though, of course. James On Friday, October 11, 2002, at 01:40 PM, Nikola Janceski wrote: > I need them.. for > > > print FILEHANDLE (list, of, stuff), next if (condition); > >> -Original Message- >> From: James Edward Gray II [mailto:[EMAIL PROTECTED]] >> Sent: Friday, October 11, 2002 2:39 PM >> To: Nikola Janceski >> Cc: Beginners (E-mail) >> Subject: Re: Is this correct? print syntax >> >> >> Parenthesis are optional for pre-defined subroutines, like Perl's >> built-in, so most users just leave them off when they're not needed: >> >> print FILEHANDLE list, of stuff, to print; >> >> On Friday, October 11, 2002, at 01:28 PM, Nikola Janceski wrote: >> >>> Is this correct placement of the parenthesis? >>> >>> print FILEHANDLE (list_of_print_stuff); >>> >>> >>> Nikola Janceski >>> >>> The straightest path is not the path of experience. >>> -- Nicky J. from da' Bronx >>> >>> >>> >> -- >> - >>> - >>> >>> The views and opinions expressed in this email message are >> the sender's >>> own, and do not necessarily represent the views and >> opinions of Summit >>> Systems Inc. >>> >>> >>> -- >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >> > > --- > - > > The views and opinions expressed in this email message are the sender's > own, and do not necessarily represent the views and opinions of Summit > Systems Inc. > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is this correct? print syntax
Hey Nikola, My MUA believes you used Internet Mail Service (5.5.2650.21) to write the following on Friday, October 11, 2002 at 2:28:27 PM. NJ> Is this correct placement of the parenthesis? NJ> print FILEHANDLE (list_of_print_stuff); The best thing to do is look at perldoc, and try it yourself. use strict; use warnings; print (list_of_print_stuff); # This gives an error print "\nThis is how I usually do it\n"; tryperldoc -q printat a command prompt. -- [EMAIL PROTECTED] Flying with The Bat! eMail v1.61 Windows 2000 5.0.2195 (Service Pack 2) What else can you do at 3:00 am? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: SUID and getting the basename
Steve Main <[EMAIL PROTECTED]> wrote: > > I have a script that will run with the SUID bit set. This of course has > generated a bunch of problems. As I have been working through them I have > come across one that I just can't seem to figure out. > > I want to get this ( or some equivalent) to work: > > $oraProgName = `/usr/bin/basename $0`; > > this command gives me "Insecure dependency in `` while running setuid at" > yada yada yada > > does anyone have a way to make this work? use File::Basename; $ora_prog_name = basename $0; -- Steve perldoc -qa.j | perl -lpe '($_)=m("(.*)")' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Is this correct? print syntax
from the doc I was a little confused and wanted clarification: Also be careful not to follow the print keyword with a left parenthesis unless you want the corresponding right parenthesis to terminate the arguments to the print--interpose a "+" or put parentheses around all the arguments. this makes me think I can do this: print(FILEHANDLE list, of, stuff, to, print), next if (condition); which I haven't tested. and do I need another comma in that?... ;) just fueling the fire I guess. > -Original Message- > From: Tim Musson [mailto:[EMAIL PROTECTED]] > Sent: Friday, October 11, 2002 2:46 PM > To: [EMAIL PROTECTED] > Subject: Re: Is this correct? print syntax > > > Hey Nikola, > > My MUA believes you used Internet Mail Service (5.5.2650.21) > to write the following on Friday, October 11, 2002 at 2:28:27 PM. > > NJ> Is this correct placement of the parenthesis? > > NJ> print FILEHANDLE (list_of_print_stuff); > > The best thing to do is look at perldoc, and try it yourself. > > use strict; > use warnings; > print (list_of_print_stuff); # This gives an error > print "\nThis is how I usually do it\n"; > > tryperldoc -q printat a command prompt. > > -- > [EMAIL PROTECTED] > Flying with The Bat! eMail v1.61 > Windows 2000 5.0.2195 (Service Pack 2) > What else can you do at 3:00 am? > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Is this correct? print syntax
>print FILEHANDLE (list, of, stuff), next if (condition); Why are you using a comma operator here and not just a semi-colon to terminate the print statement? I.e. why not: print FILEHANDLE (list, of, stuff); next if (condition); In both cases, the return value of print() is getting tossed and the 'next if (...)' is not dependent on the print statement. ---Larry ++ | Larry Coffin, G.P.H. Watertown, MA | | http://www.PointInfinity.com/lcoffin/[EMAIL PROTECTED] | ++ Today is the tomorrow you worried about yesterday - -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is this correct? print syntax
On Friday, October 11, 2002, at 01:45 PM, Tim Musson wrote: > use strict; > use warnings; > print (list_of_print_stuff); # This gives an error I don't get any error with this, assuming I either make it a proper declared variable or quote it, in Perl 5.6.0. It's never wrong to use parenthesis, even if they aren't required. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is this correct? print syntax
Hey Nikola, My MUA believes you used Internet Mail Service (5.5.2650.21) to write the following on Friday, October 11, 2002 at 2:40:28 PM. NJ> I need them.. for NJ> print FILEHANDLE (list, of, stuff), next if (condition); This type of thing is common in my code when I am messing around. my $debug=0; # !=0 makes info print print "\n\n\tThis is in the test\n\n" if $debug; -- [EMAIL PROTECTED] Flying with The Bat! eMail v1.61 Windows 2000 5.0.2195 (Service Pack 2) Does the noise in my head bother you? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Is this correct? print syntax
On Oct 11, Nikola Janceski said: >print(FILEHANDLE list, of, stuff, to, print), next if (condition); > >which I haven't tested. and do I need another comma in that?... ;) just >fueling the fire I guess. That is what you need. print (FH @args), next if condition; And no, do NOT put a comma after the filehandle. print FH (@args), next if condition; is the same as print FH @args, next if condition; which is NOT what you want. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is this correct? print syntax
On Friday, October 11, 2002, at 01:57 PM, Larry Coffin wrote: >> print FILEHANDLE (list, of, stuff), next if (condition); > > print FILEHANDLE (list, of, stuff); > next if (condition); > > In both cases, the return value of print() is getting tossed and > the 'next if (...)' is not dependent on the print statement. But these two examples don't behave the same. The first one prints and calls next, only on the condition. The second one always prints and then calls next, if the condition is true. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is this correct? print syntax
Nikola Janceski <[EMAIL PROTECTED]> wrote: > Is this correct placement of the parenthesis? > > print FILEHANDLE (list_of_print_stuff); > Not really. It will usually work, but the FILEHANDLE is the first argument, so it ought to be: print(FH "foo", "bar"); -- Steve perldoc -qa.j | perl -lpe '($_)=m("(.*)")' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is this correct? print syntax
On Fri, Oct 11, 2002 at 02:57:21PM -0400, Larry Coffin wrote: > >print FILEHANDLE (list, of, stuff), next if (condition); > > Why are you using a comma operator here and not just a semi-colon > to terminate the print statement? I.e. why not: > > print FILEHANDLE (list, of, stuff); > next if (condition); > > In both cases, the return value of print() is getting tossed and > the 'next if (...)' is not dependent on the print statement. Because print is generally called for its side effects rather than for its return value. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
switch
Hi guys, I am trying to implement a switch statment in perl. I have tryed doing it 2 way's. For some reason my comparison statments are not working can some one please look over my code and see if they can point me on the right track ?? Thanx in advance, Mark Solution 1: while( ( $Remainder = ($P_lenght%16065) ) != 0 ) { print "\a size you gave is not multiple of cylenders\n"; print "round (U)p (D)own (R)enter ?"; $Ans=<>; # chomp ($Ans); print $Ans; for ($where){ /u/ && do{print "u\n";}; /d/ && do{print "d\n";}; # default print "enter partition length: "; chomp ( $P_lenght=<> ); } } _exit 0; solution 2: while( ( $Remainder = ($P_lenght%16065) ) != 0 ) { print "\a size you gave is not multiple of cylenders\n"; print "round (U)p (D)own (R)enter ?"; $Ans=<>; # chomp ($Ans); print $Ans; if( $Ans =~ /u/i ){ $P_lenght = ($P_lenght - $Remainder+$CYLLENGTH); } elsif( $Ans =~ /d/i){ $P_lenght-=$Remainder; } # default else{ print "enter partition length: "; chomp ( $P_lenght=<> ); } } _exit 0; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: switch
You might want to try a search on CPAN, there is a switch module there... http://search.cpan.org/search?query=switch&mode=all Here is some sample code from the perldoc: = use Switch; switch ($val) { case 1 { print "number 1" } case "a"{ print "string a" } case [1..10,42] { print "number in list" } case (@array) { print "number in list" } case /\w+/ { print "pattern" } case qr/\w+/{ print "pattern" } case (%hash){ print "entry in hash" } case (\%hash) { print "entry in hash" } case (\&sub){ print "arg to subroutine" } else{ print "previous case not true" } } = Rob -Original Message- From: Mark Goland [mailto:[EMAIL PROTECTED]] Sent: Friday, October 11, 2002 3:20 PM To: [EMAIL PROTECTED] Subject: switch Hi guys, I am trying to implement a switch statment in perl. I have tryed doing it 2 way's. For some reason my comparison statments are not working can some one please look over my code and see if they can point me on the right track ?? Thanx in advance, Mark Solution 1: while( ( $Remainder = ($P_lenght%16065) ) != 0 ) { print "\a size you gave is not multiple of cylenders\n"; print "round (U)p (D)own (R)enter ?"; $Ans=<>; # chomp ($Ans); print $Ans; for ($where){ /u/ && do{print "u\n";}; /d/ && do{print "d\n";}; # default print "enter partition length: "; chomp ( $P_lenght=<> ); } } _exit 0; solution 2: while( ( $Remainder = ($P_lenght%16065) ) != 0 ) { print "\a size you gave is not multiple of cylenders\n"; print "round (U)p (D)own (R)enter ?"; $Ans=<>; # chomp ($Ans); print $Ans; if( $Ans =~ /u/i ){ $P_lenght = ($P_lenght - $Remainder+$CYLLENGTH); } elsif( $Ans =~ /d/i){ $P_lenght-=$Remainder; } # default else{ print "enter partition length: "; chomp ( $P_lenght=<> ); } } _exit 0; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is this correct? print syntax
At 3:05 PM -0400 10/11/02, James Edward Gray II wrote: >>> print FILEHANDLE (list, of, stuff), next if (condition); >> >> print FILEHANDLE (list, of, stuff); >> next if (condition); >But these two examples don't behave the same. The first one prints >and calls next, only on the condition. The second one always prints >and then calls next, if the condition is true. You're right James. I saw that from your earlier letter that I received after I sent mine -- the 'if' has a higher precedence than the comma and both statements are executed conditionally. And I agree with your earlier letter that it is better to break those into two statements and enclose them within an 'if' block -- much cleaner that way. Thanks for clearing that up! ---Larry ++ | Larry Coffin, G.P.H. Watertown, MA | | http://www.PointInfinity.com/lcoffin/[EMAIL PROTECTED] | ++ Today is the tomorrow you worried about yesterday - -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Using Perl to write to an Access 97 database (*.mdb)
Is there a module for this? I have some comma-separated files I need to input to an Access 97 format mdb. I do not need to define any tables or anything -- just pump data into an existing structure. Thank you, Shawn ** This e-mail and any files transmitted with it may contain confidential information and is intended solely for use by the individual to whom it is addressed. If you received this e-mail in error, please notify the sender, do not disclose its contents to others and delete it from your system. ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: switch
Ooops, I think I misunderstood the question in my last post. That will teach me to read the whole post first! Anyway... What does that $where in your code come from? It is in the for() statement. Shouldn't it be $Ans? I would do it more like this... print "Enter the command: "; chomp(my $input = ); for ($input) { /u/i and print "u\n" and last; /d/i and print "d\n" and last; # default print "default\n"; } You need the "and last", otherwise it will always execute the default. Rob -Original Message- From: Mark Goland [mailto:[EMAIL PROTECTED]] Sent: Friday, October 11, 2002 3:20 PM To: [EMAIL PROTECTED] Subject: switch Hi guys, I am trying to implement a switch statment in perl. I have tryed doing it 2 way's. For some reason my comparison statments are not working can some one please look over my code and see if they can point me on the right track ?? Thanx in advance, Mark Solution 1: while( ( $Remainder = ($P_lenght%16065) ) != 0 ) { print "\a size you gave is not multiple of cylenders\n"; print "round (U)p (D)own (R)enter ?"; $Ans=<>; # chomp ($Ans); print $Ans; for ($where){ /u/ && do{print "u\n";}; /d/ && do{print "d\n";}; # default print "enter partition length: "; chomp ( $P_lenght=<> ); } } _exit 0; solution 2: while( ( $Remainder = ($P_lenght%16065) ) != 0 ) { print "\a size you gave is not multiple of cylenders\n"; print "round (U)p (D)own (R)enter ?"; $Ans=<>; # chomp ($Ans); print $Ans; if( $Ans =~ /u/i ){ $P_lenght = ($P_lenght - $Remainder+$CYLLENGTH); } elsif( $Ans =~ /d/i){ $P_lenght-=$Remainder; } # default else{ print "enter partition length: "; chomp ( $P_lenght=<> ); } } _exit 0; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Using Perl to write to an Access 97 database (*.mdb)
I would use withe DBD::ODBC (with DBI), or Win32::OLE (with ADO). That assumes that you have worked with either DBI or Microsoft's ADO. You could also use Win32::OLE to directly access the Access API, but I have no experience with that. Rob -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, October 11, 2002 3:20 PM To: [EMAIL PROTECTED] Subject: Using Perl to write to an Access 97 database (*.mdb) Is there a module for this? I have some comma-separated files I need to input to an Access 97 format mdb. I do not need to define any tables or anything -- just pump data into an existing structure. Thank you, Shawn ** This e-mail and any files transmitted with it may contain confidential information and is intended solely for use by the individual to whom it is addressed. If you received this e-mail in error, please notify the sender, do not disclose its contents to others and delete it from your system. ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
strange trace results using Net::SMTP and Mail::Sender
I don't know if this points to a bug in my operating system, a bug in my code or if it's normal but basically when I use these modules and run a strace (using Linux 7.3) it gives me the following: 12:28:39 close(3) = 0 12:28:39 munmap(0x400c8000, 4096) = 0 12:28:39 close(3) = -1 EBADF (Bad file descriptor) It tries to close something that is already closed if I read it correctly. I'm pretty new to using the trace feature so maybe I'm off base. Is this showing a problem or is this normal?? Jessee -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Is this correct? print syntax
Nikola Janceski wrote: > I need them.. for > > > print FILEHANDLE (list, of, stuff), next if (condition); > you probably just want: print FILEHANDLE qw(list of stuff) and next if(condition); david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: switch
You could use a ternary operator here: $Ans =~ m/u/i ? print "u\n" : $Ans =~ m/d/i ? print "d\n" : $Ans =~ m/r/i ? print "r\n" : (some default); :) >= Original Message From Mark Goland <[EMAIL PROTECTED]> = >Hi guys, > >I am trying to implement a switch statment in perl. I have tryed doing it 2 >way's. For some reason my comparison statments are not working can some one >please look over my code and see if they can point me on the right track ?? > >Thanx in advance, >Mark > >Solution 1: > >while( ( $Remainder = ($P_lenght%16065) ) != 0 ) >{ > print "\a size you gave is not multiple of cylenders\n"; > print "round (U)p (D)own (R)enter ?"; $Ans=<>; ># chomp ($Ans); >print $Ans; >for ($where){ >/u/ && do{print "u\n";}; >/d/ && do{print "d\n";}; ># default >print "enter partition length: "; >chomp ( $P_lenght=<> ); > > >} >} >_exit 0; > >solution 2: > >while( ( $Remainder = ($P_lenght%16065) ) != 0 ) >{ > print "\a size you gave is not multiple of cylenders\n"; > print "round (U)p (D)own (R)enter ?"; $Ans=<>; ># chomp ($Ans); >print $Ans; >if( $Ans =~ /u/i ){ >$P_lenght = ($P_lenght - $Remainder+$CYLLENGTH); >} >elsif( $Ans =~ /d/i){ >$P_lenght-=$Remainder; >} ># default >else{ >print "enter partition length: "; chomp ( $P_lenght=<> ); >} > > >} > >_exit 0; > > > > >-- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using Perl to write to an Access 97 database (*.mdb)
By the way, I've already looked around search.cpan.org, and I couldn't find anything. Possibly due to the fact that there are about 500 modules which include the word "access" in the name. If you know of a specific module, please send me a link or the name. "Try cpan" will not help this time. Thank you again, Shawn shawn_milochik@godi vachoc.com To: [EMAIL PROTECTED] cc: 10/11/2002 03:19 PMbcc: Subject: Using Perl to write to an Access 97 database (*.mdb) Is there a module for this? I have some comma-separated files I need to input to an Access 97 format mdb. I do not need to define any tables or anything -- just pump data into an existing structure. Thank you, Shawn ** This e-mail and any files transmitted with it may contain confidential information and is intended solely for use by the individual to whom it is addressed. If you received this e-mail in error, please notify the sender, do not disclose its contents to others and delete it from your system. ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: strange trace results using Net::SMTP and Mail::Sender
From: "Jessee Parker" <[EMAIL PROTECTED]> > I don't know if this points to a bug in my operating system, a bug in > my code or if it's normal but basically when I use these modules and > run a strace (using Linux 7.3) it gives me the following: > > 12:28:39 close(3) = 0 > 12:28:39 munmap(0x400c8000, 4096) = 0 > 12:28:39 close(3) = -1 EBADF (Bad file > descriptor) > > It tries to close something that is already closed if I read it > correctly. I'm pretty new to using the trace feature so maybe I'm off > base. Is this showing a problem or is this normal?? It should not cause any problems, but I would not say it's 100% normal. Could you show me your code (for Mail::Sender)? And could you run your script with perl -w ? Maybe it'll print a warning ... Thanks, Jenda=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
html regular expressions
while reading the o'eilly book 'learning perl' i came across a section dealing with reg. expressions for html. they recommended grabbing a robust module from cpan to help with these, but i can't quite seem to find one specifically for this purpose. any one done this before, or have some direction for me? matt -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: html regular expressions
May we assume that you want to apply regexes to HTML to check formedness? Or are you wanting to detect dangerous HTML in a document? It helps to state what your goal is. :) A good module to check out for general HTML mangling might be CPAN's HTML::Parser which will "recognize markup and separate it from plain text (alias data content) in HTML documents." The HTML:: namespace has some interesting stuff if you haven't explicitly check it yet. Hope this helps, Nathanael >= Original Message From "Matthew C. Peterson" <[EMAIL PROTECTED]> = >while reading the o'eilly book 'learning perl' i came across a section >dealing with reg. expressions for html. they recommended grabbing a robust >module from cpan to help with these, but i can't quite seem to find one >specifically for this purpose. > >any one done this before, or have some direction for me? > >matt > > >-- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: html regular expressions
From: "Matthew C. Peterson" <[EMAIL PROTECTED]> > while reading the o'eilly book 'learning perl' i came across a section > dealing with reg. expressions for html. they recommended grabbing a > robust module from cpan to help with these, but i can't quite seem to > find one specifically for this purpose. HTML::Parser Jenda=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
module installation
I have been trying to install a variety of modules and all have failed during the make portion. all modules seem to give the same error where a variable is pointed to an incomplete type. I have recompiled perl, I have recompiled make any ideas on what I can try. :-( chuck ** Mercantile Bankshares Corporation Confidential Electronic Mail: The information contained in this message is intended only for the persons to whom it is addressed and may contain confidential or privileged material. Copying, distributing, dissemination, reliance on, or other use of the information by persons other than the intended recipient(s) is prohibited. If you received this message in error, please notify the sender and delete the entire message from any computer. ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using Perl to write to an Access 97 database (*.mdb)
I´m a beginner with perl and I need to find the DBI.pm module for Win32. Does anybody know where I could find it? use DBI; @driver_names = DBI->available_drivers; @data_sources = DBI->data_sources($driver_name, \%attr); $i=0; foreach (@driver_names){print i++, ' ', $_, "\n";} $i=0; foreach (@data_sources){print i++, ' ', $_, "\n";} Microsoft Windows 2000 [Versão 5.00.2195] (C) Copyright 1985-2000 Microsoft Corp. F:\Internet Tutorial\Perl>perl dbi.pl Can't locate DBI.pm in @INC (@INC contains: D:/Perl/lib D:/Perl/site/lib .) at d bi.pl line 1. BEGIN failed--compilation aborted at dbi.pl line 1. F:\Internet Tutorial\Perl> Thanks in advance, Josimar Nunes de Oliveira - Original Message - From: comunic@ To: Undisclosed-Recipient:; Sent: Friday, October 11, 2002 5:26 PM Subject: CEFET-SP / Concurso Público para Docentes - Original Message - From: "Hanson, Rob" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Friday, October 11, 2002 4:36 PM Subject: RE: Using Perl to write to an Access 97 database (*.mdb) > I would use withe DBD::ODBC (with DBI), or Win32::OLE (with ADO). > > That assumes that you have worked with either DBI or Microsoft's ADO. > You could also use Win32::OLE to directly access the Access API, but I > have no experience with that. > > Rob > > -Original Message- > From: [EMAIL PROTECTED] > [mailto:shawn_milochik@;godivachoc.com] > Sent: Friday, October 11, 2002 3:20 PM > To: [EMAIL PROTECTED] > Subject: Using Perl to write to an Access 97 database (*.mdb) > > > Is there a module for this? I have some comma-separated files I need to > input to an Access 97 format mdb. I do not need to define any tables or > anything -- just pump data into an existing structure. > > Thank you, > Shawn > > > > > > ** > This e-mail and any files transmitted with it may contain > confidential information and is intended solely for use by > the individual to whom it is addressed. If you received > this e-mail in error, please notify the sender, do not > disclose its contents to others and delete it from your > system. > > ** > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]