Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: a learning exercise - diary program

by chromatic (Archbishop)
on Jan 27, 2001 at 05:17 UTC ( #54692=note: print w/replies, xml ) Need Help??


in reply to a learning exercise - diary program

Things I would do slightly differently:
  • Use a separate variable for the DIARY location (reusing variables for different things can be confusing)
  • Return text from weather() instead of printing within the subroutine (do your printing all in one place)
  • Create a timestamp() subroutine to format the times nicely
  • (some time in the future) Create a separate get_diary_text() subroutine so you can add different entry methods as Elgon suggests
Nothing scares me about what you have now. It's solid code.
  • Comment on Re: a learning exercise - diary program

Replies are listed 'Best First'.
Re: Re: a learning exercise - diary program
by a (Friar) on Jan 27, 2001 at 09:56 UTC
    Just a guess, but there may be a misunderstanding in the reuse of *diary.
    @diary = 'path/to/diary.txt'; open(DIARY,">>@diary") or die "can't open file: $!";
    (its a good idea to do 'or die "can't open @diary: $!"' well not '@diary' but the var holding the file name in the die stmt, as in 'or die "can't open diary file $file: $!"') is odd and just sort of lucky. You're mixing the Array @diary in a scalar context, er, I think that'll just make
    $diary[$[] eq "/path/to/diary.txt";
    fortunately, putting the @diary in a quote context unrolls it as if join("", @diary) which gives you back "/path/to/dairy.txt"

    a

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://54692]
help
Chatterbox?
[Corion]: choroba: Yeah - I basically have the same for regenerating README and README.mkdown already, except that I do that in Makefile.PL, but I guess one or the other thing should somehow work ;)
[ambrus]: was this bug: https://rt.cpan. org/Public/Bug/ Display.html?id= 59814
[Corion]: ambrus: Oh - that one would be much harder to automate... The SYNOPSIS section should mostly be a runnable program IMO, but I write only small snippets in my documentation for single functions/methods, and creating the appropriate environment for ...
[Corion]: ... those in an automated fashion seems somewhat hard to me. Although it should do wonders for the test coverage ;)
[haukex]: Corion: I once wrote an automated thingy for that here

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2017-02-27 12:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (385 votes). Check out past polls.