which is better when reading files

2008-01-10 Thread Enjoy_Life
hi, who can tell me which is better of the following codes? why there are different methods to read files? thanks 1. open(INPUT, "< filedata") or die "Couldn't open filedata for reading: $!\n"; while () { print if /blue/; } close(INPUT); 2. use IO::File; $input = IO::File->ne

Re: Creating an encrypted zipfile on Unix for Windows users

2008-01-10 Thread Rodrick Brown
On Jan 10, 2008 4:39 PM, RICHARD FERNANDEZ <[EMAIL PROTECTED]> wrote: > Hi folks, > > I'm writing a script that basically creates a bunch of files, packages > them up (tar/gz), and mails them out. > I can handle all of that, but before I mail them I also have to password > protect the archive like

Re: How to reset the diamond operator's file pointer?

2008-01-10 Thread Chas. Owens
On Jan 10, 2008 4:43 PM, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: > Zembower, Kevin wrote: > > I'm trying to write a program in which I have to make two passes through > > the file. I want to call the file on the command line and process it > > with 'while (<>){...'. Can I use something like '

Re: How to reset the diamond operator's file pointer?

2008-01-10 Thread John W. Krahn
Gunnar Hjalmarsson wrote: Zembower, Kevin wrote: I'm trying to write a program in which I have to make two passes through the file. I want to call the file on the command line and process it with 'while (<>){...'. Can I use something like 'seek STDIN, 0, 0' between the two while loops to reset t

Re: how to test a symlink target for directoryhood

2008-01-10 Thread reader
"John W. Krahn" <[EMAIL PROTECTED]> writes: > The -l test will tell you if a file is a symlink and readlink() will > read the contents of that symlink. > > if ( -l $file && -d readlink $file ) { > print "$file is a symlink that points to a directory\n"; > } Ahh nice... thanks -- To uns

Re: how to test a symlink target for directoryhood

2008-01-10 Thread reader
"Chas. Owens" <[EMAIL PROTECTED]> writes: > perldoc -f -X Ack... I was trying perldoc -f X -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: using wrapsuid

2008-01-10 Thread Tom Phoenix
On Jan 10, 2008 1:22 PM, Tim McGeary <[EMAIL PROTECTED]> wrote: > Gunnar Hjalmarsson wrote: > > Tim McGeary wrote: > >> I have a perl script that runs on the command line that I need run as > >> a CGI on a webserver, but the system commands I'm using in the script > >> require that I run it as a sp

Re: Q: how to push into array

2008-01-10 Thread Chas. Owens
On Jan 10, 2008 4:28 PM, ciwei <[EMAIL PROTECTED]> wrote: > > > push @{ $wwn{ "$host-$hba" } }, /^\s+WWN:\s+(1000[0-9a-fA-F]{12})$/; > > Thanks for the help. > > can you please explain in the above line , what the { } around > push @{ $wwn ... } <--here do ? > > is the { } here optional? or can t

Re: using wrapsuid

2008-01-10 Thread Gunnar Hjalmarsson
Tim McGeary wrote: Gunnar Hjalmarsson wrote: I don't know anything about wrapsuid, but I have successfully controlled the uid or gid of a single script via a C wrapper as described at http://perldoc.perl.org/perlsec.html#Security-Bugs I've heard dubious security issues about using a C wrapper

Re: How to reset the diamond operator's file pointer?

2008-01-10 Thread Gunnar Hjalmarsson
Zembower, Kevin wrote: I'm trying to write a program in which I have to make two passes through the file. I want to call the file on the command line and process it with 'while (<>){...'. Can I use something like 'seek STDIN, 0, 0' between the two while loops to reset the diamond operator to the

Creating an encrypted zipfile on Unix for Windows users

2008-01-10 Thread RICHARD FERNANDEZ
Hi folks, I'm writing a script that basically creates a bunch of files, packages them up (tar/gz), and mails them out. I can handle all of that, but before I mail them I also have to password protect the archive like pkzip does. I really don't want to shell out to pkzip if I can avoid it. I check

Re: Q: how to push into array

2008-01-10 Thread ciwei
> push @{ $wwn{ "$host-$hba"   } }, /^\s+WWN:\s+(1000[0-9a-fA-F]{12})$/; Thanks for the help. can you please explain in the above line , what the { } around push @{ $wwn ... } <--here do ? is the { } here optional? or can this be subsitute with ( )? thanks. -- To unsubscribe, e-mail: [EMAIL

Re: how to test a symlink target for directoryhood

2008-01-10 Thread Chas. Owens
On Jan 10, 2008 2:06 PM, <[EMAIL PROTECTED]> wrote: > "Chas. Owens" <[EMAIL PROTECTED]> writes: > > > The -X operators follow the symlink. > > Where is there a list of the -X operators > perldoc perlop doesn't mention it. Or at least > /\-X in that page doesn't find anything. > > > if (-d $symlin

Re: using wrapsuid

2008-01-10 Thread Tim McGeary
Gunnar Hjalmarsson wrote: Tim McGeary wrote: I have a perl script that runs on the command line that I need run as a CGI on a webserver, but the system commands I'm using in the script require that I run it as a specific user and will not let the webserver user run them. I've been investigat

Re: using wrapsuid

2008-01-10 Thread Gunnar Hjalmarsson
Tim McGeary wrote: I have a perl script that runs on the command line that I need run as a CGI on a webserver, but the system commands I'm using in the script require that I run it as a specific user and will not let the webserver user run them. I've been investigating possibilities like Apac

How to reset the diamond operator's file pointer?

2008-01-10 Thread Zembower, Kevin
I'm trying to write a program in which I have to make two passes through the file. I want to call the file on the command line and process it with 'while (<>){...'. Can I use something like 'seek STDIN, 0, 0' between the two while loops to reset the diamond operator to the beginning of the input fi

using wrapsuid

2008-01-10 Thread Tim McGeary
Greetings, I have a perl script that runs on the command line that I need run as a CGI on a webserver, but the system commands I'm using in the script require that I run it as a specific user and will not let the webserver user run them. I've been investigating possibilities like Apache suEX

Re: how to test a symlink target for directoryhood

2008-01-10 Thread John W. Krahn
[EMAIL PROTECTED] wrote: "Chas. Owens" <[EMAIL PROTECTED]> writes: On 1/10/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: I'm working on a little script that will generate an html page from a directory full of symlinks to target directories. However in some cases there may be symlinks that

Re: how to test a symlink target for directoryhood

2008-01-10 Thread reader
"Chas. Owens" <[EMAIL PROTECTED]> writes: > The -X operators follow the symlink. Where is there a list of the -X operators perldoc perlop doesn't mention it. Or at least /\-X in that page doesn't find anything. > if (-d $symlink && -r $symlink) { > print "$symlink points to a readable direc

Re: how to test a symlink target for directoryhood

2008-01-10 Thread reader
"Chas. Owens" <[EMAIL PROTECTED]> writes: > On 1/10/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> I'm working on a little script that will generate an html page from a >> directory full of symlinks to target directories. However in some >> cases there may be symlinks that point to regular f

Re: open and close a filehandle

2008-01-10 Thread Rob Dixon
Kevin Viel wrote: I have a file with thousands of fields, but a subsequent program can only had 3000. I have to break this file up, for simplicity: 1-03000 03001-06000 Hopefully, a basic outline of my code will suffice to get informative advice. my $cnt = -1 ; my $subset = 1 ; foreach (

Re: how to test a symlink target for directoryhood

2008-01-10 Thread reader
[EMAIL PROTECTED] writes: > I'm working on a little script that will generate an html page from a > directory full of symlinks to target directories. However in some > cases there may be symlinks that point to regular files. > > How can perl tell the difference. Or rather how can I test the > sy

Re: how to test a symlink target for directoryhood

2008-01-10 Thread Chas. Owens
On 1/10/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I'm working on a little script that will generate an html page from a > directory full of symlinks to target directories. However in some > cases there may be symlinks that point to regular files. > > How can perl tell the difference. Or

Re: How to test if a graph is a subgraph of another graph?

2008-01-10 Thread Chas. Owens
On 1/9/08, vijay <[EMAIL PROTECTED]> wrote: > I am using Graph::Directed module but there does not seem to be a way > to test if one graph is a subgraph of another. If you don't care about isomorphism it is fairly easy. Let's say we have a graph a-b-c-d | e-f | g and we want to know if e-f |

how to test a symlink target for directoryhood

2008-01-10 Thread reader
I'm working on a little script that will generate an html page from a directory full of symlinks to target directories. However in some cases there may be symlinks that point to regular files. How can perl tell the difference. Or rather how can I test the symlink to see if it points at a real op

RE: open and close a filehandle

2008-01-10 Thread Kevin Viel
> -Original Message- > From: John W. Krahn [mailto:[EMAIL PROTECTED] > Sent: Thursday, January 10, 2008 8:26 AM > To: Perl Beginners > Subject: Re: open and close a filehandle > > Kevin Viel wrote: > > I have a file with thousands of fields, but a subsequent > program can > > only had

Re: Error while using BCP in from Inside Perl Script

2008-01-10 Thread Tom Phoenix
On Jan 10, 2008 2:09 AM, <[EMAIL PROTECTED]> wrote: > I am trying to bcp in data into a table from inside a perl script. > Though the data gets inserted into the table but still I am getting > following error : > > sh: Starting: execute permission denied > sh: 8: execute permission denied > sh: s

Re: returning groups from a string

2008-01-10 Thread Chas. Owens
On Jan 9, 2008 6:54 PM, <[EMAIL PROTECTED]> wrote: > I have a serties of strings > > john doe > sam f smith > joe s thomas jr > > > i need a regex that will return each word in the string. I have tries > variations on (.*)\b(.*) but i can't get it. what is the proper > syntax? Have you consider

Re: How to test if a graph is a subgraph of another graph?

2008-01-10 Thread Tom Phoenix
On Jan 9, 2008 3:18 PM, vijay <[EMAIL PROTECTED]> wrote: > I am using Graph::Directed module but there does not seem to be a way > to test if one graph is a subgraph of another. If there's not already a module on CPAN that does what you want, you can write one of your own. http://search.cpan

returning groups from a string

2008-01-10 Thread kirk
I have a serties of strings john doe sam f smith joe s thomas jr i need a regex that will return each word in the string. I have tries variations on (.*)\b(.*) but i can't get it. what is the proper syntax? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

Re: Q: how to push into array

2008-01-10 Thread Chas. Owens
On Jan 9, 2008 6:26 PM, ciwei <[EMAIL PROTECTED]> wrote: > Thanks for answering my question. > > I don't understand your second question, could you break your input > > into records so we can clearly see what how you want to define the > > records? > > My data looks like this: the rcord is variable

Re: open and close a filehandle

2008-01-10 Thread Chas. Owens
On Jan 10, 2008 9:26 AM, John W. Krahn <[EMAIL PROTECTED]> wrote: snip > > if ( $cnt = 0 ) { > > You are assigning 0 to $cnt so $cnt will always be false and the else > block will always execute. snip This is one of the reasons the warnings and strict pragmas are so important. The warnings prag

Re: open and close a filehandle

2008-01-10 Thread Stephen Kratzer
On Wednesday 09 January 2008 18:03:37 you wrote: > I have a file with thousands of fields, but a subsequent program can only > had 3000. I have to break this file up, for simplicity: > > 1-03000 > 03001-06000 > > Hopefully, a basic outline of my code will suffice to get informative > advice. >

Re: open and close a filehandle

2008-01-10 Thread John W. Krahn
Kevin Viel wrote: I have a file with thousands of fields, but a subsequent program can only had 3000. I have to break this file up, for simplicity: 1-03000 03001-06000 Hopefully, a basic outline of my code will suffice to get informative advice. my $cnt = -1 ; my $subset = 1 ; foreach (

Error while using BCP in from Inside Perl Script

2008-01-10 Thread rajpreetsidhu
Greetings, I am trying to bcp in data into a table from inside a perl script. Though the data gets inserted into the table but still I am getting following error : sh: Starting: execute permission denied sh: 8: execute permission denied sh: syntax error at line 4: `(' unexpected sh: Starting: exe

How to test if a graph is a subgraph of another graph?

2008-01-10 Thread vijay
I am using Graph::Directed module but there does not seem to be a way to test if one graph is a subgraph of another. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Q: how to push into array

2008-01-10 Thread ciwei
Thanks for answering my question. > I don't understand your second question, could you break your input > into records so we can clearly see what how you want to define the > records? My data looks like this: the rcord is variable in the number of lines. I'm tring to push all WWN that start with 1

open and close a filehandle

2008-01-10 Thread Kevin Viel
I have a file with thousands of fields, but a subsequent program can only had 3000. I have to break this file up, for simplicity: 1-03000 03001-06000 Hopefully, a basic outline of my code will suffice to get informative advice. my $cnt = -1 ; my $subset = 1 ; foreach ( 1..6000 ){ $cnt++