Zhao, Bingfeng wrote:
use strict;
use warnings;
my $csv = your_csv_file; # replace your csv file name here
open FH, $csv or die "canot open file $csv: $!\n";
for()
{
chomp;
if (/(.+?),(\d+)/)
I like this more :
my ( $file, $num ) = split /,/ , $_ ;
if ( -e $file && $num =~ /
Oops, The 23rd line should be
rename $temp, $file;
> -Original Message-
> From: Zhao, Bingfeng [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, August 14, 2007 12:37 PM
> To: [EMAIL PROTECTED]; beginners@perl.org
> Subject: RE: Find and replace from CSV
>
> use strict;
> use warnings;
>
> my
use strict;
use warnings;
my $csv = your_csv_file; # replace your csv file name here
open FH, $csv or die "canot open file $csv: $!\n";
for()
{
chomp;
if (/(.+?),(\d+)/)
{
# we got file name in $1 and the number in $2
my $file = $1
On Aug 9, 8:12 am, [EMAIL PROTECTED] wrote:
> Hi, I am new to Perl.
>
> I am trying to replace a string within a bunch of html files.
>
> Ideally, I would like to have the file name pulled from a list in a
> text file, open the file, search for the string that will be replaced
> within the file, pu
Thanks for all of the help.
To answer Paul's first question, I think I didn't explain very well
what I am trying to do.
There are a few thousand html files that I need to modify. There is a
string that I need to replace that will be different in each file.
example: author_id = '6" (the 60k
On 8/13/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
>
>
> -Original Message-
> >From: [EMAIL PROTECTED]
> >Sent: Aug 14, 2007 3:20 AM
> >To: beginners@perl.org
> >Subject: piping and reading stdin
> >
> >I want to read from a pipe in my perl script invoked like:
> >
> >date | perl myperlscript
On 8/13/07, Chris Pax <[EMAIL PROTECTED]> wrote:
snip
> but I have it so, if you pass it a value like: ./myprog.pl update, it
> will update the callbacks file and exit.
> otherwise it will run the program.
>
> what I want to happen is for it to write in the new functions on the
> fly while running
-Original Message-
>From: [EMAIL PROTECTED]
>Sent: Aug 14, 2007 3:20 AM
>To: beginners@perl.org
>Subject: piping and reading stdin
>
>I want to read from a pipe in my perl script invoked like:
>
>date | perl myperlscript.pl
>
>I understand that this puts the text outputted from the date p
On Aug 13, 5:26 pm, [EMAIL PROTECTED] (Chas Owens) wrote:
> On 8/12/07, Chris Pax <[EMAIL PROTECTED]> wrote:
> snip> so I tried require and do.
> > I guess its best to explain my goal here. I am using perl for gtk
> > programming. The main code will use the glade bindings and use a
> > separate fil
On Aug 13, 3:52 am, [EMAIL PROTECTED] (Bingfeng Zhao) wrote:
> Hi, list,
> I use perl on Win32 platform mostly. In order to automated the process
> of version control and code review, I need check whether a file is
> readonly and make it readonly if necessary. But perl seems unfriendly to
> win32 a
I want to read from a pipe in my perl script invoked like:
date | perl myperlscript.pl
I understand that this puts the text outputted from the date program
into the stdin. How could I check the buffer contained by the stdin
without it blocking for you to input anything from the keyboard if
nothin
On Aug 13, 4:33 pm, [EMAIL PROTECTED] (Oryann9) wrote:
> From the Perl Review and my understanding as well, use
> Carp with keywords carp and croak is supposed to
> provide additional detail in your errors and warnings.
Your understanding is wrong. They do not provide additional
details. They p
On 8/13/07, Don Scott <[EMAIL PROTECTED]> wrote:
> use Net::SFTP;
>
> Net::SFTP->new($remotehost)
> or die "could open connection to $remote_host\n";
> $sftp->get($remotedir$remotefile)
> or die "could not get $remotefile\n";
> $sftp->do_remove($remotedir$remotefile)
>
I am in the process of removing the Net::FTP routines in some of my
older programs. I don't yet have the Net::SFTP and Net::SSH::Perl
modules installed (I don't have root on these systems). In the
meantime, I will probably do:
system "scp remotehost:/remotedir/remotefile /localdir/localfile";
syst
On 8/12/07, Chris Pax <[EMAIL PROTECTED]> wrote:
snip
> so I tried require and do.
> I guess its best to explain my goal here. I am using perl for gtk
> programming. The main code will use the glade bindings and use a
> separate file for call backs. I want to make it so that if a new
> callback/fun
--- Paul Lalli <[EMAIL PROTECTED]> wrote:
> On Aug 13, 2:39 pm, [EMAIL PROTECTED] (Robert Hicks)
> wrote:
> > I typically "use Carp;" and change my "die" and
> "warn" statements to
> > "croak" and "carp". I have read a couple places
> croak/carp are a little
> > better at telling you what and whe
On 8/13/07, Robert Hicks <[EMAIL PROTECTED]> wrote:
> I typically "use Carp;" and change my "die" and "warn" statements to
> "croak" and "carp". I have read a couple places croak/carp are a little
> better at telling you what and where than the standard die/warn.
If to Carp is wrong, I don't want
On Aug 13, 2:39 pm, [EMAIL PROTECTED] (Robert Hicks) wrote:
> I typically "use Carp;" and change my "die" and "warn" statements to
> "croak" and "carp". I have read a couple places croak/carp are a little
> better at telling you what and where than the standard die/warn.
There is no right or wrong
On 8/13/07, Robert Hicks <[EMAIL PROTECTED]> wrote:
> I typically "use Carp;" and change my "die" and "warn" statements to
> "croak" and "carp". I have read a couple places croak/carp are a little
> better at telling you what and where than the standard die/warn.
>
> Robert
The question of whether
I typically "use Carp;" and change my "die" and "warn" statements to
"croak" and "carp". I have read a couple places croak/carp are a little
better at telling you what and where than the standard die/warn.
Robert
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EM
On 8/13/07, Luba Pardo <[EMAIL PROTECTED]> wrote:
> Dear list:
> I wrote a script that takes a list of ids from an input file and store these
> in an array in a pairwise-like manner (if total list is n then the array is
> (2 ^n)-n). I need to extract for each pair of ids a certain value from a
> hu
Luba Pardo wrote:
Dear list:
Hello,
I wrote a script that takes a list of ids from an input file and store these
in an array in a pairwise-like manner (if total list is n then the array is
(2 ^n)-n). I need to extract for each pair of ids a certain value from a
huge file that contains the pai
On 8/12/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote:
snip
> >> perl -pi -le '$_ = "something" if $. == 10' your_file
> >
> > So if this was in a script rather than a oneliner how would it work?
> > I was playing and can not get it to work in an actual test script.
>
> Not surprising since it's
Jeff Pang wrote:
From: Xavier Noria <[EMAIL PROTECTED]>
On Aug 13, 2007, at 9:29 AM, Jeff Pang wrote:
Does die call exit when it's excuted?
If so,when I overwrote exit() function in my script,would die call
this customized
exit?
Do you want some code executed if the program dies?
No.I
Jeff Pang wrote:
Does die call exit when it's excuted?
If so,when I overwrote exit() function in my script,would die call this
customized
exit?
See the section "Overriding Built-in Functions" in:
perldoc perlsub
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-o
On Mon, 2007-08-13 at 07:47 -0700, Paul Lalli wrote:
> On Aug 13, 9:40 am, [EMAIL PROTECTED] (Ken Foskey) wrote:
> > On Sun, 2007-08-12 at 22:55 -0400, yitzle wrote:
> > > I got an array of values where the order is relevent, eg the ages of
> > > Alice, Bob and Charles, and I want to make a hash ou
Dear list:
I wrote a script that takes a list of ids from an input file and store these
in an array in a pairwise-like manner (if total list is n then the array is
(2 ^n)-n). I need to extract for each pair of ids a certain value from a
huge file that contains the pair of ids and the value (format
On Aug 13, 9:40 am, [EMAIL PROTECTED] (Ken Foskey) wrote:
> On Sun, 2007-08-12 at 22:55 -0400, yitzle wrote:
> > I got an array of values where the order is relevent, eg the ages of
> > Alice, Bob and Charles, and I want to make a hash out of it. I got
> > this code that does it:
> > my %ages = (
Chris Pax wrote:
so I tried require and do.
I guess its best to explain my goal here. I am using perl for gtk
programming. The main code will use the glade bindings and use a
separate file for call backs. I want to make it so that if a new
callback/function is defined in the glade file, that func
Ken Foskey wrote:
On Sun, 2007-08-12 at 22:55 -0400, yitzle wrote:
I got an array of values where the order is relevent, eg the ages of
Alice, Bob and Charles, and I want to make a hash out of it. I got
this code that does it:
my %ages = (alice => $r[0], bob => $r[1], charles => $r[2]);
Is the
On Sun, 2007-08-12 at 22:55 -0400, yitzle wrote:
> I got an array of values where the order is relevent, eg the ages of
> Alice, Bob and Charles, and I want to make a hash out of it. I got
> this code that does it:
> my %ages = (alice => $r[0], bob => $r[1], charles => $r[2]);
> Is there a more e
Thank you.That explained what I want to know.
--Jeff Pang
** Get a sneak peek of the all-new AOL at
http://discover.aol.com/memed/aolcom30tour
On Aug 13, 2007, at 1:57 PM, Jeff Pang wrote:
Yes that's fine.
I think when we say 'use Apache qw/exit/' in modperl scripts,it may
do the same things as you mentioned -- modify the typeglob directly
-- but I'm not so sure.
I don't know too much XS but looks like this code in src/modules/pe
-Original Message-
>From: Paul Johnson <[EMAIL PROTECTED]>
>Sent: Aug 13, 2007 7:45 PM
>To: Jeff Pang <[EMAIL PROTECTED]>
>Cc: Paul Lalli <[EMAIL PROTECTED]>, beginners@perl.org
>Subject: Re: die and exit
>
>On Mon, Aug 13, 2007 at 07:24:56PM +0800, Jeff Pang wrote:
>
>> >> sub exit {
>>
On Mon, Aug 13, 2007 at 07:24:56PM +0800, Jeff Pang wrote:
> >> sub exit {
> >> print "test exit";
> >> exit;
> >> }
> >
> >This does not "overwrite" exit. Your own subroutine &exit and the
> >built-in CORE::exit() are not the same thing.
>
> Then how to overwrite CORE::exit?
> Can anybo
-Original Message-
>From: Paul Lalli <[EMAIL PROTECTED]>
>Sent: Aug 13, 2007 7:06 PM
>To: beginners@perl.org
>Subject: Re: die and exit
>
>On Aug 13, 3:29 am, [EMAIL PROTECTED] (Jeff Pang) wrote:
>> Does die call exit when it's excuted?
>> If so,when I overwrote exit() function in my scri
On Aug 13, 3:29 am, [EMAIL PROTECTED] (Jeff Pang) wrote:
> Does die call exit when it's excuted?
> If so,when I overwrote exit() function in my script,would die call this
> customized
> exit?
> sub exit {
> print "test exit";
> exit;
> }
This does not "overwrite" exit. Your own subrouti
there is a difference between the function exit:
perldoc -f exit
and a sub you have defined by your own. even if you re-use a name of a
build-in. thats why you called exit via &exit; and not exit; or exit();
#!/usr/bin/perl -w
sub exit(){
print "sub exit called\n";
}
&exit;
&exit();
if ($
Hi,
You can always read a file backwards until you reach a position that was
already processed.
This can be done by using File::ReadBackwards.
Hope that helps
Yaron Kahanovitch
- Original Message -
From: "sivasakthi" <[EMAIL PROTECTED]>
To: "beginners perl"
Sent: Wednesday, August 8
-Original Message-
>From: Xavier Noria <[EMAIL PROTECTED]>
>Sent: Aug 13, 2007 3:43 AM
>To: beginners-list
>Subject: Re: die and exit
>
>On Aug 13, 2007, at 9:29 AM, Jeff Pang wrote:
>
>> Does die call exit when it's excuted?
>> If so,when I overwrote exit() function in my script,would d
On Aug 13, 2007, at 9:29 AM, Jeff Pang wrote:
Does die call exit when it's excuted?
If so,when I overwrote exit() function in my script,would die call
this customized
exit?
Do you want some code executed if the program dies? If that's the
case assign a coderef to $SIG{__DIE__}:
$SIG{_
On Wed, 2007-08-08 at 05:58 -0700, Paul Lalli wrote:
> On Aug 8, 8:09 am, [EMAIL PROTECTED] (Sivasakthi) wrote:
> > I have a very large file. It may be contain 1lac lines
>
> Just FYI, that doesn't mean anything outside of India. You might want
> to use more conventional numeric notation when
Does die call exit when it's excuted?
If so,when I overwrote exit() function in my script,would die call this
customized
exit?
I gave a test,but didn't see die calling exit distinctly.
This works as I wanted:
use strict;
use warnings;
sub exit {
print "test exit";
exit;
}
&exit;
But
43 matches
Mail list logo