rename &file,&file.×tampI have been trying all kinds of wierd regular expressions
$VALUE=~s/^;(.*)&$/$userdoes not seem to work. please help out.. Thanking you in advance
if we can assume that file is a variable containing the old name of the file, and timestamp is a variable containing the, well... timestamp... you may find that one would access the value of a variable named file by prepending a dollar sign ($), not an ampersand (&). an ampersand generally denotes a subroutine, while a dollar sign denotes a scalar variable.
you might also want to post a more complete version of your code for further dissection.
$/ = q#(\w)# ; sub sig { print scalar reverse join ' ', @_ } sig
map { s$\$/\$/$\$2\$1$g && $_ } split( ' ', ",erckha rlPe erthnoa stJu" );
on second glance, i'm not sure what you're trying to do with the regex, but if my above comments gets you on your way to your solution, perhaps we won't need to delve into the problems with the regex above as written.
$/ = q#(\w)# ; sub sig { print scalar reverse join ' ', @_ } sig
map { s$\$/\$/$\$2\$1$g && $_ } split( ' ', ",erckha rlPe erthnoa stJu" );
Hi Kitty,
Sorry to say that, I dont understand what is your expectation. Can you provide your code to know what you've tried so far. I dont know what is stored in the $VALUE scalar variable and what you are trying to replace with the regular expression.
regards,
Frank
Don't put off till tomorrow, what you can do today.
#!/bin/sh cat file | sed ``/VALUE/s//$1/'' > file.`date "+%s"`Otherwise, try this code:
use strict; use warnings; my $user_input = shift || die "I need input"; my $file = "file"; open FH, $file or die "can't open $file for reading $!"; my @arr =; close FH; foreach(@arr){ s/VALUE/$user_input/g; } open FH, ">$file" or die "can't open $file for writing $!"; print FH @arr; close FH; rename $file, $file.time;
and perl was the easiest scripting language to learn.
Fine to know you solved your problem, whatever it was. But are you sure of what you're saying?!? Don't misunderstand me, I love Perl - and I dislike the line-noise-reputation it unfortunately has in certain circles. But I wouldn't catalogue it as "easy" so... easily.
As another side note, since it seems that quite a lot of people had difficulties to understand your post, may I suggest you to read node 174051?
Other replies and your own diagnostics have solved the issues you originally asked.
perlmonks.org content © perlmonks.org and blazar, chargrill, idle, kitty, l.frankline, tweetiepooh
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03